ArrayIndexOutOfBoundsException
チェックアウト後にトランザクションがキャンセルされました。SANDBOX テスト アカウントを使用しています。
ここでスタック トレースからのチャンクを提供しています。
FATAL EXCEPTION: Thread-481
E/AndroidRuntime(15495): java.lang.ArrayIndexOutOfBoundsException: length=4; index=6
at com.paypal.android.MEP.PayPal.getPayType(Unknown Source)
at com.paypal.android.a.m.f(Unknown Source)
at com.paypal.android.a.b.y(Unknown Source)
at com.paypal.android.a.b.f(Unknown Source)
at com.paypal.android.a.k.run(Unknown Source)
私の支払いタスククラスは -
public class PaymentTask extends AsyncTask<Void, Void, Void>{
private Handler mHandler;
private Activity mActivity;
// The PayPal server to be used - can also be ENV_NONE and ENV_LIVE
private static final int server = PayPal.ENV_SANDBOX;
// The ID of your application that you received from PayPal
private static final String appID = "APP-80W284485P519543T";
public PaymentTask(Activity mActivity, Handler mHandler){
super();
this.mHandler = mHandler;
this.mActivity = mActivity;
}
@Override
protected Void doInBackground(Void... params) {
PayPal pp = PayPal.getInstance();
// If the library is already initialized, then we don't need to initialize it again.
if(pp == null) {
pp = PayPal.initWithAppID(mActivity, appID, server);
pp.setLanguage("en_US"); // Sets the language for the library.
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
// Set to true if the transaction will require shipping.
pp.setShippingEnabled(true);
pp.setDynamicAmountCalculationEnabled(false);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
mHandler.sendEmptyMessage(0);
super.onPostExecute(result);
}
}
チェックアウトボタンのクリック時に実行されるコード -
PayPalPayment newPayment = new PayPalPayment();
newPayment.setSubtotal(new BigDecimal(Integer.parseInt("10"));
newPayment.setCurrencyType("USD");
newPayment.setRecipient("my.mail@gmail.com");
newPayment.setPaymentType(PayPal.PAYMENT_SUBTYPE_DONATIONS);
newPayment.setMerchantName("Support the initiative");
// Sets the memo. This memo will be part of the notification sent by PayPal to the necessary parties.
newPayment.setMemo("Thanks for contributing generously!");
Intent paypalIntent = PayPal.getInstance().checkout(newPayment, getSherlockActivity());
startActivityForResult(paypalIntent, request);
}
mCheckoutButton.updateButton();