I have a code. I used Stripe in live mode. First, I used SetupIntent to set up their account. After that, I stored customer Stripe ID and payment method ID for further use. Then I used PaymentIntent to charge an amount from their set up account. It is working with cards, but for banks, it is not working. Here is the code:
try:
if payment_method_types == "us_bank_account":
stripe.PaymentMethod.attach(
payment_data.stripe_payment_id,
customer=payment_data.customer.stripe_customer_id,
)
payment = stripe.PaymentIntent.create(
payment_method=stripe_payment_id,
customer=stripe_customer_id,
amount=int(1 * 100),
currency='usd',
confirm=True,
return_url='http://127.0.0.1:8000/',
off_session=True,
payment_method_types=["ach_credit_transfer", "ach_debit", "us_bank_account"]
)
else:
payment = stripe.PaymentIntent.create(
payment_method=stripe_payment_id,
customer=stripe_customer_id,
amount=int(1 * 100),
currency='usd',
confirm=True,
return_url='http://127.0.0.1:8000/',
off_session=True
)
except Exception as e:
print(str(e))
if payment.status == 'succeeded':
print("Payment success.")
else:
print("Payment not success.")
Let me know what to do now? The card works perfectly and shows payment success. However, when I try using a US bank card, it always shows payment not successful.
I attempted to resolve the problem but was unsuccessful, hence I require a proper solution.
Shawon Barmon Ovi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.