#trying-to-process-bacs-debit

1 messages ยท Page 1 of 1 (latest)

wraith summitBOT
empty rain
#

Have you looked into setting the mandate_data parameter already? Do you have a specific question?

narrow coral
#

no, how do I set the parameter?

#

Yes, my specific question is how can I make offline payments

empty rain
narrow coral
#

looking...

#

Ok it says "This hash contains details about the Mandate to create. This parameter can only be used with confirm=true"

#

what is an example of what I need to enter into that parameter?

empty rain
#

I don't understand the question. The API reference shows all the attributes and the types of values the API is expecting

narrow coral
#

I don't understand how to get mandate information to put into the param

#

So I just need to add the one required parameter value? "mandate_data.customer_acceptance.type": "offline"

empty rain
#

I believe that will work. When you test it, does it have the desired effect?

narrow coral
#

I get "parameter_unknown" error

#

Am I writing it correclty?

#

"mandate_data.customer_acceptance.type"

empty rain
narrow coral
empty rain
#

You have to provide the mandate_data on the Confirm API call (not the creation API call)

narrow coral
#

oh ooops, I should send it like this "mandate_data[customer_acceptance][type]"

empty rain
#

Make sure you're using that

narrow coral
empty rain
narrow coral
#

looking now

#

ok so it has to be a checkout? Currently I use the payment form. Is it not the same thing?

empty rain
#

No it doesn't, I'm just trying to figure out which guide you're following and figure out why it doesn't explain how to do future payments or manage mandates

narrow coral
#

ok one sec.. I have so many guides...

empty rain
#

That seems like a knowledge gap that our docs should address, so I'd like to update it to include a mention of these concepts if it doesn't already

narrow coral
#

ok let me pull it up.. one sec.. I have so many windows open

empty rain
#

No worries. I think if you are using Payment Element, the mandate should be collected automatically, so you may be able to reference the mandate that was created on the first Payment/Setup Intent

narrow coral
#

you mean the mandate is returned in the payload object when I make the payment intent?

#

or when I finish the payment (ie after the payment is submitted)?

empty rain
#

After the Payment Intent is confirmed

narrow coral
#

yeah seems right

#

payment intent is confirmed when the payment is submitted?

#

And I get that mandate from the returned payload or do I query stripe for it?

empty rain
#

I think I was mistaken earlier. We store mandate data on the Payment Intent for other asynchronous payment types (e.g. ACSS or Cards with mandates) but it doesn't look like that's the case for BACS.

narrow coral
#

When I create the payment intent, looks like I need to add this param: "payment_intent_data[setup_future_usage]"="off_session"

empty rain
#

So you would have to query for it

narrow coral
#

oh ok, perfect

#

so I query the payment intent?

empty rain
#

Hmmmm, I think I might have been mistaken. I can't actually figure out how to query for the mandate. Give me a few minutes to circle back

narrow coral
#

ok sure no problem - thank you!

#

ugh "payment_intent_data[setup_future_usage]" does not exsist as a parameter on payment intent

empty rain
#

