paypal / paypal-here-sdk-android-distribution

Add credit card (swipe & key-in) capabilities to your Android app
Other
84 stars 95 forks source link

Process Payment without SDK UI #111

Closed cdewberry closed 6 years ago

cdewberry commented 6 years ago

In my android app I am attempting to process payments using the non-UI processPayment() methods with the triangle magstripe only dongle.

I have tried calling: PayPalHereSDK.getTransactionManager().beginPayment(amount, transactionController); followed by: processPayment(TransactionManager.PaymentType paymentType, TransactionController customController, DefaultResponseHandler<TransactionManager.PaymentResponse,PPError> response); To allow cancelling the card swipe, but my app crashes with: NullPointerException: Attempt to invoke interface method 'org.json.JSONObject com.paypal.merchant.sdk.domain.SecureCreditCard.getSecureData()' on a null object reference

What is the correct way to call processPayment to allow for cancelling a card swipe?

ppmtscory commented 6 years ago

My apologies but I'm not sure I understand the request. Once you call processPayment and it's complete, then you'll need to do a refund. Otherwise, if you've already called beginPayment but want to start the process over, there should be a cancelPayment call that you can make.

cdewberry commented 6 years ago

Thanks for the response, Cory!

My issue is that once processPaymentWithSDKUI is called and the 'Please swipe card' dialog is displayed, there is no way to cancel. So, if the payee can't find their card or has some issue, there is currently no way to cancel from that screen. Back button does not work. So, I thought I would be able to use the processPayment call without the UI, but I must not be using it correctly. What calls need to be made and in what order to process a payment without the SDKUI?

Thanks so much for your help!

Caroline Dewberry Software Engineer Book Systems, Inc. (256)533-9746

On Wed, Dec 13, 2017 at 5:13 PM, Cory notifications@github.com wrote:

My apologies but I'm not sure I understand the request. Once you call processPayment and it's complete, then you'll need to do a refund. Otherwise, if you've already called beginPayment but want to start the process over, there should be a cancelPayment call that you can make.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paypal/paypal-here-sdk-android-distribution/issues/111#issuecomment-351555632, or mute the thread https://github.com/notifications/unsubscribe-auth/ASZbbwOgxRirpOASW6d1BZW7Gf45zdmBks5tAFoggaJpZM4RBIEN .

ppmtscory commented 6 years ago

I'm assuming you are using the EMV reader, in which case, you should be able to press the red X button on the bottom left of the reader to cancel the payment at that point.

cdewberry commented 6 years ago

No, I'm using the MagneticCardReader. What I would really like is a timeout. I know there is a onContactlessReaderTimeout - I'd like one for the MagneticCardReader. Then I could go back to the ChargeActivity and allow canceling.

Caroline Dewberry Software Engineer Book Systems, Inc. (256)533-9746

On Thu, Dec 14, 2017 at 11:38 AM, Cory notifications@github.com wrote:

I'm assuming you are using the EMV reader, in which case, you should be able to press the red X button on the bottom left of the reader to cancel the payment at that point.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/paypal/paypal-here-sdk-android-distribution/issues/111#issuecomment-351782980, or mute the thread https://github.com/notifications/unsubscribe-auth/ASZbb3UxAX-tvZ9OvHpNqeYI457fS1-wks5tAVz8gaJpZM4RBIEN .

ppmtscory commented 6 years ago

Ah, ok, I understand. You should be able to control this on your side then without the SDK UI. As long as you have your listeners set up, after you call beginPayment the SDK will start monitoring the card reader. Once you get the callback for the detected swipe, then you would call processPayment to process that transaction. I believe that listener event is onCardReadSuccess.