#ahsan-terminal-m2
1 messages · Page 1 of 1 (latest)
@graceful canopy hello! I don't understand the question or what that could mean at all I'm sorry, do you have more details
I am using M2 card reader for processing payments
I need to fetch payment method id
How can I fetch that?
Can you try and provide more context around your ask please? What exact doc are you following, what does your code look like? At which step are you trying to access the PaymentMethod id?
Please try to explain all of this in one message instead of multiple short sequential messages so that I can help you further
@graceful canopy do you have more details?
yes
Terminal.shared.createPaymentIntent
I am not getting paymentMethodID in return
after scanning card on M2 reader
I'm really sorry, you are not giving me enough actionable information to help you. Creating a PaymentIntent does not collect card details at all. This happens later. You haven't shared any info I asked except one line of code
Terminal.getInstance()
.collectPaymentMethod(paymentIntent, collectPaymentMethodCallback)
I scan card after this method call in Step 2
//Step 2 - once we've created the payment intent, it's time to read the card
okay so what's the problem them? What do you get back at that step? what's blocking you?
ahsan-terminal-m2
// Step 3 - we've collected the payment method, so it's time to process the payment
private val collectPaymentMethodCallback by lazy {
object : PaymentIntentCallback {
override fun onSuccess(paymentIntent: PaymentIntent) {
// Here when I am accessing paymentIntent.paymentMethodId -> returns null
}
override fun onFailure(e: TerminalException) {
// Update UI w/ failure
print(e.localizedMessage)
}
}
}
See this comment
// Here when I am accessing paymentIntent.paymentMethodId -> returns null
?
gotcha, this is the piece of info I was asking for
@graceful canopy so at that point the card details have been collected locally but the PaymentIntent hasn't been confirmed yet so there's no PaymentMethod id to access, that's expected
So, how I can retrieve paymentMethodID in this process?
I need to send paymentMethodId to server for creating payment Intent
You already have a PaymentIntent right?
I'm sorry, I'm worried you are totally misunderstanding how this works and the state machine here
1/ Create a PaymentIntent
2/ Collect card details in your app
3/ Confirm the PaymentIntent in your app
4/ All done
But I want to create payment Intent on server. So, what will be the process now?
What exact doc are you following? I really don't understand your flow here. You can not collect card details without an already existing PaymentIntent first
So in my flow, I want everything to be done on backend side including creating payment intent and app will only scan card
what do you mean "scan card"? Like with a camera?
Scan/Swipe card through M2 reader
then that is impossible. To collect card details you need to configure why, especially the exact currency and amount so that it is part of the confirmation. This is required for in person payments really
?
My colleague @scarlet walrus is taking over and can help you figure out next steps but I think the first step is for you to carefully read the canonical docs around integrating Terminal and understanding why a PaymentIntent is required and things can't happen server-side in that case
To clarify @graceful canopy are you trying to take a payment right now, or save a card for later payments?
Hi @scarlet walrus
What you describe above creating a payment intent for use with your Terminal reader, if for taking payment with a physical card in person right now, and before you get that paymentMethod you need to confirm the payment
https://stripe.com/docs/terminal/payments/collect-payment?terminal-sdk-platform=android#confirm-payment
If you are trying to save a physical card to use later without a payment right now, then you should follow this guide instead: https://stripe.com/docs/terminal/features/saving-cards/save-cards-directly?terminal-sdk-platform=android#create-setupintent
So, the scenario in my case is .
- User will donate amount i.e. $100
- then there is middle provide who will deduct his percentage lets suppose $1
- Remaining will be transfer to connected account after stripe fees.
This is the scenario
Now how can I achieve this
val params = PaymentIntentParameters.Builder()
.setAmount(1000)
.setCurrency("usd")
.build()
What other params I will have to set in payment builder
For that model you should take a look at COnnect destination charges and setting application fees:
https://stripe.com/docs/connect/destination-charges#application-fee
So according to above link, payment intent will be created on server side?
As the guide shows with terminal payments you can create the payment intent either server or client side, that's up to you
Thsi connect docs show server-created examples only, yes
You can set those same parameters with the Terminal SDK though:
https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-payment-intent-parameters/application-fee-amount.html
https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-payment-intent-parameters/transfer-data-destination.html
transferDataDestination = ConnectAccountId(Where the remaining funds will be deposited?) after stripe and application fee deduction?
That's the account the transfer will be sent to. You should review the connect docs i linked to understand how stripe fees are deducted.