stripe / stripe-android

Stripe Android SDK
https://stripe.com/docs/mobile/android
MIT License
1.29k stars 645 forks source link

[BUG] Pay anr with Alipay. #4734

Closed 22106331 closed 2 years ago

22106331 commented 2 years ago

Summary

Pay anr with Alipay.

"main" prio=5 tid=1 TimedWaiting
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x71bc16a8 self=0x711339a7b0
  | sysTid=6331 nice=-10 cgrp=default sched=0/0 handle=0x7239bd14f8
  | state=S schedstat=( 7925057528 130398465 8286 ) utm=719 stm=72 core=6 HZ=100
  | stack=0x7fe7795000-0x7fe7797000 stackSize=8192KB
  | held mutexes=
  at java.lang.Object.wait(Native method)
  - waiting on <0x093077d6> (a java.lang.Class<com.alipay.android.app.IAlixPay>)
  at java.lang.Object.wait(Object.java:442)
  at f0.e.a(SourceFile:18)
  - locked <0x093077d6> (a java.lang.Class<com.alipay.android.app.IAlixPay>)
  at f0.e.g(SourceFile:15)
  at f0.e.h(SourceFile:30)
  at com.alipay.sdk.app.PayTask.h(SourceFile:10)
  at com.alipay.sdk.app.PayTask.g(SourceFile:25)
  - locked <0x03aa6a57> (a com.alipay.sdk.app.PayTask)
  at com.alipay.sdk.app.PayTask.payV2(SourceFile:2)
  - locked <0x03aa6a57> (a com.alipay.sdk.app.PayTask)
  at com.fysl.user.takeout.order.PaymentController$requestStripAliPayment$2$2.i(SourceFile:1)
  at com.fysl.user.takeout.order.PaymentController$requestStripAliPayment$2$2.h(SourceFile:-1)
  at com.fysl.user.takeout.order.c0.onAuthenticationRequest(SourceFile:-1)
  at com.stripe.android.networking.DefaultAlipayRepository.authenticate(SourceFile:7)
  at com.stripe.android.StripePaymentController.authenticateAlipay(SourceFile:4)
  at com.stripe.android.StripePaymentController.confirmAndAuthenticateAlipay(SourceFile:6)
  at com.stripe.android.StripePaymentController$confirmAndAuthenticateAlipay$1.invokeSuspend(SourceFile:-1)
  at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:4)

Code to reproduce

activity.lifecycleScope.launch {
    kotlin.runCatching {
        stripe.confirmAlipayPayment(ConfirmPaymentIntentParams.createAlipay(clientSecret),
                { data -> PayTask(activity).payV2(data, true) })
    }.fold(onSuccess = {
        delegate?.paymentDidSuccess()
    }, onFailure = {
        delegate?.stopLoading()
        delegate?.paymentDidFail(it)
        LogUtils.d("PaymentController", "requestPayment alipay fail ${it.localizedMessage}")
    })
}

Android version

android11

Impacted devices

Installation method

gradle

Dependency Versions

implementation 'com.stripe:stripe-android:19.3.0' implementation 'com.stripe:stripe-wechatpay:19.3.0'

For kotlin: ./gradlew :dependencies | grep kotlin

For stripe-android: ./gradlew :dependencies | grep com.android.tools.build

For Android Gradle Plugin: ./gradlew :dependencies | grep com.stripe:stripe-android

For Gradle version: ./gradlew -v -->

kotlin: stripe-android: Android Gradle Plugin: Gradle:

SDK classes

Video

Other information

jameswoo-stripe commented 2 years ago

Hi @22106331, thank you for reporting this issue. Can you please let us know which version of the Alipay SDK you are using? Also, are you able to update your code to reproduce? It seems like the callback parameter is missing.

I tested our example app with the following code and could not reproduce the issue:

lifecycleScope.launch {
    runCatching {
        stripe.confirmAlipayPayment(
            ConfirmPaymentIntentParams.createAlipay(clientSecret),
            { data -> PayTask(this@PaymentAuthActivity).payV2(data, true) },
            callback = object : ApiResultCallback<PaymentIntentResult> {
                override fun onSuccess(result: PaymentIntentResult) {
                    println("Success")
                }

                override fun onError(e: Exception) {
                    println("Error: $e")
                }
            }
        )
    }
}

I am using implementation(name:"alipaySdk-15.7.4-20200228192259", ext:"aar")

Also, are you running in test mode? Alipay does not support test mode payments.

22106331 commented 2 years ago

Hi @22106331, thank you for reporting this issue. Can you please let us know which version of the Alipay SDK you are using? Also, are you able to update your code to reproduce? It seems like the callback parameter is missing.

I tested our example app with the following code and could not reproduce the issue:

lifecycleScope.launch {
    runCatching {
        stripe.confirmAlipayPayment(
            ConfirmPaymentIntentParams.createAlipay(clientSecret),
            { data -> PayTask(this@PaymentAuthActivity).payV2(data, true) },
            callback = object : ApiResultCallback<PaymentIntentResult> {
                override fun onSuccess(result: PaymentIntentResult) {
                    println("Success")
                }

                override fun onError(e: Exception) {
                    println("Error: $e")
                }
            }
        )
    }
}

I am using implementation(name:"alipaySdk-15.7.4-20200228192259", ext:"aar")

Also, are you running in test mode? Alipay does not support test mode payments.

I am using implementation files('libs/alipaysdk-15.8.06.211122170115.aar') I am running in release mode.

jameswoo-stripe commented 2 years ago

I am using implementation files('libs/alipaysdk-15.8.06.211122170115.aar') I am running in release mode.

Hi @22106331, I mean that your Stripe dashboard account should be running in live mode:

Screen Shot 2022-03-21 at 10 50 18 PM

22106331 commented 2 years ago

I am using implementation files('libs/alipaysdk-15.8.06.211122170115.aar') I am running in release mode.

Hi @22106331, I mean that your Stripe dashboard account should be running in live mode:

Screen Shot 2022-03-21 at 10 50 18 PM Thanks, my problem is solved.