So it looks like you would get the Mandate from either the Setup Intent (https://stripe.com/docs/api/setup_intents/object#setup_intent_object-mandate ) that was used to setup that Payment Method for future usage, or the Charge object (https://stripe.com/docs/api/charges/object#charge_object-payment_method_details-bacs_debit-mandate)

narrow coral
#

I'm currently not using either of those

empty rain
#

The Payment Element would set those for you

narrow coral
#

let me look at charge object

#

you mean when I do the checkout?

empty rain
#

Charges are created when a payment is created and you can get them from the Payment Intent object.

narrow coral
#

ok so I should be able to see it in the dashboard, right? Looking now...

deft surge
#

Hi there. Taking over for two-shoes as they have to step out

narrow coral
#

ok this is getting better

#

payment_intent_mandate_invalid

#

Only active mandates can be used with PaymentIntents.

deft surge
#

Yeah it was a single use mandate already used

#

What's your end goal here?

narrow coral
#

I want to make offline payments

#

as many as I'd like and keep charging a Bacs debit

#

seems I get a mandate after submitting a payment but then the mandate is deemed as already used and can't be used again?

deft surge
narrow coral
#

I am not using check out. I am using payemnt form

#

Is there a way to get the mandate for future bacs payment in this flow?

deft surge
#

It's the same principle as the article I shared

#

Only not using Checkout

narrow coral
#

so setup_future_usage = off_session?

#

or on_session?

deft surge
#

off_session if you are going to charge them off session. on_session if you are going to charge them on session. Completely depends

narrow coral
#

initial payement is on session then after that off session

#

my flow is that they make a their first payment then subsequently, we charget them

#

so is that off_session?

deft surge
#

yep

narrow coral
#

ok trying it now...

deft surge
narrow coral
#

it has a mandate

deft surge
#

Ok. Now try charging it offsession in the exact same way that was done at the link I shared

narrow coral
#

I now get this error when creating a subsequent offline payment intent: "The provided mandate has a different payment method than the one provided on the PaymentIntent."

#

but I used the same payment method

#

pm_1MgvRfCZpRa6P5DM7vcOVz4L

#

oh wait - I queried the mandate and found a different payment method pm_1MjSOjCZpRa6P5DMLWyjhlkF. I used that one when making the offline payment and it worked!

#

But why is there a new payment method?

deft surge
#

There isn't

#

Look at the pm associated with the pi in your dashboard

#

Not sure what pm_1MgvRfCZpRa6P5DM7vcOVz4L is for

#

Looks like that one was from a week ago

narrow coral
#

pm_1MgvRfCZpRa6P5DM7vcOVz4L was the pm I used when I made teh first payment intent, the one where I say Setup Future Usage = off_session

deft surge
#

You created it a week ago

#

Oh I see what you're saying

#

You passed that old pm to the payment intent function

#

That doesn't really make sense if you're setting up a payment method for future usage

#

You need to be on session for the first payment to collect the user's info

#

So, the payment method won't really exist yet and one is created when you collect the user's payment info and set it up for future usage

narrow coral
#

ok so when I create the first payment intent with Setup Future Usage = off_session, do I not need to specify a payment method? Maybe that param is irrelevant?

#

I though that had to be attached to a customer

deft surge
#

No the whole point of the checkout flow is to collect and create a pm

narrow coral
#

maybe I don't actually need to attach payment method to a customer if I'm using these mandates?

deft surge
#

It shouldn't exist yet

#

You do need the pm attached, but that's the whole point of your checkout flow

narrow coral
#

So what is all this business of attaching a pm to a cus?

deft surge
#

What do you mean?

#

How are you collecting payment info right now?

#

The attachment should happen automatically if you use the payment element

narrow coral
#

This API - {{baseUrl}}/v1/payment_methods/:payment_method/attach?customer=cus_NSJ2putWkB0jmJ

deft surge
#

No how are you collecting payment info

#

What guide are you following

#

The payment element?

narrow coral
#

I'm collecting through stipe.js

deft surge
#

Are you not following a guide?

narrow coral
#

so you're saying it gets attached when I go through this stripe.js flow?

#

my understanding was that I had to explicitly attach the pm to the customer

#

but I suppose I don't...

deft surge
#

What guide are you following?

narrow coral
#

yes, this one

#

but there are so many docs and every support person points me to a different one

deft surge
#

Ok. So if you read through that guide, attachment and payment method creation isn't mentioned

#

That's done through the payment element automatically

narrow coral
#

ok great. So I do need to specify the customer though, right?

deft surge
#

Yeah you just pass the customer id when creating the payment intent

#

But if you're passing the payment intent client secret to stripe.js to collecting payment method details, then a payment method will be created and attached to the customer automatically

narrow coral
#

ok great and then the PM is created for me. I query the PI to get the mandate and the PM for future offline payments, right?

#

oooh kay...

#

that makes total sense

deft surge
#

But recommend testing it out

#

I think mandate is implicitly associated with the PM if you set it up for future usage correctly so don't think you need to specify mandate for future off session payments

#

But again, recommend testing it to be sure

narrow coral
#

I just removed the mandate and it worked

deft surge
#

Cool yeah

narrow coral
#

wow - so all I was missing in all of this was setup_future_usage = off_session

deft surge
#

And shouldn't include pm_123 in the PI creation request for your flow

narrow coral
#

ooooh

#

I just need the customer

#

no mandate, no payment method

#

wow - it's that simple.. you guys do it all.. as long as I pass the magic setup_future_usage = off_session

#

does it ever expire and then I have to send the user back to the accept a payment stripe.js flow again?

#

Oh no, actually if I don't send the PM_ then it will debit the credit card instead of Bacs Debit

#

maybe because that customer paid with credit card before

#

and payments default to credit card..?

deft surge
#

Sorry I think I confused you. I meant you don't need to specify the PM_ in the initial payment intent creation request (the on-session one).

#

For the off-session ones, you're correct

#

It's safest to pass pm_ for the offsession payments in case they have a card as their default

narrow coral
#

ah ok

#

got it

#

thank you so much

#

super helpful

deft surge
#

No problem. And mandate shouldn't expire or anything

narrow coral
#

Can I bug you again if I have issues?

deft surge
#

Yeah, but we archive threads after some time, so if you have any more questions, just ask in the main channel again

narrow coral
#

oh ok sounds good

#

thank you!

deft surge
#

No problem

narrow coral
#

You really helped unblock me. Very grateful ๐Ÿ™‚