#ignasidedieu_expanding-responses

1 messages ยท Page 1 of 1 (latest)

young sequoiaBOT
#

๐Ÿ‘‹ 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/1337100439543611484

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

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

twilit perch
#

Hello there

#

Can you share a request ID where you see this error?

#

The PaymentIntent you shared was generated from a Checkout Session?

novel plover
#

Sorry, the PaymentIntent provided is not correct because I cannot create it. This is the request_id req_0JwOMg1vosk30n, I am seeing the error in our Integration Tests

#

Probably this piece of code can help understanding the issue:

#

List<String> list= new ArrayList<>();
list.add("latest_charge");
Map<String, Object> expandList= new HashMap<>();
expandList.put("expand", list);
expandList.put("payment_intent", createParams.build());
LOGGER.info("DEBUG: Create PaymentIntent with expandList={}", expandList);
paymentIntent = PaymentIntent.create(expandList, requestOptions);

twilit perch
novel plover
#

I'm not sure if PaymenyIntent.create allows to be expandable

twilit perch
#

So the expansion piece is correct

#

It does

#

The rest of your parameters are not being passed correctly.

young sequoiaBOT
novel plover
#

And payment_intent is not accepted as part of the request, is it?

opaque smelt
#

Hi ๐Ÿ‘‹

I"m stepping in as my colleague needs to go. GIve me just a sec to check this request.

#

Okay, on the same page now. payment_intent is not a valid parameter when you are attempting to create a Payment Intent. What are you trying to do here?

novel plover
#

I am trying to create a paymentIntent with the expansion of latest_charge in its response.

opaque smelt
#

Okay so you need to pass amount and currency as parameters as we explain here

#

The expand parameter is being passed correctly but not the other parameters

novel plover
#

So in this case instead of using PaymentIntentCreateParams I need to pass each value as a key pair

opaque smelt
#

The doc I linked in my previous message shows the Java syntax in the code window on the right hand side

novel plover
#

Or create a Payment intent like before and retrieve it after

opaque smelt
#

e.g.

PaymentIntentCreateParams params =
  PaymentIntentCreateParams.builder()
    .setAmount(2000L)
    .setCurrency("usd")
    .setAutomaticPaymentMethods(
      PaymentIntentCreateParams.AutomaticPaymentMethods.builder()
        .setEnabled(true)
        .build()
    )
    .build();
#

You need to use the correct setter methods for each parameter

novel plover
#

Okay, I'll try set "expand" attribute

opaque smelt
#

As you can see in our Expand doc, you can also use the addExpand() method for your params builder

novel plover
#

I think this should work,

#

PaymentIntentCaptureParams params = PaymentIntentCaptureParams.builder()
.setAmountToCapture(amountToCapture)
.addExpand("latest_charge")
.build();

#

paymentIntent.capture(params, requestOptions);

opaque smelt
#

Are you trying to create or capture funds for an existing Payment Intent? Those are two entirely separate actions

novel plover
#

Both

#

One piece of code needs to create and in other step capture. However both requiere charge to be expandable

opaque smelt
#

Capture will happen automatically unless you specify you want to do it as a separate action

#

But yes, you will want to use the addExpand method to specify which expandable properties you want expanded in the response.

#

Give it a try and see if that does what you expect