Authorization Codes: How Paystack Recurring Billing Really Works
A Paystack authorization code is a token that represents a customer's saved payment method. It is created after the customer's first successful card payment. Paystack tokenizes the card details and returns an authorization_code string that you can use to charge the card again without the customer re-entering their information. Both the managed Subscriptions API and the manual charge_authorization endpoint use authorization codes under the hood.
Reusable vs Non-Reusable Authorizations
Not every authorization can be used for recurring charges. The reusable field tells you which ones can.
Reusable (reusable: true): Card payments almost always produce reusable authorizations. You can call charge_authorization with these codes as many times as you need. The customer does not need to re-authenticate.
Non-reusable (reusable: false): Bank transfer and USSD payments typically produce non-reusable authorizations. These are one-time tokens. You cannot charge them again. They exist in the authorization object for record-keeping, but calling charge_authorization with them will fail.
This distinction matters because your application needs to handle both cases. If a customer's first payment was via bank transfer, you have their money but you do not have a reusable authorization. You cannot set up recurring billing for them until they make a card payment.
function canSetupRecurring(authorization) {
if (!authorization.reusable) {
console.log('This payment method cannot be used for recurring charges.');
console.log('Channel:', authorization.channel);
console.log('The customer needs to pay with a card to enable recurring billing.');
return false;
}
return true;
}
// When processing a successful payment
function handleSuccessfulPayment(transactionData) {
var auth = transactionData.authorization;
if (canSetupRecurring(auth)) {
// Safe to store for recurring billing
storeAuthorizationForRecurring(transactionData.customer.email, auth);
} else {
// Grant access for this payment only
// Prompt the customer to add a card for recurring billing
promptForCardPayment(transactionData.customer.email);
}
}
For a complete treatment of this topic, including mobile money and country-specific behavior, see reusable vs non-reusable authorizations.
Security Considerations
An authorization code is not a card number, but it can be used to charge real money. Treat it with the same seriousness you would treat any payment credential.
What authorization codes can do
- Charge the customer's card for any amount, at any time, without their interaction.
- Create subscriptions on behalf of the customer.
What authorization codes cannot do
- Reveal the full card number. You only ever see bin (first 6 digits) and last4.
- Be used on a different Paystack merchant account. The authorization is scoped to your integration.
- Be used without your Paystack secret key. The charge_authorization call requires authentication.
Storage guidelines
- Store authorization codes in your database, not in localStorage, cookies, or frontend code.
- Encrypt the authorization_code column at rest. It is not PCI-regulated like raw card numbers, but it is still a payment credential.
- Restrict database access to authorization codes. Not every developer on your team needs to see them.
- Log charge attempts but do not log the full authorization code. Use the last4 for debugging.
For a complete guide on secure storage patterns, see storing authorization codes securely.
Key Takeaways
- ✓Authorization codes are tokens created after a customer's first successful card payment. They represent the saved payment method.
- ✓The tokenization happens on Paystack's side. You never see or handle raw card numbers. You only work with the authorization_code string.
- ✓Only authorizations marked reusable: true can be used for recurring charges. Card payments produce reusable authorizations; bank transfers and USSD typically do not.
- ✓Authorization codes do not expire on a fixed schedule. They remain valid as long as the underlying card is valid.
- ✓The Subscriptions API uses authorization codes internally. When Paystack renews a subscription, it charges the authorization linked to that subscription.
- ✓With charge_authorization, you control the schedule, the amount, and the retry logic. Paystack just executes the charge using the stored token.
Frequently Asked Questions
- Do Paystack authorization codes expire?
- Authorization codes themselves do not have a fixed expiry date in Paystack's system. They remain usable as long as the underlying card is valid. When the card expires, is cancelled, or is blocked by the bank, charges against the authorization code will fail. Track the exp_month and exp_year fields to anticipate card expiry.
- Can I use an authorization code from a bank transfer for recurring billing?
- No. Bank transfer payments produce authorizations with reusable: false. You cannot use them for recurring charges via charge_authorization or for creating subscriptions. The customer needs to make a card payment to generate a reusable authorization.
- Can someone use my authorization code on a different Paystack account?
- No. Authorization codes are scoped to your Paystack integration (your merchant account). They cannot be used by other merchants, even if someone obtains the authorization code string. The charge_authorization call also requires your secret key.
- How many authorization codes can one customer have?
- There is no practical limit. Each successful card payment creates a new authorization. If a customer pays with five different cards, they have five authorization codes. Use the signature field to identify when two authorizations represent the same physical card.
- What is the signature field on an authorization?
- The signature is a unique identifier for the physical card. If a customer pays with the same card multiple times, each payment creates a new authorization code, but all of them share the same signature. Use this to deduplicate and avoid showing the same card twice in your UI.
Ready to build real-world apps?
Join the McTaba Labs full-stack marathon (4 months full-time · 6 months part-time). Learn M-Pesa, USSD, and WhatsApp engineering while shipping 8 production apps.
Apply to the McTaba Marathon