如何为多个商家使用PayPal?

时间:2019-03-21 18:19:00

标签: ionic-framework paypal ionic3

我正在尝试创建多个商店,在这些商店中,不同的商人应该出售他们的产品,并且每个商人都必须使用自己的PayPal帐户。
我想显示带有结帐数据和商户ID的PayPal表单,以便以正确的商户ID来获取每个商店的付款。

在桌面网站上,我为每个商人使用了以下操作信息,并且效果很好:

action: "https://www.paypal.com/it/cgi-bin/webscr"
param1: name=business and value="xxxxxxx"
param2: ....
etc...

在ionic3中,我尝试使用新的PayPal javascript SDK。

1-我在index.html标头中调用我的客户ID,如下所示:

<script src="https://www.paypal.com/sdk/js?client-id=xxxxx&currency=EUR"></script>  

2-在“ PayPal”按钮中,我尝试在Payee命令中传递每个商店的商家ID,但在PayPal中却出现错误:

  

在PayPal脚本代码中传递商人ID =“ XYZ”。通过   商人ID =未知,如果您无权访问商人ID。

很明显,我具有在Payee命令中传递的商家ID,如下面的脚本所示。我在哪里错了?

下面是我的按钮脚本:

initPayPal() {
var _totaleOrdine = this.totaleOrdine.toString();

var _merchant: string = 'XXXXXXXXX';

  paypal.Buttons({
    env: 'sandbox', // sandbox | production
      locale: 'it_IT',

      //ref: https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/customize-button/
    style: {
        size: 'responsive',
        color: 'gold',
        shape: 'pill',
        label: 'buynow', // label: checkout, buynow, credit, pay, paypal
        tagline: false

      },

    commit: true,
    debug: true,

     createOrder: function(data, actions) {
      // Set up the transaction
        console.log(data);
        console.log(actions);

        return actions.order.create({

        application_context: {
            brand_name: "MyBrand",
        },


        purchase_units: [{

     //   reference_id:_merchant,

          amount: {
            value: _totaleOrdine,
          },

          payee: {
            email: 'merchant2@mydomain.it',
            merchant_id: 'xxxxx'
          },

          shipping: {
            address: {

                address_line_1: "Via Roma 10",
                address_line_2: "",
                admin_area_2: "Roma",
                admin_area_1: "RM",
                postal_code: "00100",
                country_code: "IT",

            },

            name:{
                full_name: "adam adami"
            },
          },

        }],
});
},
     onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
        alert('Transaction completed by ' + details.payer.name.given_name);
       console.log(details);
        // Call your server to save the transaction
        return fetch('/paypal-transaction-complete', {
          method: 'post',
          body: JSON.stringify({
            orderID: data.orderID
          })
        });
        //
      });

    },

     onCancel: function(data, actions) {
        /*
         * Buyer cancelled the payment
         */
         console.log("Buyer cancelled the payment");
      },

     onError: function(err) {
        /*
         * An error occurred during the transaction
         */
         console.log(err);
         console.log("An error occurred during the transaction");
      }

  }).render(this.paypalbuttoncontainer2);

0 个答案:

没有答案