I downloaded this library: MPL
I downloaded this example: PizzaMPL
I created a sandbox account and several personal and business accounts.
I see the API credentials and signature perfectly (I don’t need the API credentials for testing in SANDBOX?) If so, where do I need to paste my code? The docs say, “In addition to the API credentials, MPL calls also require an AppID. For Sandbox in PayPal, the AppID is static:“ APP-80W284485P519543T ”“ In the app <? >
Now in the SANDBOX environment, when I give the "pay using PayPal" button, the code received in PayPalActivityResult (int requestCode, int resultCode, intention intent): PayPal.FAILURE and the displayed message: "The application is not authorized, Error ID -1"
I could not find this error in the wonderful PayPal documentation.
Here is my code:
public void initLibrary() {
PayPal pp = PayPal.getInstance();
if (pp == null) {
pp = PayPal.initWithAppID(this, "APP-80W284485P519543T",
PayPal.ENV_SANDBOX);
pp.setLanguage("en_US");
pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
pp.setShippingEnabled(true);
pp.setDynamicAmountCalculationEnabled(false);
_paypalLibraryInit = true;
}
}
private void showPayPalButton() {
PayPal pp = PayPal.getInstance();
CheckoutButton launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);
launchPayPalButton.setOnClickListener(this);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.bottomMargin = 10;
launchPayPalButton.setLayoutParams(params);
launchPayPalButton.setId(12345);
((LinearLayout) findViewById(R.id.wrapper)).addView(launchPayPalButton);
((LinearLayout) findViewById(R.id.wrapper)).setGravity(Gravity.CENTER_HORIZONTAL);
}
public void PayPalButtonClick(View arg0) {
PayPalPayment payment = new PayPalPayment();
payment.setCurrencyType("USD");
payment.setRecipient("erauskin-facilitator@gmail.com");
payment.setSubtotal(new BigDecimal(200.0f));
payment.setPaymentType(PayPal.PAYMENT_TYPE_PERSONAL);
payment.setMerchantName("Discográfica XXX");
Intent paypalIntent = PayPal.getInstance().checkout(payment, this);
this.startActivityForResult(paypalIntent, 1);
}
public void PayPalActivityResult(int requestCode, int resultCode, Intent intent) {
switch (resultCode) {
case Activity.RESULT_OK:
String payKey = intent
.getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
this.paymentSucceeded(payKey);
break;
case Activity.RESULT_CANCELED:
this.paymentCanceled();
break;
case PayPalActivity.RESULT_FAILURE:
String errorID = intent
.getStringExtra(PayPalActivity.EXTRA_ERROR_ID);
String errorMessage = intent
.getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
this.paymentFailed(errorID, errorMessage);
}
}
source
share