[英]Paypal Native Checkout Button keeps loading and then disappears on Android
我正在使用新的 Native Checkout SDK for Android 和 Java,我一直在關注文檔中的每一步,但這種情況一直在發生,我不知道
這是我的公共 class 應用程序擴展應用程序
CheckoutConfig checkoutConfig = new CheckoutConfig(
this,
ID,
Environment.SANDBOX,
String.format("%s://paypalpay", BuildConfig.APPLICATION_ID),
CurrencyCode.MXN,
UserAction.PAY_NOW,
new SettingsConfig(
true,
false
)
);
在我實現按鈕的片段上
payPalButton.setup(
createOrderActions -> {
ArrayList purchaseUnits = new ArrayList<>();
purchaseUnits.add(
new PurchaseUnit.Builder()
.amount(
new Amount.Builder()
.currencyCode(CurrencyCode.MXN)
.value(amount)
.build()
)
.build()
);
Order order = new Order(
OrderIntent.CAPTURE,
new AppContext.Builder()
.userAction(UserAction.PAY_NOW)
.build(),
purchaseUnits
);
createOrderActions.create(order, (CreateOrderActions.OnOrderCreated) null);
},
approval -> approval.getOrderActions().capture(result -> {
Log.i("CaptureOrder", String.format("CaptureOrderResult: %s", result));
}),
() -> {
Log.d("OnCancel", "Buyer cancelled the PayPal experience.");
Snackbar snackbar = Snackbar.make(requireView(), R.string.la_donacion_no_fue_realizada, Snackbar.LENGTH_LONG);
snackbar.getView().setBackgroundColor(ContextCompat.getColor(requireContext(),android.R.color.holo_red_light));
snackbar.show();
},
errorInfo -> {
Log.d("OnError", String.format("Error: %s", errorInfo));
Snackbar snackbar = Snackbar.make(requireView(), R.string.la_donacion_no_fue_realizada, Snackbar.LENGTH_LONG);
snackbar.getView().setBackgroundColor(ContextCompat.getColor(requireContext(),android.R.color.holo_red_light));
snackbar.show();
}
);
剛剛通過在擴展應用程序文件中添加這一行來解決它:
PayPalCheckout.setConfig(checkoutConfig);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.