1

Paypal Mass Pay IPNについての質問です。私のプラットフォームはPHP と mySQLです。

PaypalサポートWebサイト全体で、行われた支払いのみのIPNを見つけました. Mass Pay の同様の回線で IPN が必要ですが、見つかりませんでした。また、既存の Mass Pay NVP コードを試してみましたが、うまくいきませんでした。

私がやろうとしているのは、Mass Pay 経由で支払いが正常に送信されたすべての受信者について、自分のデータベース テーブルに電子メール、金額、unique_id を記録したいということです。できれば支払い状況も把握したいので、成功か失敗か、それをもとに社内で何らかの処理をする必要があります。

既存のコード Mass pay コードは次のとおりです。

<?php

$environment = 'sandbox';   // or 'beta-sandbox' or 'live'

/**
 * 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($methodName_, $nvpStr_) {
    global $environment;

    // Set up your API credentials, PayPal end point, and API version.
    $API_UserName = urlencode('my_api_username');
    $API_Password = urlencode('my_api_password');
    $API_Signature = urlencode('my_api_signature');

    $API_Endpoint = "https://api-3t.paypal.com/nvp";
    if("sandbox" === $environment || "beta-sandbox" === $environment) {
        $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
    }
    $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_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);

    // Set the API operation, version, and API signature in the request.
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$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;
}

// Set request-specific fields.
$emailSubject =urlencode('example_email_subject');
$receiverType = urlencode('EmailAddress');
$currency = urlencode('USD');                           // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')

// Add request-specific fields to the request string.
$nvpStr="&EMAILSUBJECT=$emailSubject&RECEIVERTYPE=$receiverType&CURRENCYCODE=$currency";

$receiversArray = array();

for($i = 0; $i < 3; $i++) {
    $receiverData = array(  'receiverEmail' => "user$i@paypal.com",
                            'amount' => "example_amount",
                            'uniqueID' => "example_unique_id",
                            'note' => "example_note");
    $receiversArray[$i] = $receiverData;
}

foreach($receiversArray as $i => $receiverData) {
    $receiverEmail = urlencode($receiverData['receiverEmail']);
    $amount = urlencode($receiverData['amount']);
    $uniqueID = urlencode($receiverData['uniqueID']);
    $note = urlencode($receiverData['note']);
    $nvpStr .= "&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note";
}

// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = PPHttpPost('MassPay', $nvpStr);

if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    exit('MassPay Completed Successfully: '.print_r($httpParsedResponseAr, true));


} else  {
    exit('MassPay failed: ' . print_r($httpParsedResponseAr, true));
}

?>

上記のコードで、上記で要求したフィールドをキャプチャするコードをどこにどのように追加すればよいですか? 解決策を示すコードは高く評価されます。

どうもありがとうございました。

4

2 に答える 2

0

私は定期支払いに精通していますが、IPN応答はあなたが探している値を送り返すと思います。返送された配列からそれらをキャプチャし、いくつかの変数に配置して、データベースに保存するだけです。

$email   = $httpParsedResponseAr["receiver_email"];  
$amount  = $httpParsedResponseAr["mc_currency_x"];

一括支払い変数の値は次のとおりです
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables

于 2010-04-11T02:06:51.543 に答える
0

一般に、このデータを取得するには 2 つの方法があります。1 つは、masspay を直接呼び出したときの応答を確認する方法で、もう 1 つはアカウントの IPN を設定する方法です。

グローバル IPN を設定する必要があります。この呼び出しで IPN リッスン URL を変数として送信する方法が見つかりません。

HTH-FT

于 2011-02-26T09:54:46.673 に答える