Paypal MPL for Android和Pizza示例"应用程序未经授权,错误ID -1"

时间:2014-05-07 09:46:21

标签: android paypal paypal-sandbox paypal-adaptive-payments

我下载了这个库:MPL

我下载了这个示例:PizzaMPL

我创建了一个沙盒帐户以及多个个人和企业帐户。

我完全可以看到API凭据和签名(我不需要在SANDBOX中进行测试的API凭据?)如果是,我必须在我的代码中放入?文档说“除了API凭证,MPL调用还需要AppID。对于PayPal沙箱,AppID是静态的:”APP-80W284485P519543T“”在adition ????

现在在SANDBOX环境中,当我给出按钮“pay with paypal”时,在PayPalActivityResult(int requestCode,int resultCode,Intent intent)中获得的代码是:PayPal.FAILURE,显示的消息是:“应用程序未授权,错误ID -1“

我在paypal的精彩文档中找不到这个错误。

这是我的代码:

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() {

    // Generate the PayPal checkout button and save it for later use
    PayPal pp = PayPal.getInstance();
    CheckoutButton launchPayPalButton = pp.getCheckoutButton(this, PayPal.BUTTON_278x43, CheckoutButton.TEXT_PAY);
    // The OnClick listener for the checkout button
    launchPayPalButton.setOnClickListener(this);
    // Add the listener to the layout
    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) {
    // Create a basic PayPal payment
    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:
            // The payment succeeded
            String payKey = intent
                    .getStringExtra(PayPalActivity.EXTRA_PAY_KEY);
            this.paymentSucceeded(payKey);
            break;
        case Activity.RESULT_CANCELED:
            // The payment was canceled
            this.paymentCanceled();
            break;
        case PayPalActivity.RESULT_FAILURE:
            // The payment failed -- we get the error from the
            // EXTRA_ERROR_ID and EXTRA_ERROR_MESSAGE
            String errorID = intent
                    .getStringExtra(PayPalActivity.EXTRA_ERROR_ID);
            String errorMessage = intent
                    .getStringExtra(PayPalActivity.EXTRA_ERROR_MESSAGE);
            this.paymentFailed(errorID, errorMessage);
        }
}

0 个答案:

没有答案