PayPal JavaScript SDK客户端JS,如何获取功能?

时间:2019-03-07 15:47:04

标签: javascript php paypal

问题与PayPal JavaScript SDK客户端JS有关 https://developer.paypal.com/docs/checkout/reference/server-integration/capture-transaction/#on-the-serverfetch功能如何工作?

根据官方文档,客户端类似于:

paypal.Buttons({

createOrder: function(data, actions) {
  return actions.order.create({
    purchase_units: [{
      amount: {
        value: '0.01'
      }
    }]
  });  
},

onApprove: function( data, actions ) {
    return actions.order.capture().then( function(details) {
        //alert('Transaction completed by ' + details.payer.name.given_name);
        // Call your server to save the transaction
        //console.log('Transaction completed' ); alert(details); 
        console.log( 'data.orderID = ' + data.orderID ); 
        document.getElementById('orderID').value = data.orderID;
        console.log('data'); console.log(data); 
        console.log('Transaction completed by ' + details.payer.name.given_name );
        //return fetch('/paypal-transaction-complete', {
        return fetch( 'https://domain.biz/pay/ppal_1025/EN/pay', {
            method: 'POST',
            body: JSON.stringify({
                orderID: data.orderID,
                submitPpal: 1 //imitation of submit button
            })
        }); // return fetch( 'https://typejoy.biz/pay/ppal_1025/EN/pay
    }); // return actions.order.capture().then( function(details
} // onApprove: function(data, actions

  }).render('#payPp'); 

我不了解其工作原理:

return fetch( 'https://domain.biz/pay/ppal_1025/EN/pay', { <... > } )

我在与网址https://domain.biz/pay/ppal_1025/EN/pay相关的文件中看不到任何POST结果

空POST记录为URL out.php的{​​{1}}

https://domain.biz/pay/ppal_1025/EN/pay

PayBundle \ Resources \ actions \ ppal \ action.php

file_put_contents( __DIR__'/out.php', json_encode( $_POST ) .' from '.__FILE__  );

0 个答案:

没有答案