Android中的PayPal自适应支付(链式支付)集成

时间:2014-03-07 13:32:39

标签: paypal-sandbox paypal-adaptive-payments

我正在我的应用程序中集成PayPal自适应支付并搜索我的问题的解决方案。如果任何人在Android中实现了链式支付,请向我提供帮助。

问题: -

使用PayPal_MPL.jar在我的应用中集成链式支付时。我的工作正常,但有一个问题是paypal对话框中没有信用卡支付选项。

由于

我指的是link

2 个答案:

答案 0 :(得分:0)

first implement method
   private void initLibrary() {
        PayPal pp = PayPal.getInstance();
        if(pp == null) {
            pp = PayPal.initWithAppID(this, PAYPAL_APP_ID, PayPal.ENV_SANDBOX);
            pp.setLanguage("en_US"); // Sets the language for the library.
            pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER);
//            pp.setShippingEnabled(true);
            pp.setDynamicAmountCalculationEnabled(false);
        }
    }    



**paypal button click event code**

     double secondary_payment = 0;
    double primary_payment = 0;

      PayPalAdvancedPayment advPayment = makeChainedPayment(secondary_payment,primary_payment,"primary_email","secondary_email");

      Intent checkoutIntent = PayPal.getInstance().checkout(advPayment, your_current_activity);
                    startActivityForResult(checkoutIntent, 1); 

    =============================================
    private PayPalAdvancedPayment makeChainedPayment(double priceSecondary, double pricePrimary, String primary_email, String secondary_email) {
            PayPalAdvancedPayment payment = new PayPalAdvancedPayment();
            payment.setCurrencyType("USD");
    //        payment.setMerchantName("PushND");
            BigDecimal bigDecimalPrimary=new BigDecimal(pricePrimary);
            PayPalReceiverDetails receiverPrimary = new PayPalReceiverDetails();
            receiverPrimary.setRecipient(primary_email);
            //receiverPrimary.setRecipient("adaptive_receiver_1@pushnd.com");
            receiverPrimary.setSubtotal(bigDecimalPrimary);
            receiverPrimary.setIsPrimary(true);
            payment.getReceivers().add(receiverPrimary);

            PayPalReceiverDetails receiverSecondary= new PayPalReceiverDetails();
            receiverSecondary.setRecipient(secondary_email);
            BigDecimal bigDecimalSecond=new BigDecimal(priceSecondary);
            receiverSecondary.setSubtotal(bigDecimalSecond);
            payment.getReceivers().add(receiverSecondary);

            return payment;
        }

答案 1 :(得分:-1)

请找到以下链接并检查您的答案......

https://github.com/paypal/PayPal-Android-SDK

 PayPal pp = PayPal.getInstance();
             launchChainedPayment = pp.getCheckoutButton(this, PayPal.BUTTON_194x37, CheckoutButton.TEXT_PAY);
             launchChainedPayment.setOnClickListener(this);




private void initLibrary() {
              PayPal pp = PayPal.getInstance();
              if(pp == null) {
                     pp = PayPal.initWithAppID(this, Constant.PAYPAL_APP_ID, Constant.server);
                     pp.setLanguage("en_US"); // Sets the language for the library.
                     pp.setFeesPayer(PayPal.FEEPAYER_EACHRECEIVER); 
                     pp.setShippingEnabled(true);
                     pp.setDynamicAmountCalculationEnabled(false);
              }
             }
         private PayPalAdvancedPayment makeChainedPayment(double priceDouble,double pricePrimary,String primary_email,JSONObject jsonObject) {
                PayPalAdvancedPayment payment = new PayPalAdvancedPayment();
                payment.setCurrencyType("USD");
                payment.setMerchantName("PushND");
                BigDecimal bigDecimalPrimary=new BigDecimal(String.valueOf(priceDouble));
                PayPalReceiverDetails receiverPrimary = new PayPalReceiverDetails();
                receiverPrimary.setRecipient(primary_email);
                //receiverPrimary.setRecipient("adaptive_receiver_1@pushnd.com");
                receiverPrimary.setSubtotal(bigDecimalPrimary);
                receiverPrimary.setIsPrimary(true);
                payment.getReceivers().add(receiverPrimary);
            try {
                    JSONObject jsonObjectSecondary = jsonObject;
                    Iterator<Object> keys = jsonObjectSecondary.keys();
                    while (keys.hasNext())
                    {
                        String Key=String.valueOf(keys.next());
                        PayPalReceiverDetails receiverSecondary= new PayPalReceiverDetails();
                        receiverSecondary.setRecipient(jsonObjectSecondary.getJSONObject(Key).get("email").toString());
                       //   receiverSecondary.setRecipient("adaptive_receiver_2@pushnd.com");
                        double priceSecondary=priceDouble*((Double.parseDouble(jsonObjectSecondary.getJSONObject(Key).get("profit_percent").toString()))/100);
                        BigDecimal bigDecimalSecondary=new BigDecimal(String.valueOf(priceSecondary));
                        receiverSecondary.setSubtotal(bigDecimalSecondary);
                        receiverSecondary.setIsPrimary(false);
                        payment.getReceivers().add(receiverSecondary);
                    }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
          return payment;
     }