PayPal付款页面未显示

时间:2012-09-26 08:25:02

标签: android

我正在创建测试用途的paypal应用程序。我已经创建了测试paypal帐户,并在我的活动中按下了我的按钮点击了下面的代码。但没有任何东西可以展示并获得例外:

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

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

2 个答案:

答案 0 :(得分: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("") ;
}

答案 1 :(得分:0)

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