1

Payflow Pro を既存の Web サイトに統合しようとしています。

PHP 用の SDK はありません。PHP との統合には、Payflow HTTPS インターフェイスを使用する必要があります。開発ガイド (https://cms.paypal.com/cms_content/AU/en_AU/files/developer/PP_WPPPF_HTTPSInterface_Guide.pdf) には、Paypal サーバーへの HTTPS 接続を作成するコードを記述する必要があると記載されています。これを行うにはどのような方法を使用すればよいですか? また、接続が確立された後に HTTPS 要求を送信するにはどうすればよいですか?

4

3 に答える 3

1

curlや。などのHTTPリクエストを発行する通常の方法を使用するだけfile_get_contentsです。基盤となるトランスポート層がSSLで保護された接続をサポートしている場合、https://...URLにリクエストを送信すると、SSLで保護された接続が作成されます。そうしないと、トランスポート層はHTTPS接続を確立できないと言って失敗します。

于 2012-10-18T17:45:22.730 に答える
1

最終的にここで例を見つけることができました: https://ppmts.custhelp.com/app/answers/detail/a_id/618

<?
$submiturl = "https://pilot-payflowpro.paypal.com/transaction:443/";

$plist="USER=****&VENDOR=****&PARTNER=****&PWD=****&TENDER=C&" .
        "TRXTYPE=A&ACCT=5105105105105100&" .
        "EXPDATE=1209&STREET= 123 MainSt.&CVV2=123&AMT=1.00";

$request_id = date('YmdGis');
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

// Here's your custom headers; adjust appropriately for your setup:
$headers[] = "Content-Type: text/namevalue";    // either text/namevalue or text/xml
$headers[] = "X-VPS-Timeout: 30";
$headers[] = "X-VPS-VIT-OS-Name: Linux";        // Name of your Operating System (OS)
$headers[] = "X-VPS-VIT-OS-Version: RHEL 4";    // OS Version
$headers[] = "X-VPS-VIT-Client-Type: PHP/cURL"; // Language you are using
$headers[] = "X-VPS-VIT-Client-Version: 0.01";  // For your info
$headers[] = "X-VPS-VIT-Client-Architecture: x86";  // For your info
$headers[] = "X-VPS-VIT-Integration-Product: MyApplication";  // For your info,  application name
$headers[] = "X-VPS-VIT-Integration-Version: 0.01"; // Application version
$headers[] = "X-VPS-Request-ID: " . $request_id;

$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $submiturl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 45); // times out after 45 secs
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https
curl_setopt($ch, CURLOPT_POSTFIELDS, $plist); //adding POST data
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2); //verifies ssl certificate
curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done
curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST

// $info = curl_getinfo($ch); //grabbing details of curl connection

$result = curl_exec($ch);
$headers = curl_getinfo($ch);
curl_close($ch);
echo $result;
?> 
于 2012-10-22T21:48:19.990 に答える