VivaPayments / API

Index of Viva Wallet open source projects on GitHub.
139 stars 162 forks source link

Card validation step in 'Create payment order' #1078

Closed LoggiaNG closed 4 years ago

LoggiaNG commented 5 years ago

Hello, we have implemented the following procedure, for our food delivery application.

  1. User wants to order food from a store, so he enters his card information and our app sends it to the server
  2. We follow the steps to create a payment order (/api/orders) with IsPreAuth=true
  3. If the payment order is successful, we inform the store of the user's order. 4.1. When the store confirms the user's order, we call /api/transactions to complete the payment 4.2 If the store for some reason rejects the user's order, we cancel the payment order

The problem is that on step 2, we thought that we would get feedback if the card data is incorrect (or if the card has sufficient funds), before sending the delivery order to the store. But we see that this is not the case. Are we missing something here?

Ideally we would like to inform the user of any mistakes in the card input form or the card itself on step 2. As it is now, the user sees his card being "accepted", his order being processed, but then rejected because of card error. We wish to make every step clear to the client, and the store.

Thank you.

odysseas12 commented 5 years ago

I know the documentation says otherwise. But the way Im doing preauthorizations for the past 2 years is the following.

  1. In https://demo.vivapayments.com/selfcare/en/security/apiaccess check "Allow recurring payments"
  2. Create a normal order as usual (/api/orders).
  3. Create a transaction (/api/transactions) and add to the normal request IsPreAuth=true and PaymentMethodId=1

To capture a payment you send a request to '/api/transactions/{id}' with form data 'Installments' => 0, 'Amount' => {amount}

To release a payment you send a request to '/api/transactions/{id}?amount={amount}'

Hope this help.

@matthewrgourd Is the way we do preauthorization going to change to what is now described in the docs ?

matthewrgourd commented 5 years ago

Hi @odysseas12 let me get back to you after I receive an answer from our dev team...

VrasidasP commented 5 years ago

What does PaymentMethodId=1 do? We can't find it in the documentation.

odysseas12 commented 5 years ago

@VrasidasP I dont know exactly PaymentMethodId=1 is but if not included the transaction is not an authorization but a card charge.

matthewrgourd commented 4 years ago

Hi there, feedback from our development team is that If you want to create a PreAuth transaction you must pass property IsPreAuth=true and PaymentMethod=1(PreauthCapture) on create transaction endpoint: https://developer.vivawallet.com/online-checkouts/native-checkout-v2/#step-5-make-the-actual-charge Hope this helps!