如何解决沙盒测试模式下 Android 中的 Paypal 支付网关集成问题
我已经在我的 Android 应用程序中启动了 Paypal 支付网关集成。但问题是——
在沙盒测试期间显示 Paypal 付款屏幕,但在填写详细信息(Paypal 登录凭据)后继续显示
404 - RESOURCE_NOT_FOUND。指定的资源不存在。
我遵循的步骤 -
1- 设置 PayPalConfiguration.ENVIRONMENT_SANDBox 模式。
2- 设置Client_ID
3- 设置货币美元
我也试过生产模式更改所有必需的设置,但在这种情况下得到了
429 - 多次命中问题。
我也花了一整天的时间和我的朋友解决这个问题,但没有成功。
1- Paypal 是限制沙盒测试模式还是仅在印度限制此服务?
2-解决此问题的方法是什么?
或 Paypal 删除沙盒测试服务,还是我需要实施 BrainTree SDK 以进行 Paypal 集成?
我的活动课程开始
公共类 MainActivity 扩展 AppCompatActivity { private static final String TAG = "paymentExample"; 私有静态最终字符串 CONfig_ENVIRONMENT = PayPalConfiguration.ENVIRONMENT_SANDBox; private static final String PAYMENT_TYPE = "USD"; private static final String CONfig_CLIENT_ID = "这是我的客户 ID 代码";
private static final int REQUEST_CODE_PAYMENT = 1;
private static PayPalConfiguration config = new PayPalConfiguration()
.environment(CONfig_ENVIRONMENT)
.clientId(CONfig_CLIENT_ID);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(this,PayPalService.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONfigURATION,config);
startService(intent);
}
public void onBuypressed(View pressed) {
PayPalPayment thingToBuy = getThingToBuy();
Intent intent = new Intent(MainActivity.this,PaymentActivity.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONfigURATION,config);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT,thingToBuy);
startActivityForResult(intent,REQUEST_CODE_PAYMENT);
}
private PayPalPayment getThingToBuy() {
return new PayPalPayment(new BigDecimal("0.1"),PAYMENT_TYPE,"eSIM",PayPalPayment.PAYMENT_INTENT_SALE);
}
@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode,resultCode,data);
Log.i(TAG,data.toString());
if (requestCode == REQUEST_CODE_PAYMENT) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm =
data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
Log.i(TAG,confirm.toJSONObject().toString(4));
Log.i(TAG,confirm.getPayment().toJSONObject().toString(4));
} catch (JSONException e) {
Log.e(TAG,"an extremely unlikely failure occurred: ",e);
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i(TAG,"The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i(
TAG,"An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
}
}
}
@Override
public void onDestroy() {
// Stop service when done
stopService(new Intent(this,PayPalService.class));
super.onDestroy();
}
} 活动课程结束
错误堆栈日志
E/paypal.sdk: request failure with http statusCode:404,exception:Not Found
2021-02-15 21:48:22.046 3106-3200/com.claytech.paypaldemoapplication E/paypal.sdk: Exception parsing server response
org.json.JSONException: End of input at character 0 of
at org.json.JSONTokener.SyntaxError(JSONTokener.java:460)
at org.json.JSONTokener.nextValue(JSONTokener.java:101)
at com.paypal.android.sdk.cw.m(UnkNown Source:7)
at com.paypal.android.sdk.fm.d(UnkNown Source:0)
at com.paypal.android.sdk.ci.a(UnkNown Source:21)
at com.paypal.android.sdk.cm.a(UnkNown Source:58)
at com.paypal.android.sdk.cq.onResponse(UnkNown Source:45)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
2021-02-15 21:48:22.057 3106-3200/com.claytech.paypaldemoapplication E/paypal.sdk: request Failed with server response:
2021-02-15 21:48:22.075 3106-3106/com.claytech.paypaldemoapplication E/paypal.sdk: INTERNAL_SERVER_ERROR
解决方法
PayPal Android SDK 已弃用,因此您似乎在使用已弃用的解决方案。如果您需要本机 SDK,通过 Braintree 的 Express Checkout 是唯一可用的。但是,您确实需要一个服务器或网络服务来使用 Braintree,因为该集成有一个服务器端部分。
或者,您可以在您的服务器或网络服务上集成 v2 Create Order API,并使用 rel:approve URL 从您的本机应用程序打开浏览器,并将返回 URL 设为您的应用程序的深层链接,然后触发捕获从您的服务器订购电话。
如您所见,所有解决方案都需要服务器或网络服务。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。