#danitoyy

1 messages ยท Page 1 of 1 (latest)

gleaming wharfBOT
fallow magnet
wispy heron
#

.addPaymentMethodType(null)

#

Thats my current code

#

When building the update params

#

Maybe I need to pass "card" explicitly ?

fallow magnet
#

Sounds reasonable yep

wispy heron
#

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

#

๐Ÿ˜„

fallow magnet
#

Checking. I know there's a setPaymentMethodTypes method on other calls

wispy heron
#

This is the java lib

#

For your convenience ๐Ÿ™‚

fallow magnet
#

Yep

#

Did you try addAllPaymentMethodType?

PaymentIntentUpdateParams params = PaymentIntentUpdateParams.builder().addAllPaymentMethodType(Arrays.asList("card")).build();
paymentIntent.update(params);
wispy heron
#

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;
}

dusk inlet
#

Hey! Taking over for my colleague. Could you please share the final requst Id to Stripe API.

wispy heron
#

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

dusk inlet
#

Or the PaymentIntent Id

wispy heron
#

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

dusk inlet
#

According to this error message, you are passing an empty string as a payment method

wispy heron
#

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

fallow magnet
#

You'd pass an empty string to unset the field, not null

dusk inlet
#

You are passing an array with empty value

wispy heron
#

But this is a list

#

Its not a string value ๐Ÿ˜„

dusk inlet
#

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

wispy heron
#

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 ?

fallow magnet
dusk inlet
wispy heron
#

Guys

#

I am not unsetting an array ๐Ÿ˜„

#

With empty string

#

I was passing null the whole time

#

Oh yea

#

its the same basically

dusk inlet
#

Can you debug PaymentIntentUpdateParams and share what value you are passing before calling Stripe API?

wispy heron
#

Yes, one second

#

pi_3NjEpDCKbv7cTYjh0qnX2zES

dusk inlet
#

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

wispy heron
#

Thats what I am doing

#

I just dont see another Id

#

:D:D

#

this is the intent after updating it with the params

dusk inlet
#

You can see that PayementMethodTypes is not an empty array

wispy heron
#

Yup and I want to change it from sepa to card

dusk inlet
#

can you open it in the debug console and make another screenshot

wispy heron
dusk inlet
#

This is the PaymentIntent object

#

Can you share the code you are using to update the PaymentIntent? where you have PaymentIntentUpdateParams

wispy heron
#

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

dusk inlet
#

Now can you inspect cardPaymentRequestplease and share the screenshot

wispy heron
#

This is the two possible options, if it is being updated to card payment

dusk inlet
#

Wait

wispy heron
#

or if it is a bank transfer (sepa)

dusk inlet
#

Can you please inspect the output of buildUpdateParams(cardPaymentRequest)?

wispy heron
#

Yup

#

One sec

dusk inlet
#

See, you are passing an array with one null element.

wispy heron
#

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

#

๐Ÿ˜„

dusk inlet
#

The array object it's not null.

#

you are passing an array of null element.

wispy heron
#

Sure, what do I pass to get the default card value

dusk inlet
#

Now you can't unset payment_element_types.

#

You need to pass payment_element_types:['card]

wispy heron
#

okay

#

let me try real quick

#

its a small change

dusk inlet
#

You can do a test using this update param:

aymentIntentUpdateParams piParams = PaymentIntentUpdateParams.builder()
                    .addPaymentMethodType("card")
                    .build();
wispy heron
#

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?

dusk inlet
wispy heron
#

Okay, will give that to the frontend devs

#

Thank you guys and sorry for my stupid questions ๐Ÿ˜„

dusk inlet
#

Np! Happy to help!

wispy heron
#

Atleast we managed to fix the issue

dusk inlet
#

Yeap!

wispy heron
#

have a good one