#Gautam- subscription
1 messages · Page 1 of 1 (latest)
Hi Gautam, so you want to setup a subscription with ACH as the default payment method?
yes, but dynamically I want to attach payment method while subscription
I have bank account ref for a customer that i want to set while subscription
Thanks for the confirmation. Please give me some time to work out a solution for you.
const subscription = await stripe.subscriptions.create({
customer: customerId,
transfer_data:
{
destination: destinationStripeId
},
default_payment_method: paymentMethodRef,
metadata: {
subscription_id: subscriptionId,
solution_id: solutionId,
remmitance_org_id: remittanceOrgId,
customer_org_id: customerOrgId
},
items: [
{
price: priceObjectId,
tax_rates: [taxRateReference]
},
]
});
return subscription;
Can you tell me how did you get the paymentMethodRef ?
const bankAccount = await stripeCustomerService.attachBankToCustomer(
bankAchToken.id,
existingAccounts[0].customer_reference
);
this way we are attaching bank to customer
ba_1JwilsHiJqyEPSdXb4tgVo7F this is ref which we have for bank ach and that we are attching to customer
const token = await stripe.tokens.create({
bank_account: {
country: constant.COUNTRY,
currency: constant.CURRENCY,
account_number: accountNumber,
routing_number: routingNumber,
account_holder_name: accountHolderName,
account_holder_type: accountHolderType
}
});
const source = await stripe.customers.createSource(customerId, {
source: token.id
});
return source;
Thanks for the code. so you are using the source API. could you try to pass the paymentMethodRef to default_source param instead of default_payment_method?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yes, if you are using the Source API for card as well then you can pass the id to the default_source.
However, I strongly encourage you to migrate to the new payment_method API for card payments, which allows you to use the latest features such as 3DS for card transactions.
Thanks Jack , default_source is working