我正在構建一個與Paypal集成的Android應用程序。 我寫了這個:Android:添加PayPal付款
PayPal pp = PayPal.initWithAppID(this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX);
LinearLayout lay = (LinearLayout)findViewById(R.id.layout_faq);
CheckoutButton launchSimplePayment = pp.getCheckoutButton(this, PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY);
launchSimplePayment.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
PayPalPayment payment = new PayPalPayment();
payment.setSubtotal(new BigDecimal("8.25"));
payment.setCurrencyType("USD");
payment.setRecipient("[email protected]");
payment.setPaymentType(PayPal.PAYMENT_TYPE_GOODS);
Intent checkoutIntent = PayPal.getInstance().checkout(payment, getApplicationContext());
startActivityForResult(checkoutIntent, 1);
}});
lay.addView(launchSimplePayment);
當我運行模擬器,應用程序崩潰。日誌貓說:
05-03 12:48:41.768: E/AndroidRuntime(748): FATAL EXCEPTION: Thread-85
05-03 12:48:41.768: E/AndroidRuntime(748): java.lang.NullPointerException
05-03 12:48:41.768: E/AndroidRuntime(748): at com.paypal.android.b.e.j(Unknown Source)
05-03 12:48:41.768: E/AndroidRuntime(748): at com.paypal.android.b.e.v(Unknown Source)
05-03 12:48:41.768: E/AndroidRuntime(748): at com.paypal.android.b.e.c(Unknown Source)
05-03 12:48:41.768: E/AndroidRuntime(748): at com.paypal.android.b.f.run(Unknown Source)
我導入的庫是PayPal_MPL.jar。
我需要導入其他jar嗎?或者是什麼?
謝謝。
https://developer.paypal.com/webapps/developer/docs/classic/mobile/ht_mpl-itemPayment-Android/ – Ajay 2013-05-03 13:01:34
oK,這裏說,我必須加載「其他必要的MPL組件」,它帶來了我到下載頁面...可能是一個愚蠢的問題,但我必須下載java-rest-api ...對嗎? – MikeKeepsOnShine 2013-05-03 13:13:14
無需下載Java休息api運行簡單的貝寶應用程序,請檢查此示例https://github.com/vivdub/SimplePayPalIntegration並嘗試使用最新的PayPal_MPL jar文件這一個 – Ajay 2013-05-03 13:22:24