Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php PayPal智能支付按钮错误PayPal。按钮不是功能_Php_Paypal - Fatal编程技术网

Php PayPal智能支付按钮错误PayPal。按钮不是功能

Php PayPal智能支付按钮错误PayPal。按钮不是功能,php,paypal,Php,Paypal,在我的网站正常运行之前,我正在整合智能支付按钮,但今天早些时候,我发现了这些错误 我在加载paypal.Buttons().render()函数之前加载了paypal SDK,该函数位于我的paypal.js文件中 <script src="https://www.paypal.com/sdk/js?client-id=<MY_CLIENT_ID_HERE>&currency=PHP"></script> <script type="text

在我的网站正常运行之前,我正在整合智能支付按钮,但今天早些时候,我发现了这些错误

我在加载
paypal.Buttons().render()
函数之前加载了paypal SDK,该函数位于我的
paypal.js
文件中

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

<script type="text/javascript" src="paypal.js"></script>
paypal.Buttons({
createOrder : function(data, actions){
  return actions.order.create({
    purchase_units : [{
      amount : {
        value : amount_to_pay
      }
    }],
    application_context: {
        shipping_preference: "NO_SHIPPING",
    },
    country_code : "PH"
  })
},
style: {
      color:  'gold',
      shape:  'rect',
      label:  'buynow',
       size: 'responsive',
       branding: true

  },
  onApprove: function(data, actions) {
    // Capture the funds from the transaction
    return actions.order.capture().then(function(details) {

      return fetch('/pay-with-pp', {
        method: 'post',
        headers: {
          'content-type': 'application/json'
        },
        body: JSON.stringify({
          orderID: data.orderID,
          product_id : product_id,
          _token : token
        })
      }).then(function(res){
        alert('Payment has been made! Please see the delivery status on orders page!');
        window.location.href = redirect_url
      });
    });
  },

}).render('#paypal-button-container');

我仔细分析了错误,找到了解决办法

我在加载SDK的脚本标记中添加了一个
数据名称空间
属性

<script src="https://www.paypal.com/sdk/js?client-id=AaJMejIDjhumOr48XsycjfvQegxAku1dHdrA0DNfkqFSg7bFFkpJTnnwyaLIGUFsPijWx1g51gxp9F-5&currency=USD" data-namespace="paypal_sdk"></script>
我曾经

paypal_sdk.Buttons().render()

而且它有效

太好了,它对我也有效,非常感谢!
paypal_sdk.Buttons().render()