【发布时间】:2012-12-27 18:54:00
【问题描述】:
我在结账后收到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();
【问题讨论】:
-
你需要为我们提供更多的东西来根除你的问题,因为这意味着当你的数组有 4 个项目时你试图访问位置 6 的东西[0-3 ]
-
嗨@DanielFigueroa,我已经编辑了我的问题,以防万一它有任何帮助
-
您使用的是哪个版本的
PayPal MPL?如果此问题仍然存在,您能否使用version 1.5.5.44测试您的代码并更新您的跟踪信息? -
嗨@Akdeniz,我使用的是 1.5.5.44 版本的 PayPal_MPL。如果我仍然需要更新堆栈跟踪,请告诉我。提前致谢。