MikeKeepsOnShine
MikeKeepsOnShine

Reputation: 1750

Android:add PayPal payments

I'm building an Android application, integrated with Paypal. I wrote this:

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);

When i run the emulator, the app crashes. Log cat says:

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)

The library that i've imported is PayPal_MPL.jar.

Have i need to import other jar? or what?

Thanks.

Upvotes: 1

Views: 1227

Answers (2)

1'hafs
1'hafs

Reputation: 579

Please use Pay pal sandbox accounts, the issue will be solved.

Upvotes: 0

tomwhipple
tomwhipple

Reputation: 2850

The MPL library that you're using is being deprecated. It's recommended that you use the new PayPal Android SDK instead if possible.

Upvotes: 1

Related Questions