如何解决如何在Android中更新条带默认设置客户默认源
我当前正在使用条纹'com.stripe:stripe-android:15.0.1'并调用presentPaymentMethodSelection来呈现付款活动流。我使用的是订阅服务,因此我只需要显示卡,设置默认卡并添加新卡即可。我认为对于android条纹,仍然没有像iOS这样的onClick条纹默认源更新。因此,我正在使用setCustomerDefaultSource来解决此目的。
问题 1:获取default-source = null。
2:无法更新卡=收到“没有这样的来源:'pm _ *********************'”
卡点击时收到错误:
errorCode = 400
errorMessage = "No such source: 'pm_*********************'"
stripeError = {Stripe****}
charge = ""
code = "resource_missing"
declineCode = ""
message = "No such source: 'pm_*********************'"
param = "source"
type = "invalid_request_error"
shadow$_klass_ = {Cla***} "class com.stripe.android.StripeError"
shadow$_monitor_ = 0
这是卡的信息
0 = {PaymentMethod0}
billingDetails = {PaymentMethod$Billin}
card = {PaymentMethod$Car}
cardPresent = null
created = {Long@10}
customerId = "cus_**************er"
id = "pm_*********************"
ideal = null
liveMode = false
metadata = {HashMap@###} size = 0
type = "card"
shadow$_klass_ = {Class@$$$} "class com.stripe.android.model.PaymentMethod"
shadow$_monitor_ = 0
和以下功能的参数 paymentId:“ pm _ *********************”
mCustomerSessionN.setCustomerDefaultSource(paymentId,Source.SourceType.CARD,new CustomerSession.CustomerRetrievalListener() {
@Override
public void onCustomerRetrieved(@NonNull Customer customer) {
Log.d("","onCustomerRetrieved: " + customer);
Toast.makeText(getApplicationContext(),"Card is added ",Toast.LENGTH_SHORT).show();
}
@Override
public void onError(int errorCode,@NonNull String errorMessage,@Nullable StripeError stripeError) {
Log.d("","onCustomerRetrieved: " + errorMessage);
Toast.makeText(getApplicationContext(),errorMessage,Toast.LENGTH_SHORT).show();
}
});
} catch (Exception e) {
}
}
解决方法
Stripe的移动SDK组件(例如您正在使用的PaymentSession / CustomerSession)现在默认创建了PaymentMethod对象(例如,将v9.1.0之后的Stripe Android移至PaymentMethod对象)。
PaymentMethod对象与旧版Token / Source / Card对象有些不同,因为它们仍然可以附加到Customer,但是它们不会自动具有“默认”概念。
现在,您正在将Customer上的source
字段设置为PaymentMethod对象,不支持该字段(attachPaymentMethod()
是旧字段,因此它仅支持Token或Source对象)
您要使用的是在CustomerSession [0]上使用default_payment_method: pm_123
函数,将PaymentMethod附加到客户。
然后,在服务器端,当您创建订阅时,您还将传递 internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module 'discord.js)'
Require stack:
- C:\Users\Madison\Desktop\BeepBoop\index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Madison\Desktop\BeepBoop\index.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
{
code: 'MODULE_NOT_FOUND',requireStack: [ 'C:\\Users\\Madison\\Desktop\\BeepBoop\\index.js' ]
来指定要在[1]上创建订阅的附加PaymentMethod中的哪个。
[1] https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。