【问题标题】:how to execute Future payments on server-side如何在服务器端执行未来支付
【发布时间】:2014-08-14 08:54:43
【问题描述】:

我已经完成了在此 link 中提到的第一个两个步骤,并正在处理第三个步骤“使用您的后端服务器调用支付 API。”

对于第 3 步,我有 access_token相关 idamount

我在 curl 中找到了 step3 的以下代码。因此,我已将以下 curl 命令转换为 PHP 代码,对此我有两个问题:

1) 转换是否正确?

2) 如果是,那么从 PayPal 获得空白页响应可能是什么问题?

卷曲代码:

curl 'https://api.paypal.com/v1/payments/authorization/4TD55050SV609544L/capture' \
-H "Content-Type: application/json" \
-H "Paypal-Application-Correlation-Id: c2edbd6e97b14ff2b19ddb8eec9d264c" \
-H "Authorization: Bearer WfXdnxmyJtdF4q59ofxuQuAAk6eEV-Njm6puht3Nk3w" \
-d '{
       "amount":{
          "currency":"USD",
          "total":"1.50"
       },
       "is_final_capture":true
    }'

这是我根据上面的代码尝试的理解:

static public function executePayment2( $refresh_token, $correlation_id, $fee_amount )
{
    $data = array(
        "amount" => array(
            "currency" => "USD",
            "total" => $fee_amount
        ),
        "is_final_capture" => "true"
    );

    $data_string = json_encode($data);
    $ch = curl_init( "https://api.paypal.com/v1/payments/authorization/4TD55050SV609544L/capture" );        

    curl_setopt_array( $ch, array(
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => array(
                'Content-Type: application/json',
                'Content-Length: ' . strlen($data_string),
                'Authorization: Bearer ' . $refresh_token,      //Need to set $refresh_token
                'Paypal-Application-Correlation-Id: ' . $correlation_id      //Need to set $correlation_id
            ),
            CURLOPT_POSTFIELDS => $data_string,
            CURLOPT_RETURNTRANSFER => true
        )
    );

    $result = curl_exec( $ch );   //Make it all happen and store response   
}

【问题讨论】:

  • 还没反应?

标签: php paypal paypal-sandbox


【解决方案1】:

当您将您的移动应用程序与 PayPal Mobile SDK 2.0 集成时,您的客户无需登录其 PayPal 帐户就可以在未来多次支付账单。支持 PayPal 付款(不是信用卡)。基本...

【讨论】:

  • 我上面已经提到这些步骤都完成了。我在最后一步。
猜你喜欢
  • 2013-04-13
  • 2015-10-29
  • 2016-06-18
  • 2019-12-06
  • 1970-01-01
  • 2014-11-24
  • 2016-01-17
  • 2017-05-02
  • 1970-01-01
相关资源
最近更新 更多