如何在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中的哪个。

[0] https://stripe.dev/stripe-android/stripe/com.stripe.android/-customer-session/attach-payment-method.html

[1] https://stripe.com/docs/api/subscriptions/object#subscription_object-default_payment_method