How to implement recurring payments in Django using QuickBooks Payments (card-on-file vs vault token)?

I am building a Django-based subscription system and integrating it with QuickBooks Payments.

My goal:
  • Allow a customer to enter their credit/debit card details once.
  • Store their card in a secure way.
  • Charge them automatically every month (like Stripe Subscriptions).
What I’ve tried so far:
  • I can successfully create a Vault Token using the QuickBooks Payments API when a customer enters their card.
  • I am able to make a one-time charge using that token.
The problem:

The Vault Token seems to be one-time only (not reusable for future charges).
I want to know the correct way to store a card-on-file for recurring billing.
Do I need to use the QuickBooks Customer API to attach the card permanently?
Or is there a way to reuse the Vault Token for recurring charges?

Django 5.2
Celery for scheduling monthly tasks
QuickBooks Payments API (sandbox)

I currently store: qb_customer_id, vault_token, last4, expiry dateyour text

def charge_recurring_payment(access_token, realm_id, user, amount):
    url = "https://sandbox.api.intuit.com/quickbooks/v4/payments/charges"
    headers = {
        "Authorization": f"Bearer {access_token}",
        "Accept": "application/json",
        "Content-Type": "application/json"
    }
    payload = {
        "amount": str(amount),
        "currency": "USD",
        "cardOnFile": {
            "value": user.qb_vault_token,  # <--- works once, fails later
            "type": "TOKEN"
        }
    }
    resp = requests.post(url, json=payload, headers=headers)
    return resp.json()

How do I properly save a customer’s card in QuickBooks so that I can reuse it for monthly recurring charges?
Should I be storing the Customer ID + Card ID instead of the Vault Token?
Is there an official QuickBooks Payments pattern for recurring billing in Django/Python?

Вернуться на верх