首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用PHP 5创建与Paypal服务器的HTTPS连接

使用PHP 5创建与Paypal服务器的HTTPS连接
EN

Stack Overflow用户
提问于 2012-10-19 01:42:34
回答 3查看 984关注 0票数 1

我正在尝试集成一个现有的网站与薪酬流专业。

PHP没有SDK,与PHP的集成将需要使用Payflow HTTPS接口。开发指南(https://cms.paypal.com/cms_content/AU/en_AU/files/developer/PP_WPPPF_HTTPSInterface_Guide.pdf)说,我将需要编写代码,创建一个HTTPS连接到贝宝服务器。我应该使用什么方法来完成此操作,以及如何在连接建立后提交HTTPS请求?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-10-23 05:48:20

我终于在这里找到了一个例子:https://ppmts.custhelp.com/app/answers/detail/a_id/618

代码语言:javascript
运行
复制
<?
$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;
?> 
票数 1
EN

Stack Overflow用户

发布于 2012-10-19 01:45:23

只需使用任何常规方法发出HTTP请求,例如curl或file_get_contents。如果底层传输层支持SSL安全连接,则向HTTPS发出请求将建立SSL安全连接;否则,传输层将失败,因为它无法建立https://...连接。

票数 1
EN

Stack Overflow用户

发布于 2012-10-21 12:05:40

您有三个选项:

1)如果您喜欢冒险,可以使用OSCommerce PHP PayFlow SDK作为起点:https://www.x.com/sites/default/files/OsC23PayPalPayFlow.zip

2)您可以通读支付流程的开发指南,并进行自己手工制作的API调用:https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PayflowPro_Guide.pdf

3)您可以尝试一下集成向导。我将为您自动生成代码:https://www.paypal-labs.com/integrationwizardccpayflow/main.php

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12960539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档