【问题标题】:PayPal Express Payment Verification贝宝快速付款验证
【发布时间】:2018-11-24 22:55:53
【问题描述】:

我正在开发一个我接受 PayPal Express Checkout 的 WordPress 插件。我能够成功获取 PaymentID 和 PayerID。但我不知道如何验证付款。 另外,我可以从 payerID 或 PaymentID 获取付款人详细信息吗?

下面是我用来创建支付按钮的脚本。

<script>
          paypal.Button.render({

              env: 'sandbox',

              // PayPal Client IDs - replace with your own
              // Create a PayPal app: https://developer.paypal.com/developer/applications/create
              client: {
                  sandbox:    'AfI6d9wTxV519v5OI08omQE7HX9XI6-h3AopzKAiP5Yk2nO6brKaTJH8DyeAwpRpLI0CjGtQVSS737eS',
                  production: 'AfI6d9wTxV519v5OI08omQE7HX9XI6-h3AopzKAiP5Yk2nO6brKaTJH8DyeAwpRpLI0CjGtQVSS737eS'
              },

              // Show the buyer a 'Pay Now' button in the checkout flow
              commit: true,

              // payment() is called when the button is clicked
              payment: function(data, actions) {

                  // Make a call to the REST api to create the payment
                  return actions.payment.create({
                      payment: {
                          transactions: [
                              {
                                  amount: { total: <?php echo $_SESSION['trip-cost'];?>, currency: 'USD' },
                                  custom: '1452'
                              }
                          ]
                      }
                  });
              },
              validate: function(actions) {
                // var fields = jQuery(".wp-travel-engine-billing-details-wrapper").find("select, input").serializeArray();
                // console.log(fields);
                // jQuery.each(fields, function(i, field) {
                // if (!field.value)
                //   alert(field.name + ' is required');
                // }); 
              },
              // onAuthorize() is called when the buyer approves the payment
              onAuthorize: function(data, actions) {
                  // Make a call to the REST api to execute the payment
                  return actions.payment.execute().then(function() {
                      window.location = '<?php echo $wp_travel_engine_confirmation_page; ?>?paymentid='+data.paymentID+"&payerID="+data.payerID+"&token="+data.paymentToken+"&pid=1";
                  });
              }
          }, '#paypal-button-container');
        </script>

谢谢。

【问题讨论】:

    标签: wordpress paypal


    【解决方案1】:

    我可以通过使用 ipnlistener 来做到这一点。

    【讨论】:

      猜你喜欢
      • 2016-01-02
      • 2015-05-02
      • 2011-07-25
      • 2016-06-17
      • 2011-11-17
      • 2015-05-03
      • 2011-10-18
      • 2012-07-20
      • 2016-05-27
      相关资源
      最近更新 更多