#arpit-gupta_bacs-mandate-off-session

1 messages ยท Page 1 of 1 (latest)

gusty sonnetBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1329569720126537822

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

viscid coral
#

Hi ๐Ÿ‘‹

Are you first setting the BACS DD as a default payment method when you save it to the customer?

eternal comet
#

I'll share the code snippet. Let me check. We haven't done any change as it was working fine with other payment methods. Also the loading of payment element is set to automatic so stripe shows the enbled payment methods accordingly.

viscid coral
#

Do you have an example payment intent ID I can review? It will start with pi_

eternal comet
#

Here it is: pi_3Qi1DnB9ZMu7qZKZ0wJ4BNXg

viscid coral
#

Thanks, taking a look

eternal comet
#

I was just wondering that same code was working for other payment methods but not sure why not with BACS DD default payment method was not getting populated automatically.

#

Sure. Thanks. Hope you come up with the reason and solution.

viscid coral
#
payment_method_options: {
    amazon_pay: {
      setup_future_usage: "off_session",
    },
    card: {
      setup_future_usage: "off_session",
    },
    revolut_pay: {
      setup_future_usage: "off_session",
    },
    sepa_debit: {
      setup_future_usage: "off_session",
    },
    us_bank_account: {
      setup_future_usage: "off_session",
    },
  },

I don't see BACs here so it's not being set up for future usage

eternal comet
#

Sure let me add and try. Hope this works. Thanks a lot.

#

Do we need to do some settings from stripe dashboard for BACS?

viscid coral
#

Is it enabled on your account?

eternal comet
#

Yes BACS Payment method is enabled that's why first payment is going through

#

Also setup_future_usage is being passed as off_session while creating payment intent.

#

But some how it is not coming in payment method options

#

Okay let me try out few things on my end then I'll get back to you

viscid coral
#

Just so we are clear, here are all the parameters you passed to our API to create that payment intent

{
  amount: "2000",
  automatic_payment_methods: {
    enabled: "true",
  },
  currency: "GBP",
  customer: "cus_RXXXXXXu",
  description: "GBP prod",
  metadata: {
    altId: "XXXXXX",
    altType: "location",
    contactId: "XXXXXX",
    orderId: "XXXXX",
  },
  payment_method_configuration: "pmc_1xxxxxxxxxxx",
  payment_method_options: {
    amazon_pay: {
      setup_future_usage: "off_session",
    },
    card: {
      setup_future_usage: "off_session",
    },
    revolut_pay: {
      setup_future_usage: "off_session",
    },
    sepa_debit: {
      setup_future_usage: "off_session",
    },
    us_bank_account: {
      setup_future_usage: "off_session",
    },
  },
}

You will notice, setup_future_usage is being passed for specific payment methods. It will not apply universally

eternal comet
#

Okay Thanks a lot. I'll pass that and see if it works

viscid coral
#

I'll pass that and see if it works
What do you mean here? I suspect you had good reason to be so specific (not all payment methods support off-session usage).

#

In that case you just need to add

payment_method_options: {
    amazon_pay: {
      setup_future_usage: "off_session",
    },
    bacs_debit: {
      setup_future_usage: "off_session", <- add this
    },
    card: {
      setup_future_usage: "off_session",
    },
    revolut_pay: {
      setup_future_usage: "off_session",
    },
    sepa_debit: {
      setup_future_usage: "off_session",
    },
    us_bank_account: {
      setup_future_usage: "off_session",
    },
  },

instead of a global setup_future_usage: "off_session"

eternal comet
#

Yes it worked but now facing a different issue

#

This is the curl for confirm payment:

#

curl 'https://api.stripe.com/v1/payment_intents/pi_3Qi1npB9ZMu7qZKZ1ivykrkl/confirm'
-H 'accept: application/json'
-H 'accept-language: en-GB,en;q=0.9'
-H 'content-type: application/x-www-form-urlencoded'
-H 'origin: https://js.stripe.com'
-H 'priority: u=1, i'
-H 'referer: https://js.stripe.com/'
-H 'sec-ch-ua: "Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"'
-H 'sec-ch-ua-mobile: ?0'
-H 'sec-ch-ua-platform: "macOS"'
-H 'sec-fetch-dest: empty'
-H 'sec-fetch-mode: cors'
-H 'sec-fetch-site: same-site'
-H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
--data-raw 'setup_future_usage=off_session&payment_method=pm_1Qi1nAB9ZMu7qZKZa8U6M8GT&expected_payment_method_type=card&use_stripe_sdk=true&key=pk_test_WvH5LGch2F7bqyIJ6gVMu3iE&_stripe_account=acct_1PcpMhB9ZMu7qZKZ&client_secret=pi_3Qi1npB9ZMu7qZKZ1ivykrkl_secret_ZoCzObuEy8c1SwyMHwTyEDPIe'

