第1步:
CustomerSession.initCustomerSession
第2步:
CustomerSession.getInstance()。retrieveCurrentCustomer
第3步:
我正在获取custumer(测试环境):{“ hasMore”:false,“ id”:“ cus_I4xevY1VmbpCGL”,“ sources”:[],“ totalCount”:0,“ url”:“ / v1 / customers / cus_I4xevY1VmbpCGL / sources“}
但是来源是空的,尽管在条形仪表板中我可以看到已保存付款方式(卡)。
答案 0 :(得分:1)
CustomerSession.getInstance().getPaymentMethods(PaymentMethod.Type.Card, new CustomerSession.PaymentMethodsRetrievalListener() {
@Override
public void onPaymentMethodsRetrieved(@NonNull List<PaymentMethod> paymentMethods) {
Log.d("testcustumer-size", paymentMethods.size()+" ");
if (paymentMethods.size() > 0) {
for (PaymentMethod method : paymentMethods) {
Log.d("testcustumer", method.id);
Log.d("testcustumer", method.card.last4);
Log.d("testcustumer", method.card.expiryMonth + "/" + method.card.expiryYear);
}
adapter = new CardsAdapter(paymentMethods);
cardsRV.setAdapter(adapter);
((CardsAdapter) adapter).setOnItemClickListener((position, v) -> {
// paymentIntent(paymentMethods.get(position).card,paymentIntentClientSecret);
stripe.confirmPayment(SavedCardsActivity.this,
ConfirmPaymentIntentParams.createWithPaymentMethodId(
paymentMethods.get(position).id,
paymentIntentClientSecret,
null
)
);
});
}
}
@Override
public void onError(int errorCode, @NonNull String errorMessage, @Nullable StripeError stripeError) {
}
});