Skip to main content

setupRecurring Method

Overview​

The setupRecurring method establishes a payment mandate for future recurring charges. This enables subscription billing, automated bill payments, and installment plans without requiring customer presence for each transaction.

Business Use Case: A customer signs up for your SaaS monthly plan. Setup a recurring mandate so you can charge their card automatically each month.

Purpose​

ScenarioBenefit
SaaS subscriptionsAutomate monthly billing
Utility billsEnable automatic payments
Installment plansSchedule multiple payments
Membership duesAutomate renewals

Request Fields​

FieldTypeRequiredDescription
merchantRecurringPaymentIdstringYesYour unique recurring setup ID
amountMoneyYesInitial amount for validation
paymentMethodPaymentMethodYesCard or payment method
addressPaymentAddressYesBilling address
authTypestringYesTHREE_DS or NO_THREE_DS
setupFutureUsagestringNoON_SESSION or OFF_SESSION
customerobjectNoCustomer information

Response Fields​

FieldTypeDescription
merchantRecurringPaymentIdstringYour reference (echoed back)
connectorRecurringPaymentIdstringConnector's mandate ID
statusPaymentStatusACTIVE, FAILED, PENDING
mandateReferenceobjectMandate ID and status
errorErrorInfoError details if failed
statusCodenumberHTTP status code

Example​

SDK Setup​

const { PaymentClient } = require('hyperswitch-prism');

const paymentClient = new PaymentClient({
connector: 'stripe',
apiKey: 'YOUR_API_KEY',
environment: 'SANDBOX'
});

Request​

const request = {
merchantRecurringPaymentId: "recurring_001",
amount: {
minorAmount: 2900,
currency: "USD"
},
paymentMethod: {
card: {
cardNumber: { value: "4242424242424242" },
cardExpMonth: { value: "12" },
cardExpYear: { value: "2027" },
cardCvc: { value: "123" },
cardHolderName: { value: "John Doe" }
}
},
address: {
billing: {
line1: "123 Main St",
city: "San Francisco",
state: "CA",
zip: "94102",
country: "US"
}
},
authType: "NO_THREE_DS",
setupFutureUsage: "OFF_SESSION"
};

const response = await paymentClient.setupRecurring(request);

Response​

{
merchantRecurringPaymentId: "recurring_001",
connectorRecurringPaymentId: "seti_3Oxxx...",
status: "ACTIVE",
mandateReference: {
mandateId: "pm_3Oxxx...",
mandateStatus: "ACTIVE"
},
statusCode: 200
}

Next Steps​