Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collectPaymentMethod works only once #241

Closed
hssrrw opened this issue Jun 16, 2022 · 1 comment
Closed

collectPaymentMethod works only once #241

hssrrw opened this issue Jun 16, 2022 · 1 comment
Assignees
Labels
bug bug report

Comments

@hssrrw
Copy link

hssrrw commented Jun 16, 2022

Summary

When I scan a card using collectPaymentMethod() first time it works fine. When then I call collectPaymentMethod() to discard the first card data and scan another one, I get this error:

CollectPaymentMethod was canceled by the user

Could anyone help me understand the cause of the issue? Thank you in advance!

Here is the function used to call collectPaymentMethod():

Code to reproduce

private var collectPaymentCancelable: Cancelable? = null
private var intentInProcess: PaymentIntent? = null

fun scanCard(intentId: String, promise: Promise) {
  if (!Terminal.isInitialized()) {
    promise.reject("empty_token", "You must provide connection token first")
    return
  }

  if (Terminal.getInstance().connectionStatus != ConnectionStatus.CONNECTED) {
    promise.reject("reader_disconnected", "You must connect to a reader first")
    return
  }

  Terminal.getInstance().retrievePaymentIntent(intentId, object : PaymentIntentCallback {
    override fun onSuccess(paymentIntent: PaymentIntent) {
      collectPaymentCancelable = Terminal.getInstance()
        .collectPaymentMethod(paymentIntent, object : PaymentIntentCallback {
          override fun onSuccess(paymentIntent: PaymentIntent) {
            collectPaymentCancelable = null
            intentInProcess = paymentIntent
            promise.resolve(serializeIntent(paymentIntent))
          }

          override fun onFailure(e: TerminalException) {
            collectPaymentCancelable = null
            promise.reject("collect_failed", e.errorMessage)
          }
        })
    }

    override fun onFailure(e: TerminalException) {
      promise.reject("retrieve_fail", e.errorMessage)
    }
  })
}

Android version

Android 12

Impacted devices (Android devices or readers)

Phone: Samsung Galaxy A13
Terminal: BBPOS Chipper X2

SDK version

com.stripe:stripeterminal:2.10.0
buildToolsVersion = "31.0.0"
minSdkVersion = 26
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = "21.4.7075529"
androidXAnnotation = "1.1.0"
androidXBrowser = "1.0.0"
kotlinVersion = "1.5.20"

Other information

Here is the relevant log:

