#zishaan-terminal-androidsdk

1 messages ยท Page 1 of 1 (latest)

opal echo
#

Hello!

frail rover
#

Hi there!

#

Thanks for the quick response

opal echo
#

Let me ask my team

frail rover
#

Awesome! Thanks!!

ionic wadi
#

Hello! I'm having a look at this now, but it will be a few minutes as I need to adjust my Terminal test integration. Wanted to let you know we haven't forgotten about you. ๐Ÿ™‚

frail rover
#

Haha sounds good! Thanks Rubeus ๐Ÿ™‚

ionic wadi
#

Question for you: after collectPaymentMethod is called are you able to see the amount of the tip selected? I'm not seeing it show up in my testing (although I'm not using Android).

frail rover
#

I think there's a seperate method to get that

#

Let me check

#

I was going to figure that out next

ionic wadi
#

Oh, I think I know what I'm doing wrong... one moment...

frail rover
#

Okay sweet! I think there's supposed to be amount_details somewhere but I can't seem to find it

ionic wadi
#

Ah, got it working!

frail rover
#

Oh awesome!!

#

How'd you manage to get it to work?

ionic wadi
#

Okay, so this is mostly going to be server-side changes, not client-side. On your server, when you receive the request to capture the PaymentIntent, you can retrieve the PaymentIntent from Stripe, look at the amount_details on the PaymentIntent to get the tip amount, then update the PaymentItent with the application_fee_amount you want, then capture it after that.

frail rover
#

Oh gotcha! So does that mean that for this to work - it'll have to be a capture method of 'manual'?

ionic wadi
#

Yep, that's a requirement for tipping.

frail rover
#

That's what it is right now - but I was going to switch it to automatic actually

#

Gotcha!

#

Okay perfect!!

#

This is super helpful!!

#

And just to clarify, if the application fee amount is higher in the capture endpoint from what I send to the reader, that's no problem?

ionic wadi
#

Not sure I understand your last question, can you provide more details?

#

Like an example scenario?

frail rover
#

Oh yeah for sure, so before the tip the price of all the items is say $100 and the fees are set to 2% so the application fee amount is 200 cents

#

if after the tip (the total is $140) - during the capture step (server-side) am I just changing the application fee amount to 280 cents?

#

and it wouldn't cause any issues?

ionic wadi
#

Yeah, that's correct. In my testing just now, for example, I created my PaymentIntent for $5.00, then selected a $3.00 tip on the reader, then I updated the PaymentIntent to have a $1.00 application_fee_amount just before I captured it (it previously had none at all).

frail rover
#

oh perfect!!

#

This is super helpful!!

#

Thanks Rubeus!!

#

๐Ÿ™‚

ionic wadi
#

This is a slightly edited version of the actual test code I just used on my server:

$paymentIntent = \Stripe\PaymentIntent::retrieve($paymentIntentID);

// Look at $paymentIntent->amount_details to calculate the new fee

$paymentIntent = \Stripe\PaymentIntent::update($paymentIntentID, [
    'application_fee_amount' => 100,
]);

$paymentIntent->capture();
#

That's inside the capture request handler coming from my client.

frail rover
#

I see! So it's update the application fee amount on the payment intent, and then capture it

ionic wadi
#

Also, fun fact: I had started out by putting breakpoints client side to see if I could see the tip amount there after collecting the PaymentMethod, but when doing that the tip never showed up, even after capture. Turns out there's some kind of issue that prevents the tip from being applied at all if the client-side process takes too long (like waiting on me to poke around while paused on a breakpoint). So watch out if you're using breakpoints in this flow!

frail rover
#

Can I just change the application fee amount on the capture?

#

So for our US clients since we have overcapture we do this:

ionic wadi
#

Oh, that's a good question! Let me check...

frail rover
#
      // Capture a payment intent with application_fee_amount
      // Reference: https://stripe.com/docs/payments/capture-later#capture-funds
    const paymentIntent = await stripe.paymentIntents.capture(
          paymentIntentId,
          {
            amount_to_capture: finalAmount,
            application_fee_amount: applicationFeeAmount || 0,
          }
        );
ionic wadi
#

Yes, you can! That would make a lot of sense! ๐Ÿ˜…

frail rover
#

Okay sick!!

#

Hahaha that's perfect!!

ionic wadi
#

Yep! So the key is retrieving the PaymentIntent from Stripe on your server to calculate the correct application_fee_amount to use when you capture it.

frail rover
#

Gotcha! That makes sense!

#

Awesome!! Thanks Rubeus ๐Ÿ’ฏ I really appreciate the help!