如何在android中更新条带默认设置客户默认源

如何在android中更新条带默认设置客户默认源,android,stripe-payments,Android,Stripe Payments,我目前正在使用stripe'com.stripe:stripe android:15.0.1'并调用presentPaymentMethodSelection来显示支付活动流。我正在使用订阅服务,因此我只需要显示卡、设置默认卡和添加新卡。我认为android stripe仍然没有像ios那样的onClick stripe默认源代码更新。所以我使用setCustomerDefaultSource来解决这个问题 问题 1:获取默认源=null 2:无法更新卡=收到“无此类来源:'pm********

我目前正在使用stripe'com.stripe:stripe android:15.0.1'并调用presentPaymentMethodSelection来显示支付活动流。我正在使用订阅服务,因此我只需要显示卡、设置默认卡和添加新卡。我认为android stripe仍然没有像ios那样的onClick stripe默认源代码更新。所以我使用setCustomerDefaultSource来解决这个问题

问题 1:获取默认源=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*********************”


Stripe的移动SDK组件,如您正在使用的PaymentSession/CustomerSession,现在默认为创建PaymentMethod对象(例如,在v9.1.0移动到PaymentMethod对象之后的Stripe Android)

PaymentMethod对象与传统的令牌/源/卡对象有些不同,因为它们仍然可以附加到客户,但不会自动具有“默认”概念

现在,您正在将客户上的
source
字段设置为PaymentMethod对象,该对象不受支持(
source
是传统字段,因此它仅支持令牌或源对象)

相反,您希望在CustomerSession[0]上使用
attachPaymentMethod()
函数将PaymentMethod附加到客户

然后,在服务器端,当您创建订阅时,您还将传递
default\u payment\u method:pm\u 123
以指定要在[1]上创建订阅的附加PaymentMethod

[0]


[1]

谢谢。因此,在CustomerSession.attachPaymentMethod中,当默认的付款方法(pm_***)传递给i时,会返回我的付款方法。那么现在您想让我生成令牌并对服务器进行api调用,并让服务器将特定的卡设为默认值?正确,您可以通过CustomerSession/PaymentSession将PaymentMethod附加到客户。但它并没有被确定为“用于发票和订阅的默认付款方式”。您必须通过服务器端调用来指定客户的
发票设置。默认付款方法
谢谢@hmunoz,我联系了stripe支持。他们提出了同样的建议。
     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) {

    }
}