#danitoyy
1 messages ยท Page 1 of 1 (latest)
Should be possible, yep: https://stripe.com/docs/api/payment_intents/update#update_payment_intent-payment_method_types
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
.addPaymentMethodType(null)
Thats my current code
When building the update params
Maybe I need to pass "card" explicitly ?
Sounds reasonable yep
But to me it sounds like I will add card as well
instead of removing sepa_debit and putting card on top of it
looking at the code in the library
/**
* Add an element to paymentMethodTypes list. A list is initialized for the first add/addAll
* call, and subsequent calls adds additional elements to the original list. See {@link
* PaymentIntentUpdateParams#paymentMethodTypes} for the field documentation.
*/
public Builder addPaymentMethodType(String element) {
if (this.paymentMethodTypes == null) {
this.paymentMethodTypes = new ArrayList<>();
}
this.paymentMethodTypes.add(element);
return this;
}
It adds to the list instead of overwriting it
๐
Checking. I know there's a setPaymentMethodTypes method on other calls
Yep
Did you try addAllPaymentMethodType?
PaymentIntentUpdateParams params = PaymentIntentUpdateParams.builder().addAllPaymentMethodType(Arrays.asList("card")).build();
paymentIntent.update(params);
The code is the same
it adds all
desnt overwrite
๐
/**
* Add all elements to paymentMethodTypes list. A list is initialized for the first
* add/addAll call, and subsequent calls adds additional elements to the original list. See
* {@link PaymentIntentUpdateParams#paymentMethodTypes} for the field documentation.
*/
public Builder addAllPaymentMethodType(List<String> elements) {
if (this.paymentMethodTypes == null) {
this.paymentMethodTypes = new ArrayList<>();
}
this.paymentMethodTypes.addAll(elements);
return this;
}
Hey! Taking over for my colleague. Could you please share the final requst Id to Stripe API.
com.stripe.exception.InvalidRequestException: You passed an empty string for 'payment_method_types[0]'. We assume empty values are an attempt to unset a parameter; however 'payment_method_types[0]' cannot be unset. You should remove 'payment_method_types[0]' from your request or supply a non-empty value.; code: parameter_invalid_empty; request-id: req_9br5rBAKZLrfgs
Or the PaymentIntent Id
Thats it
request-id: req_9br5rBAKZLrfgs
I tried updating it
and it gave me that error
Currently, it should be set to sepa_debit
But what if the customer decides to go back and change to a card payment
According to this error message, you are passing an empty string as a payment method
if he does not want a bank transfer
No, I am passing null
In order to get the default value, which should be "card"
It says that in the comment on top of the method
You'd pass an empty string to unset the field, not null
You are passing an array with empty value
Don't pass anything in that case payment_method_types=null
However, according to the requestId you are sharing, you are passing payment_method_types:[""] which is not correct
Oh, that might be a missunderstaning from my side
I thought the update params are updating only the fields I pass
not the whole object
But apparrently it updates everything, even the fields I have given upon creating and not passing them later in the update
And they are also being overridden
correct ?
You still unset an array with an empty string
Can you share an example of a requestid?
Guys
I am not unsetting an array ๐
With empty string
I was passing null the whole time
Oh yea
its the same basically
Can you debug PaymentIntentUpdateParams and share what value you are passing before calling Stripe API?
This is the PaymentIntent Id
I meant to log the object PaymentIntentUpdateParams you are passing to the API
in your local integration
just print/ create a breakpoint and debug inspect the object you are pssing to the API
Thats what I am doing
I just dont see another Id
:D:D
this is the intent after updating it with the params
You can see that PayementMethodTypes is not an empty array
Yup and I want to change it from sepa to card
can you open it in the debug console and make another screenshot
This is the PaymentIntent object
Can you share the code you are using to update the PaymentIntent? where you have PaymentIntentUpdateParams
Yup
One second
I will share how it starts as well for your convenience
I always check if I have created the intent before that. If I find the intendId in my database, I will just update the existing one
iinstead of creating it
and those arethe params
one sec
Now can you inspect cardPaymentRequestplease and share the screenshot
Wait
or if it is a bank transfer (sepa)
Can you please inspect the output of buildUpdateParams(cardPaymentRequest)?
See, you are passing an array with one null element.
It is null, because I am trying to remove sepa_debit
I know man, but how do I remove it
I want it to be "card" from now on
you get me
๐
Sure, what do I pass to get the default card value
Now you can't unset payment_element_types.
You need to pass payment_element_types:['card]
You can do a test using this update param:
aymentIntentUpdateParams piParams = PaymentIntentUpdateParams.builder()
.addPaymentMethodType("card")
.build();
Yea, thats what I am doing now
okay
I can see it changing from card to sepa debit
and from sepa debit to card
all good
this will also change the element ui as well, correct?
Yes. You may need to fetch the PaymentIntent updates using this method:
https://stripe.com/docs/js/elements_object/fetch_updates
(from your frontend after updating the PaymentIntent card<=>sepa)
Okay, will give that to the frontend devs
Thank you guys and sorry for my stupid questions ๐
Np! Happy to help!
Atleast we managed to fix the issue
Yeap!
have a good one