2

我正在创建测试目的的贝宝应用程序。我已经创建了测试贝宝帐户,并在我的按钮单击活动中编写了下面给出的代码。但什么都没有显示并出现异常:

09-26 13:52:51.908: E/NetworkHandler(540): postXML caught exception doing I/O, mobileclient.sandbox.paypal.com

代码:

float ammount = Float.parseFloat(_details.get(_G_no)
            .get_product_price());
     PayPalPayment newPayment = new PayPalPayment();
     newPayment.setSubtotal(BigDecimal.valueOf(ammount));
     newPayment.setCurrencyType("USD");
     newPayment.setRecipient("account@gmail.com");
     newPayment.setMerchantName("Merchant");
    PayPal pp = PayPal.getInstance();
     if(pp==null)
     pp = PayPal.initWithAppID(this, id, PayPal.ENV_SANDBOX);

    final Intent paypalIntent = pp.checkout(newPayment, this);
        this.startActivityForResult(paypalIntent, 1);

我的应用程序中有互联网许可。请帮我。

4

2 回答 2

0

我已从 MPL 库(已弃用)更新为新的 PayPal Android SDK。我已经解决了这个错误。

于 2013-11-10T17:12:59.020 回答
0

我不知道,这是否正确。但我通过在您的代码之前创建互联网连接找到了解决方案,感谢 Vikalp patel 进行识别Have you found the solution of NetworkHandler Error

public void PayPalButtonClick_ ( View v )
{
    class asynctaskToInitLibrary extends AsyncTask<String, Integer, String >
    {
        @Override
        protected String doInBackground(String... params) 
        {

            URL actualUrl = null;
            try 
            {
                actualUrl = new URL("http://www.google.com") ;
            } 
            catch (MalformedURLException e) 
            {
                e.printStackTrace();
            }
            try 
            {
                HttpURLConnection cn = (HttpURLConnection)actualUrl.openConnection();
                Log.i(cn.getResponseMessage(),"tushar:connectionResponse") ;
            } 
            catch (IOException e) 
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            PayPal pp = PayPal.getInstance();

            // If the library is already initialized, then we don't need to initialize it again.
            if(pp == null) 
            {
                // This is the main initialization call that takes in your Context, the Application ID, and the server you would like to connect to.
                pp = PayPal.initWithAppID(Paypal_MPL.this, "APP-80W284485P519543T", PayPal.ENV_SANDBOX );

                // -- These are required settings.
                pp.setLanguage("en_US"); // Sets the language for the library.
                // --

                // -- These are a few of the optional settings.
                // Sets the fees payer. If there are fees for the transaction, this person will pay for them. Possible values are FEEPAYER_SENDER,
                // FEEPAYER_PRIMARYRECEIVER, FEEPAYER_EACHRECEIVER, and FEEPAYER_SECONDARYONLY.
                pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER); 
                // Set to true if the transaction will require shipping.
                pp.setShippingEnabled(true);
                // Dynamic Amount Calculation allows you to set tax and shipping amounts based on the user's shipping address. Shipping must be
                // enabled for Dynamic Amount Calculation. This also requires you to create a class that implements PaymentAdjuster and Serializable.
                pp.setDynamicAmountCalculationEnabled(false);
                // --
            }

            if (pp.isLibraryInitialized()) 
            {
                return "initialized" ;
            }
            else 
            {
                return "not-initialized" ;
            }
        }
        protected void onPostExecute(String result)
        {
            initializationStatus ( result ) ;
        }
    }

    asynctaskToInitLibrary object = new asynctaskToInitLibrary() ;
    object.execute("") ;
}
于 2013-07-03T09:01:52.727 回答