14367-14367/com.myexampleapp I/ViewRootImpl@dba2088[MainActivity]: ViewPostIme pointer 1
14367-14491/com.myexampleapp D/StripeTerminal: class=Terminal message=retrievePaymentIntent
14367-14860/com.myexampleapp D/StripeTerminal: class=ApiClient message=retrievePaymentIntent
14367-14860/com.myexampleapp I/StripeTerminal: class=RestClient message="url=https://api.stripe.com/v1/payment_intents/pi_3LAdhqPYpZwoQYFv0DyRDuLi request={}"
921-1156/? I/SemWifiEleStateTracker: Ele Parameters BD : 2 2 3 2 1 2 MD : -90 -90 -90 -90 -90 -90 WD : -53 -54 -54 -54 -55 -54 GC : false false false false false false SC : false false false false false false SH : false false false false false false TB : false false false false false false
921-1168/? D/NetdEventListenerService: DNS Requested by : 202, 10257, 0
639-639/? I/SurfaceFlinger: SFWD update time=83863446127245
921-1032/? D/ActivityManager: Received BROADCAST intent 0x3d7cb44 Key{broadcastIntent pkg=com.google.android.gms/com.google.android.gms.location_base intent=act=com.google.android.location.ALARM_WAKEUP_LOCATOR flags=0x4000000 u=0} requestCode=0 sent=0 from uid 1000
13969-14063/? W/SystemServiceRegistry: No service published for: wifirtt
382-14849/? I/keystore2: keystore2::watchdog: Watchdog thread idle -> terminating. Have a great day.
14367-14860/com.myexampleapp I/RestResponse: REST response with code 200 received
14367-14860/com.myexampleapp I/RestResponse: request-id: req_vQmbwEBWeQTdyN
14367-14860/com.myexampleapp I/StripeTerminal: class=RestClient message="url=https://api.stripe.com/v1/payment_intents/pi_3LAdhqPYpZwoQYFv0DyRDuLi status=OK headers={access-control-allow-credentials=true, access-control-allow-methods=GET, POST, HEAD, OPTIONS, DELETE, access-control-allow-origin=*, access-control-expose-headers=Request-Id, Stripe-Manage-Version, X-Stripe-External-Auth-Required, X-Stripe-Privileged-Session-Required, access-control-max-age=300, cache-control=no-cache, no-store, content-length=1830, content-type=application/json, date=Thu, 16 Jun 2022 06:48:34 GMT, idempotency-key=..., stripe-version=2019-02-19} response={"amount":"4321","amountCapturable":"0","amountReceived":"0","applicationFeeAmount":"171","captureMethod":"manual","charges":{"hasMore":false,"totalCount":0},"clientSecret":"...","created":"1655228350","currency":"usd","id":"...","livemode":false,"metadata":{"ClientId":"2","IdempotencyKey":"...","PaymentTransactionId":"...","ReferenceNumber":"...","PaymentNumber":"57","ClientApplicationId":"1","Md":"..."},"status":"requires_payment_method"}"
14367-14860/com.myexampleapp D/StripeTerminal: class=Terminal message=collectPaymentMethod
14367-14860/com.myexampleapp I/StripeTerminal: class=TerminalStatusManager message=TerminalStatusManager waitForInput.
14367-14860/com.myexampleapp D/StripeTerminal: class=BbposAdapterLegacy message=collectPaymentMethod amount="Amount(value=4321, currencyCode=usd)" type=com.stripe.stripeterminal.internal.common.PaymentMethodCollectionType$Sale@c92798a
14367-14860/com.myexampleapp I/StripeTerminal: class=TransactionManager message=endTransaction
14367-14860/com.myexampleapp I/StripeTerminal: class=TransactionStateMachine message="onStateChanged: COLLECT_PAYMENT_PRESENT -> CANCELLED: null"
14367-14860/com.myexampleapp I/CombinedKernelInterface: cancel
14367-14860/com.myexampleapp I/BbposReaderController: disableDevice NO_CARD
14367-14860/com.myexampleapp D/StripeTerminal: class=BbposDeviceControllerImpl message=cancelCheckCard
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14860/com.myexampleapp I/StripeTerminal: class=TransactionStateMachine message="onStateChanged: CANCELLED -> EMPTY: Transaction cancelled"
14367-14860/com.myexampleapp I/StripeTerminal: class=BbposAdapterLegacy message="Not starting the tipping flow because device doesn't support on reader tipping"
14367-14367/com.myexampleapp D/BbposControllerListener: {function: cancelCheckCard,date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: FUNCTION,message: }
14367-14860/com.myexampleapp I/StripeTerminal: class=TransactionManager message=startPaymentMethod
14367-14860/com.myexampleapp I/StripeTerminal: class=TransactionStateMachine message="onStateChanged: EMPTY -> COLLECT: Payment method requested"
14367-14860/com.myexampleapp I/BbposReaderController: enableDevice
14367-14860/com.myexampleapp D/StripeTerminal: class=BbposDeviceControllerImpl message=startEmv
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14367/com.myexampleapp D/BbposControllerListener: {function: startEmv,date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: FUNCTION,message: data : {amount=50.01, checkCardMode=SWIPE_OR_INSERT_OR_TAP, checkCardTimeout=3600, currencyCharacters={DOLLAR}, currencyCode=840, currencyExponent=2, disableQuickChip=false, onlineProcessTimeout=30, quickChipOption=1, selectAccountTypeTimeout=90, selectApplicationTimeout=90, terminalTime=220616104835, transactionType=GOODS}}
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic() - address=2F2687_1, status=0
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic : isCongested == false
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14367/com.myexampleapp D/BbposControllerListener: {date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: CALLBACK,message: isSuccess : true,callback: onReturnCancelCheckCardResult}
14367-14367/com.myexampleapp I/StripeTerminal: class=BbposTransactionListener message="onReturnCancelCheckCardResult true"
14367-14367/com.myexampleapp I/StripeTerminal: class=TransactionManager message=endTransaction
14367-14367/com.myexampleapp I/StripeTerminal: class=TransactionStateMachine message="onStateChanged: COLLECT -> CANCELLED: null"
14367-14367/com.myexampleapp I/CombinedKernelInterface: cancel
14367-14367/com.myexampleapp I/BbposReaderController: disableDevice NO_CARD
14367-14367/com.myexampleapp D/StripeTerminal: class=BbposDeviceControllerImpl message=cancelCheckCard
14367-14367/com.myexampleapp I/StripeTerminal: class=TransactionStateMachine message="onStateChanged: CANCELLED -> EMPTY: Transaction cancelled"
14367-14367/com.myexampleapp I/CombinedKernelInterface: reset
14367-14860/com.myexampleapp I/StripeTerminal: class=TerminalStatusManager message=TerminalStatusManager endPaymentFlow.
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14860/com.myexampleapp D/StripeTerminal: class=ProxyTerminalListener message=onPaymentStatusChange(READY)
14367-14367/com.myexampleapp D/BbposControllerListener: {function: cancelCheckCard,date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: FUNCTION,message: }
14367-14860/com.myexampleapp E/StripeTerminal: CollectPaymentMethod was canceled by the user
    com.stripe.stripeterminal.external.models.TerminalException: CollectPaymentMethod was canceled by the user
        at com.stripe.stripeterminal.adapter.BbposAdapterLegacy$CardReadOperation.completeCancel$core_publish(BbposAdapterLegacy.kt:757)
        at com.stripe.stripeterminal.adapter.BbposAdapterLegacy.register$lambda-29(BbposAdapterLegacy.kt:601)
        at com.stripe.stripeterminal.adapter.BbposAdapterLegacy.$r8$lambda$jYH_zPEjpJjpwr4DmrZUjLhtSbE(Unknown Source:0)
        at com.stripe.stripeterminal.adapter.BbposAdapterLegacy$$ExternalSyntheticLambda25.accept(Unknown Source:4)
        at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
        at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58)
        at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:308)
        at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:228)
        at io.reactivex.subjects.SerializedSubject.onNext(SerializedSubject.java:104)
        at com.stripe.core.hardware.reactive.status.ReactiveReaderStatusListener.handleCancellation(ReactiveReaderStatusListener.kt:73)
        at com.stripe.core.hardware.status.ReaderStatusListener$DefaultImpls.handleCancellation$default(ReaderStatusListener.kt:15)
        at com.stripe.core.bbpos.BbposTransactionListener.onReturnCancelCheckCardResult(BbposTransactionListener.kt:89)
        at com.stripe.bbpos.bbdevice.BBDeviceController.aaa004(SourceFile:17)
        at com.stripe.bbpos.bbdevice.BBDeviceController.$r8$lambda$HAZwkzCefG5buPYriXfnqa-_HR0(Unknown Source:0)
        at com.stripe.bbpos.bbdevice.BBDeviceController$$ExternalSyntheticLambda166.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8663)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic() - address=2F2687_1, status=0
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic : isCongested == false
14367-14490/com.myexampleapp I/ReactNativeJS: 'scan card error', { error: [Error: CollectPaymentMethod was canceled by the user] }
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic() - address=2F2687_1, status=0
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic : isCongested == false
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic() - address=2F2687_1, status=0
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic : isCongested == false
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14367/com.myexampleapp D/BbposControllerListener: {date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: CALLBACK,message: displayText : PRESENT_CARD, displayTextLanguage : en,callback: onRequestDisplayText}
14367-14367/com.myexampleapp I/StripeTerminal: class=BbposTransactionListener message="onRequestDisplayText PRESENT_CARD"
639-639/? I/SurfaceFlinger: SFWD update time=83864446293744
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic() - address=2F2687_1, status=0
1213-1370/? D/BtGatt.GattService: onWriteCharacteristic : isCongested == false
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14367/com.myexampleapp D/BbposControllerListener: {date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: CALLBACK,message: checkCardMode : SWIPE_OR_INSERT_OR_TAP,callback: onWaitingForCard}
14367-14367/com.myexampleapp I/StripeTerminal: class=BbposTransactionListener message="onWaitingForCard SWIPE_OR_INSERT_OR_TAP"
14367-14367/com.myexampleapp I/StripeTerminal: class=TerminalStatusManager message=TerminalStatusManager "requestReaderInput Swipe / Insert / Tap."
14367-14367/com.myexampleapp I/StripeTerminal: class=ProxyReaderListener message="onRequestReaderInput(Swipe / Insert / Tap)"
14367-14367/com.myexampleapp I/CombinedKernelInterface: reset
14367-14367/com.myexampleapp I/BbposControllerListener: onReturnDebugLog
14367-14367/com.myexampleapp D/BbposControllerListener: {date: Thu Jun 16 10:48:35 GMT+04:00 2022,type: CALLBACK,message: isSuccess : true,callback: onReturnCancelCheckCardResult}
14367-14367/com.myexampleapp I/StripeTerminal: class=BbposTransactionListener message="onReturnCancelCheckCardResult true"
14367-14367/com.myexampleapp I/StripeTerminal: class=TransactionManager message=endTransaction
14367-14367/com.myexampleapp I/CombinedKernelInterface: reset
@rv-stripe rv-stripe self-assigned this Aug 8, 2022
@rv-stripe rv-stripe added the bug bug report label Sep 20, 2022
@rv-stripe
Copy link
Contributor

This should be resolved in the 2.14 release. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug report
Projects
None yet
Development

No branches or pull requests

2 participants