英文:
Android Stripe payment sheet callback not called
问题
我在两个项目中按照这些说明进行了操作。代码完全相同。在一个项目中,一切正常,支付、后端的webhook调用,以及new PaymentSheet(this, new PaymentSheetResultCallback() {...}
中的回调都能正常运行。但另一个项目中,一切都正常,除了原生代码的回调,即PaymentSheetResultCallback()
。
我尝试在另一个项目中使用相同的ephemeralKey
和publishableKey
,来自于在另一个正常工作的项目中的那些,回调确实被调用。
我完全不知道区别在哪里。不知道从哪里开始寻找。
我尝试将逻辑移到另一个Activity中,因为我认为该Activity因某种原因可能会有问题...但没有成功。我唯一的猜测是,由于某种原因,当SDK从其Sheet视图返回时,它的回调没有被触发,也没有将数据传递给回调函数。但我不知道如何检查和修复。还有其他想法吗?
这是我的具体实现:
mPaymentSheet = new PaymentSheet(this, new PaymentSheetResultCallback() {
@Override
public void onPaymentSheetResult(@NonNull PaymentSheetResult paymentSheetResult) {
/** 这从未被调用! */
System.out.println("BUBU :: STRIPE :: huh?! :: " + paymentSheetResult);
if (paymentSheetResult instanceof PaymentSheetResult.Canceled) {
System.out.println("BUBU :: STRIPE :: canceled");
} else if (paymentSheetResult instanceof PaymentSheetResult.Failed) {
System.out.println("BUBU :: STRIPE :: error " + ((PaymentSheetResult.Failed) paymentSheetResult).getError().getMessage());
} else if (paymentSheetResult instanceof PaymentSheetResult.Completed) {
System.out.println("BUBU :: STRIPE :: WOOOOT !!!!");
}
}
});
和
PaymentConfiguration.init(APaymentSummary.this,
resp.getPublishableKey()
);
PaymentSheet.Address address = new PaymentSheet.Address(
null,
HUser.instance().getUserCountry(),
null, null, null, null
);
PaymentSheet.BillingDetails.Builder billingDetails =
new PaymentSheet.BillingDetails.Builder().address(address);
PaymentSheet.CustomerConfiguration customerConfiguration = new PaymentSheet.CustomerConfiguration(
resp.getCustomer(),
resp.getEphemeralKey()
);
PaymentSheet.GooglePayConfiguration googlePayConfiguration = new PaymentSheet.GooglePayConfiguration(
PaymentSheet.GooglePayConfiguration.Environment.Test,
HUser.instance().getUserCountry(),
getTopupHolder().getSelectedTopup().getTotalValueCurrencyCode()
);
mPaymentSheet.presentWithPaymentIntent(
resp.getPaymentIntent(),
new PaymentSheet.Configuration(
"Sift",
customerConfiguration,
googlePayConfiguration,
null,
billingDetails.build()
)
);
在后端webhook中支付已经成功,但在我的端上没有触发任何东西。
帮帮忙?
编辑
Stripe SDK中也没有任何日志...
英文:
I followed these instructions in 2 projects. Exact same code in both. In one project, everything works, the payment, the webhook call on the back-end, the callback in the new PaymentSheet(this, new PaymentSheetResultCallback() {...}
. On the other project, on the other hand, everything works, EXCEPT the callback of the native code, the PaymentSheetResultCallback()
.
I tried using the same ephemeralKey
and publishableKey
, etc from the project that doesn't work in the one that does work, and the callback is indeed called.
I have absolutely no idea what the difference is. No clue where to start looking to be frank.
I tried moving the logic in another Activity, as I thought that activity is a "strange" one for some reason ... didn't work. My single guess is for some reason the SDKs callback when it comes back from their Sheet view, is not triggered and it doesn't pass the data to the callback. But I have no idea how to check and fix that. Any other ideas ?!
Here's my implementation for clarity:
mPaymentSheet = new PaymentSheet(this, new PaymentSheetResultCallback() {
@Override
public void onPaymentSheetResult(@NonNull PaymentSheetResult paymentSheetResult) {
/** THIS IS NEVER CALLED ! */
System.out.println("BUBU :: STRIPE :: huh?! :: " + paymentSheetResult);
if (paymentSheetResult instanceof PaymentSheetResult.Canceled) {
System.out.println("BUBU :: STRIPE :: canceled");
} else if (paymentSheetResult instanceof PaymentSheetResult.Failed) {
System.out.println("BUBU :: STRIPE :: error " + ((PaymentSheetResult.Failed) paymentSheetResult).getError().getMessage());
} else if (paymentSheetResult instanceof PaymentSheetResult.Completed) {
System.out.println("BUBU :: STRIPE :: WOOOOT !!!!");
}
}
});
And
PaymentConfiguration.init(APaymentSummary.this,
resp.getPublishableKey()
);
PaymentSheet.Address address = new PaymentSheet.Address(
null,
HUser.instance().getUserCountry(),
null, null, null, null
);
PaymentSheet.BillingDetails.Builder billingDetails =
new PaymentSheet.BillingDetails.Builder().address(address);
PaymentSheet.CustomerConfiguration customerConfiguration = new PaymentSheet.CustomerConfiguration(
resp.getCustomer(),
resp.getEphemeralKey()
);
PaymentSheet.GooglePayConfiguration googlePayConfiguration = new PaymentSheet.GooglePayConfiguration(
PaymentSheet.GooglePayConfiguration.Environment.Test,
HUser.instance().getUserCountry(),
getTopupHolder().getSelectedTopup().getTotalValueCurrencyCode()
);
mPaymentSheet.presentWithPaymentIntent(
resp.getPaymentIntent(),
new PaymentSheet.Configuration(
"Sift",
customerConfiguration,
googlePayConfiguration,
null,
billingDetails.build()
)
);
Payment goes through ok in the back-end webhook, but nothing is triggered on my end.
Help ?!
EDIT
There aren't ANY logs from the Stripe SDK either ...
答案1
得分: 1
如此简单的修复...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); <--- 我从未调用这个!因此,从其表格活动中传递的Intent数据从未传递到SDK,以让它处理
/*...*/
}
英文:
Such a simple fix ....
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); <--- I was never calling this ! So it was never reaching the SDK to let it handle the Intent data coming from their Sheet Activity
/*...*/
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论