#zishaan-terminal-androidsdk
1 messages ยท Page 1 of 1 (latest)
Let me ask my team
Awesome! Thanks!!
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. ๐
Haha sounds good! Thanks Rubeus ๐
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).
I think there's a seperate method to get that
Let me check
I was going to figure that out next
Oh, I think I know what I'm doing wrong... one moment...
Okay sweet! I think there's supposed to be amount_details somewhere but I can't seem to find it
Ah, got it working!
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.
Oh gotcha! So does that mean that for this to work - it'll have to be a capture method of 'manual'?
Yep, that's a requirement for tipping.
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?
Here are the docs which indicate the capture_method must be manual for on-reader tips: https://stripe.com/docs/terminal/features/collecting-tips/on-reader#collect-payment
Not sure I understand your last question, can you provide more details?
Like an example scenario?
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?
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).
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.
I see! So it's update the application fee amount on the payment intent, and then capture it
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!
Can I just change the application fee amount on the capture?
So for our US clients since we have overcapture we do this:
Oh, that's a good question! Let me check...
// 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,
}
);
Yes, you can! That would make a lot of sense! ๐
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.