[英]Android Paypal Integration
I am trying to integrate paypal as one of payment gateway in my app and it returns the following error once I click on the pay button. 我正在尝试将Paypal集成为我的应用程序中的付款网关之一,一旦我单击“付款”按钮,它将返回以下错误。
Error java.lang.RuntimeException: Unable to start service com.paypal.android.sdk.payments.PayPalService@b122d3c8 with Intent { cmp=com.nepflights.app/com.paypal.android.sdk.payments.PayPalService }: java.lang.RuntimeException: Service extras required. 错误 java.lang.RuntimeException:无法启动Income {cmp = com.nepflights.app / com.paypal.android.sdk.payments.PayPalService}服务com.paypal.android.sdk.payments.PayPalService@b122d3c8。 lang.RuntimeException:需要额外的服务。 Please see the docs.
请参阅文档。
The code for paypal is as follows, 贝宝的代码如下,
public void onClick (View v){
switch (v.getId()) {
case R.id.btnPaypal:
PayPalPayment YourTicket = new PayPalPayment(new BigDecimal(1), "USD",
"Your Total ticket price:",
PayPalPayment.PAYMENT_INTENT_SALE);
Intent intent = new Intent(payActivity.this, PaymentActivity.class);
intent.putExtra(PaymentActivity.EXTRA_PAYMENT, YourTicket);
startActivityForResult(intent, REQUEST_PAYPAL_PAYMENT);
break;
}
}
@Override
protected void onActivityResult ( int requestCode, int resultCode, Intent data){
if (requestCode == REQUEST_PAYPAL_PAYMENT) {
if (resultCode == Activity.RESULT_OK) {
PaymentConfirmation confirm = data
.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
if (confirm != null) {
try {
System.out.println("Responseeee" + confirm);
Log.i("paymentExample", confirm.toJSONObject().toString());
JSONObject jsonObj = new JSONObject(confirm.toJSONObject().toString());
String paymentId = jsonObj.getJSONObject("response").getString("id");
System.out.println("payment id:-==" + paymentId);
Toast.makeText(getApplicationContext(), paymentId, Toast.LENGTH_LONG).show();
} catch (JSONException e) {
Log.e("paymentExample", "an extremely unlikely failure occurred: ", e);
}
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.i("paymentExample", "The user canceled.");
} else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
Log.i("paymentExample", "An invalid Payment was submitted. Please see the docs.");
}
}
}
included the following to manifist 包括以下内容以供清单
<service android:name="com.paypal.android.sdk.payments.PayPalService" android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<!--end of paypal requirements -->
It appears that you are not starting the service at all, or you forgot to provide the PayPalConfiguration
extra to the service. 看来您根本没有启动该服务,或者您忘记为该服务额外提供
PayPalConfiguration
。 As mentioned in our integration docs, you must start the service as follows: 如我们的集成文档中所述,您必须按照以下步骤启动服务:
Intent intent = new Intent(this, PayPalService.class); intent.putExtra(PayPalService.EXTRA_PAYPAL_CONFIGURATION, config); startService(intent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.