使用Android studio实现Paypal SDK-无法从应用程序登录



调用PaypalService.class:的活动

//PAYPAL SDK VARIABLES
public static final int PAYPAL_REQUEST_CODE = 7171;
private static PayPalConfiguration config = new PayPalConfiguration()
.environment(PayPalConfiguration.ENVIRONMENT_SANDBOX)
.clientId(Config.PAYPAL_CLIENT_ID);
Intent payPalIntent = new Intent(this, PayPalService.class);
payPalIntent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
startService(payPalIntent);

payment = (Button) findViewById(R.id.payment);
payment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
processPayment();
}

});
}//END OF ON CREATE
@Override
protected void onDestroy() {
stopService(new Intent(this, PayPalService.class));
super.onDestroy();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PAYPAL_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
PaymentConfirmation confirmation = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirmation != null) {
try {
String paymentDetails = confirmation.toJSONObject().toString(4);
startActivity(new Intent(this,GetTheBike.class)
.putExtra("PaymentDetails", paymentDetails)
.putExtra("PaymentAmount", amount_to_pay)
);

} catch (JSONException e) {
e.printStackTrace();
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this, "Cancel", Toast.LENGTH_SHORT).show();
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID)
Toast.makeText(this, "Invalid", Toast.LENGTH_LONG).show();
}
}
private void processPayment() {
PayPalPayment payPalPayment = new PayPalPayment(new BigDecimal(amount_to_pay), "USD",
"Pay for parking", PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(this, PaymentActivity.class);
intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, payPalPayment);
startActivityForResult(intent, PAYPAL_REQUEST_CODE);

}
}

Config.java,它在另一个文件夹中。它能够连接到应用程序(Client_id是一个有效的密钥(

package com.example.becoapk21.Config;
public class Config {
public static final String PAYPAL_CLIENT_ID="CLIENT_ID";
}

我使用一个有效的客户沙箱帐户登录(在沙箱.贝宝.com上测试登录(,这是我登录后出现的错误

E/paypal.sdk: request failure with http statusCode:404,exception:Not Found
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:62)
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)
E/paypal.sdk: request failed with server response:
E/paypal.sdk: INTERNAL_SERVER_ERROR

注意:贝宝沙箱账户位于IL。我也尝试创建美国帐户,但它不起作用

这似乎是一个不推荐使用的Android SDK,用于现在已经过时的服务。

请参阅新的Native Checkout SDK。

相关内容

  • 没有找到相关文章

最新更新