#

It gives this error: The type of the provided PaymentMethod (pm_1Qi1nAB9ZMu7qZKZa8U6M8GT) is bacs_debit. This does not match the expected type card. Try confirming with a PaymentMethod of type card.

viscid coral
#

Sorry what are you doing here? This request makes no sense to me

eternal comet
#

I'm using confirmCardPayment method of stripe sdk

#

for sepa I saw that confirmSepaDebit was present

#

But for BACS is there any method in stripe sdk to confirm payment because I coudn't find one. I found only confirmBACSSetup something like that

#

For sepa debit this works: confirmCardPaymentPayload = await stripe.value?.confirmSepaDebitPayment(
clientSecret,
{
payment_method: paymentMethodId
}
)

#

For other payment methods this works: confirmCardPaymentPayload = await stripe.value.confirmCardPayment(
clientSecret,
{
payment_method: paymentMethodId,
setup_future_usage: 'off_session'
}
)

#

Similarly is there any method for BACS DD

viscid coral
#

I was looking for that too but I see in our guide for saving Bacs DD, we only show using Checkout

eternal comet
#

So in this case, confirming payment for BACS DD is not possible after payment method is saved using stripe sdk?

viscid coral
#

No, you can use it. You just need to save the payment method, which you already did, and then pass the payment method ID and confirm=True when creating the Payment Intent.

eternal comet
#

And after this which method has to be used to confirm payment? None among confirmCardPayment or confirmSepaDebitPayment? Just passing confirm : true while creating payment method will confirm payment? Then we don't need to call separately these methods?

viscid coral
#

Just passing confirm : true while creating payment method will confirm payment?

Correct. That is what "off_session" usage means. Be sure to specify off_session: true as well

eternal comet
#

You mean while selling 2nd product in which first product's saved payment method id is used we need to pass confirm: true while creating payment intent for 2nd product. Right?

viscid coral
#

If you want to use a saved payment method without the customer interacting with your site then you would create the payment intent with that payment method ID and pass both off_session and confirm parameters

eternal comet
#

okay thanks. I'll try that.

#

Now this error is coming: When confirming a PaymentIntent with a bacs_debit PaymentMethod and setup_future_usage, mandate_data is required.

viscid coral
#

Can you share the payment intent ID?

eternal comet
#

It didn't got created as it throw this error

#

Body of request was
dataToCreatePaymentIntent: {
amount: 5000,
currency: 'GBP',
customer: 'cus_RbEhLoLAAbYbxG',
payment_method: 'pm_1Qi2FuB9ZMu7qZKZ6kGIw8kU',
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
description: 'GBP prod',
metadata: {
altId: 'tPSEBbtZmbyEB47jdDhO',
altType: 'location',
orderId: '678993b0bdfd830e867594b4',
contactId: 'yiqfgQ6mqDSPe1dGwFtO'
},
confirm: true,
setup_future_usage: 'off_session'
}
}

viscid coral
#

The error message should have included a request ID, can you share it?

eternal comet
#

The payment went through on adding this:
mandate_data: {
customer_acceptance: {
type: 'offline'
}
}

#

But since it is and online payment then type would change to online and in that case providing following data is mandatory:
mandate_data.customer_acceptance.online
object
If this is a Mandate accepted online, this hash contains details about the online acceptance.

Hide child parameters

mandate_data.customer_acceptance.online.ip_address
string
Required
The IP address from which the Mandate was accepted by the customer.

mandate_data.customer_acceptance.online.user_agent
string
Required
The user agent of the browser from which the Mandate was accepted by the customer.

viscid coral
#

Sorry this is all poorly formatted and looks like a copy/paste of some error message or docs page. Can you clarify what you mean ?

eternal comet
#

Just a min

#

mandate_data: {
customer_acceptance: {
type: 'online',
online: {
ip_address: 'xxxxxx',
user_agent: 'xxxxxx'
}
}
These additional details would be required if i set type to online

viscid coral
#

Correct

eternal comet
#

then I need to keep a track of ip address and user agent as setting type to offline just to pass the payment would be wrong

viscid coral
#

The mandate_data is asking you how you collected consent from the customer to be charged on a recurring basis

#

Like, did you display some message like
"By clicking this button, you agree to let us charge you whenever we feel like it" and the customer clicked "Yes"?

eternal comet
#

In the previous transaction we did show customer that your card would be saved in case you purchase upsell product then it can be used

viscid coral
#

Okay so that would be the IP address and user agent data to collect

eternal comet
#

OKay thanks for the help.