ペイパル一括支払いAPIを使用してIPNを介して受信機の詳細をキャプチャし、保存する必要があります

StackOverflow https://stackoverflow.com/questions/2615632

  •  26-09-2019
  •  | 
  •  

質問

これは、ペイパル一括支払いIPNについての質問です。私のプラットフォームは、をPHP&MySQLののです。

ペイパルのサポートWebサイトの上にすべては、私が作っのみ支払いにIPNを発見しました。私はミサ支払いのために同様の行にIPNを必要とするが、それを見つけることができませんでした。また、既存のマスペイNVPコードを試してみましたが、それはどちらか動作しませんでした。

私は何をしようとしていることは、支払いが正常に一括支払いを介して送信されてきた人に、すべての受信者のために、私は自分のデータベーステーブルに自分の電子メール、量とUNIQUE_IDを記録したいされていること。可能ならば、私はそれが失敗の成功を収めてと同じに基づいているかどうか、だけでなく、支払い状況をキャプチャしたい、私は家の処理にいくつかを行う必要があります。

既存のコード質量給与コードを以下に示します:

<?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));
}

?>
上記のコードでは、

、どのように、私は上記要求されたというのフィールドをキャプチャするためにコードを追加しますか?溶液を示す任意のコードが高く評価されている。

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

役に立ちましたか?

解決

私は支払いを定期的に慣れていますが、私はIPN応答は、あなたが求めている値を返送すると思います。ただ、バックアレイで送ってキャプチャするいくつかの変数にそれらを配置し、データベースに保存します。

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

ここでは、マス有料変数の値です
https://cms.paypal.com/us / CGI-binに/?CMD = _render-コンテンツ&CONTENT_ID =開発者/ e_howto_html_IPNandPDTVariablesする

他のヒント

は、このデータを取得するには、一般的には2つの方法があり、一つは、あなたが直接masspayする作るの呼び出しからの応答を見ることで、他のアカウントのためのIPNを設定しています。

あなたはセットアップグローバルIPNに、私はIPNに送信する方法を見つけることができません。この呼び出しの変数としてURLを聴いています。

HTH -FT

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top