Android stripe存储卡,无需使用CardInputWidget
我的项目需要保存用户卡,为此我使用了Stripe, 根据stripe的官方文档,我必须使用其预构建的 现在,我有一些设计要求,即使在改变了它的主题或样式之后,也与这个小部件不匹配 因此,我正在寻找任何其他方法来使用简单的edittext保存条带卡,或者创建条带的自定义卡对象 这是密码Android stripe存储卡,无需使用CardInputWidget,android,stripe-payments,payment-gateway,Android,Stripe Payments,Payment Gateway,我的项目需要保存用户卡,为此我使用了Stripe, 根据stripe的官方文档,我必须使用其预构建的 现在,我有一些设计要求,即使在改变了它的主题或样式之后,也与这个小部件不匹配 因此,我正在寻找任何其他方法来使用简单的edittext保存条带卡,或者创建条带的自定义卡对象 这是密码 implementation 'com.stripe:stripe-android:14.5.0' 片段代码 stripe = new Stripe(getActivity(), myApp.getS
implementation 'com.stripe:stripe-android:14.5.0'
片段代码
stripe = new Stripe(getActivity(), myApp.getStripePublishKey());
PaymentMethodCreateParams params = card_multiline_widget.getPaymentMethodCreateParams();
if (params == null) {
ToastUtils.makeToast(getActivity(), "Invalid Details");
return;
}
stripe.createPaymentMethod(params, new ApiResultCallback<PaymentMethod>() {
@Override
public void onSuccess(@NonNull PaymentMethod result) {
if (getActivity() != null) {
getActivity().runOnUiThread(() -> progressDialog.dismiss());
}
paymentMethodId = result.id;
LogUtils.e(paymentMethodId);
saveCard();
// Send paymentMethodId to your server for the next steps
}
@Override
public void onError(@NonNull Exception e) {
// Display the error to the user
e.printStackTrace();
LogUtils.e(e.getMessage());
if (getActivity() != null) {
getActivity().runOnUiThread(() -> progressDialog.dismiss());
}
}
});
stripe=newstripe(getActivity(),myApp.getStripePublishKey());
PaymentMethodCreateParams params=card_multiline_小部件。getPaymentMethodCreateParams();
if(params==null){
makeToast(getActivity(),“无效的详细信息”);
返回;
}
stripe.createPaymentMethod(参数,新的ApiResultCallback(){
@凌驾
成功时公共无效(@NonNull PaymentMethod result){
如果(getActivity()!=null){
getActivity();
}
paymentMethodId=result.id;
LogUtils.e(paymentMethodId);
存储卡();
//将paymentMethodId发送到服务器以进行下一步
}
@凌驾
public void onError(@NonNull异常e){
//向用户显示错误
e、 printStackTrace();
LogUtils.e(e.getMessage());
如果(getActivity()!=null){
getActivity();
}
}
});
如果您使用自己的输入来收集一些卡输入,那么您只需使用PaymentMethodCreateParams.card.Builder:的各个字段手动创建PaymentMethodCreateParams,其余的代码都是相同的(使用params对象来创建PaymentMethod),我搜索了很长时间,在文档中看不到这个生成器方法@karllekko谢谢你。如果你使用自己的输入来收集一些卡片输入,那么你只需要手动创建PaymentMethodCreateParams,使用PaymentMethodCreateParams.card.Builder:的各个字段,其余的代码都是一样的(使用params对象来创建PaymentMethod),我搜索了很长时间,在文档中看不到这个生成器方法@谢谢你,伙计。