#ahsan-terminal-m2

1 messages · Page 1 of 1 (latest)

hardy lakeBOT
humble thunder
#

@graceful canopy hello! I don't understand the question or what that could mean at all I'm sorry, do you have more details

graceful canopy
#

I am using M2 card reader for processing payments

#

I need to fetch payment method id

#

How can I fetch that?

humble thunder
#

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?

graceful canopy
#

yes

#

Terminal.shared.createPaymentIntent

#

I am not getting paymentMethodID in return

#

after scanning card on M2 reader

humble thunder
#

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

graceful canopy
#

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

humble thunder
#

okay so what's the problem them? What do you get back at that step? what's blocking you?

#

ahsan-terminal-m2

graceful canopy
#

// 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

#

?

humble thunder
#

gotcha, this is the piece of info I was asking for

humble thunder
#

@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

graceful canopy
#

So, how I can retrieve paymentMethodID in this process?

#

I need to send paymentMethodId to server for creating payment Intent

humble thunder
#

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

graceful canopy
#

But I want to create payment Intent on server. So, what will be the process now?

humble thunder
#

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

graceful canopy
#

So in my flow, I want everything to be done on backend side including creating payment intent and app will only scan card

humble thunder
#

what do you mean "scan card"? Like with a camera?

graceful canopy
#

Scan/Swipe card through M2 reader

humble thunder
#

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

hardy lakeBOT
graceful canopy
#

?

humble thunder
#

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

scarlet walrus
#

To clarify @graceful canopy are you trying to take a payment right now, or save a card for later payments?

graceful canopy
#

Hi @scarlet walrus

scarlet walrus
graceful canopy
#

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

scarlet walrus
graceful canopy
#

So according to above link, payment intent will be created on server side?

scarlet walrus
#

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

graceful canopy
#

transferDataDestination = ConnectAccountId(Where the remaining funds will be deposited?) after stripe and application fee deduction?

scarlet walrus
#

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.