【问题标题】:payment from paypal account to another paypal account using php使用 php 从贝宝帐户付款到另一个贝宝帐户
【发布时间】:2013-06-10 04:01:27
【问题描述】:

我有信用用户的网站, 当必须使用积分时,他可以将它们转换为真正的金钱,

例如: 我是用户,我有 500 个积分, 1 积分 == 1 美元 用户按下“转换为美元”按钮, 然后他插入贝宝电子邮件来汇款。

现在我需要从我的贝宝帐户自动付款到他应该插入的贝宝电子邮件。

我正在尝试使用批量付款,但这并不接受所有用户,只接受特定用户。

 * Send HTTP POST Request
 * @param string The API method name
 * @param string The POST Message fields in &name=value pair format
 * @return array Parsed HTTP Response body
 */
function PPHttpPost($environment,$methodName_, $nvpStr_)
{
    // Set up your API credentials, PayPal end point, and API version.
    // How to obtain API credentials:
    // https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_NVPAPIBasics#id084E30I30RO
    $API_UserName = ('mail');
    $API_Password = ('passapi');
    $API_Signature = ('signture');
    $API_Endpoint = "https://svcs.paypal.com/AdaptivePayments/Pay";
    if("sandbox" == $environment || "beta-sandbox" === $environment)
    {
        $API_Endpoint = "https://svcs.$environment.paypal.com/AdaptivePayments/Pay";
    }
    $version = urlencode('51.0');

    // Set the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    // Turn off the server and peer verification (TrustManager Concept).
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "X-PAYPAL-SECURITY-USERID: {$API_UserName}",
        "X-PAYPAL-SECURITY-PASSWORD: {$API_Password}",
        "X-PAYPAL-SECURITY-SIGNATURE: {$API_Signature}",
        "X-PAYPAL-REQUEST-DATA-FORMAT: NV",
        "X-PAYPAL-RESPONSE-DATA-FORMAT: NV"
    ));

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    // Set the API operation, version, and API signature in the request.
    $nvpreq = $nvpStr_;

    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

    // Get response from the server.
    $httpResponse = curl_exec($ch);

    if( !$httpResponse)
    {
        exit("$methodName_ failed: " . curl_error($ch) . '(' . curl_errno($ch) .')');
    }

    // Extract the response details.
    $httpResponseAr = explode("&", $httpResponse);

    $httpParsedResponseAr = array();
    foreach ($httpResponseAr as $i => $value)
    {
        $tmpAr = explode("=", $value);
        if(sizeof($tmpAr) > 1)
        {
            $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
        }
    }

    if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr))
    {
        exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
    }

    return $httpParsedResponseAr;
}

我该怎么做?

感谢您的帮助!

【问题讨论】:

  • 你解决了吗?

标签: php paypal payment paypal-ipn


【解决方案1】:

看看PayPal Adaptive Payments IMPLICIT Pay API
使用自适应支付,您可以创建所谓的“隐式支付”。

隐式批准付款是指发送者和 API 调用者使用同一帐户的付款。由于 PayPal 从您自己的账户中提取用于付款的资金,因此无需批准,因此没有可见的隐式批准付款流程。

下图显示了隐式批准支付操作期间的基本控制流程:

以下项目对应图中圈出的数字:

  1. 您的网站或设备向 PayPal 发送支付请求。
    注意:不需要网络流。
  2. PayPal 使用您用于其他 API 操作的密钥进行响应。

如果您想进一步探索,我建议您阅读Adaptive Payments getting started 指南和Adaptive Payments developer guide 中的自适应支付。

注意:您可以在沙盒环境中使用 AppID APP-80W284485P519543T 进行测试。

【讨论】:

  • 我无法访问 recvide paypal 帐户。
  • 没关系 - 只要 API 调用者(您)和 sender 帐户相同,则隐式付款将起作用。
【解决方案2】:

您可以使用 MassPay API 或 Adative Payments (Pay) API 来执行此操作。当您说“我尝试使用批量付款,但这并不接受所有用户,只接受特定用户”时,我不确定您的意思是什么。你能再解释一下吗?

【讨论】:

  • 我尝试使用 massPay,但我得到的回应是:“你不能使用 massPay 选项”。
猜你喜欢
  • 2011-07-25
  • 2018-01-06
  • 1970-01-01
  • 2014-06-30
  • 2014-08-15
  • 2014-04-05
  • 2013-06-20
  • 2017-11-06
  • 2014-10-31
相关资源
最近更新 更多