Paypal学习 3 -- 接受信用卡直接付款 (DoDirectPayment)
2014-10-19 15:11
597 查看
我们的页面可以提供用户直接填写信用卡付款的功能。具体步骤如下:
1) 在我们sandbox business账户下面添加一张信用卡,这张信用卡的信息可以是真实的,由于是在sandbox下,我们做测试所pay的都不会真正从信用卡中划掉,所以可以放心。具体路径:
sandbox --> My Account --> Profile --> Financial Information --> credit cards --> add a credit card
2) 找到此business账号的个人信息: 包括username password signature, 具体路径
登录到paypal developer, --> Dashboard --> Sandbox --> Accounts --> Profile --> API credencials
3) 拿到个人信息后就可以编写代码了,
4) request_parameter里面包含了信用卡的信息。
注: 参考文档 http://code.tutsplus.com/tutorials/how-to-process-credit-cards-with-paypal-payments-pro-using-php--net-25397
1) 在我们sandbox business账户下面添加一张信用卡,这张信用卡的信息可以是真实的,由于是在sandbox下,我们做测试所pay的都不会真正从信用卡中划掉,所以可以放心。具体路径:
sandbox --> My Account --> Profile --> Financial Information --> credit cards --> add a credit card
2) 找到此business账号的个人信息: 包括username password signature, 具体路径
登录到paypal developer, --> Dashboard --> Sandbox --> Accounts --> Profile --> API credencials
3) 拿到个人信息后就可以编写代码了,
<?php // Set sandbox (test mode) to true/false. $sandbox = TRUE; // Set PayPal API version and credentials. $api_version = '85.0'; $api_endpoint = $sandbox ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp'; $api_username = $sandbox ? 'your username' : 'LIVE_USERNAME_GOES_HERE'; $api_password = $sandbox ? 'your password' : 'LIVE_PASSWORD_GOES_HERE'; $api_signature = $sandbox ? 'your signature' : 'LIVE_SIGNATURE_GOES_HERE'; // Store request params in an array $request_params = array ( 'METHOD' => 'DoDirectPayment', 'USER' => $api_username, 'PWD' => $api_password, 'SIGNATURE' => $api_signature, 'VERSION' => $api_version, 'PAYMENTACTION' => 'Sale', 'IPADDRESS' => $_SERVER['REMOTE_ADDR'], <p class="p1"> 'CREDITCARDTYPE' <span class="s1">=> </span>'MasterCard'<span class="s1">, </span><span class="s2">// card type</span></p><p class="p2"><span class="s1"> <span> </span><span> </span></span><span class="s3">'ACCT' </span><span class="s1">=> </span><span class="s3">'**'</span><span class="s1">, </span>// your card no</p><p class="p1"><span class="s1"> <span> </span><span> </span></span>'EXPDATE' <span class="s1">=> </span>'**'<span class="s1">, </span><span class="s2">// expire date</span></p><p class="p3"> <span> </span><span> </span><span class="s3">'CVV2' </span>=> <span class="s3">'**'</span>, <span class="s2">// CVV</span></p><p class="p1"><span class="s1"> <span> </span><span> </span></span>'FIRSTNAME' <span class="s1">=> </span>'**'<span class="s1">,</span></p><p class="p1"><span class="s1"> <span> </span><span> </span></span>'LASTNAME' <span class="s1">=> </span>'**'<span class="s1">,</span></p>// 'STREET' => '707 W. Bay Drive', // 'CITY' => 'Largo', // 'STATE' => 'FL', // 'COUNTRYCODE' => 'US', // 'ZIP' => '33770', 'AMT' => '0.01', 'CURRENCYCODE' => 'AUD', 'DESC' => 'Testing Payments Pro' ); // Loop through $request_params array to generate the NVP string. $nvp_string = ''; foreach($request_params as $var=>$val) { $nvp_string .= '&'.$var.'='.urlencode($val); } // Send NVP string to PayPal and store response $curl = curl_init(); curl_setopt($curl, CURLOPT_VERBOSE, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_URL, $api_endpoint); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string); $result = curl_exec($curl); curl_close($curl); $nvp_response_array = parse_str($result); print_r($nvp_response_array); ?>
4) request_parameter里面包含了信用卡的信息。
注: 参考文档 http://code.tutsplus.com/tutorials/how-to-process-credit-cards-with-paypal-payments-pro-using-php--net-25397
相关文章推荐
- Paypal学习 3 -- 接受信用卡直接付款 (DoDirectPayment)
- PayPal账户类型-PayPal个人账户可以接受美金付款吗?
- EXE和SYS通信(ReadFile WriteFile DO_DIRECT_IO) 直接方式
- 信用卡怎么付款给PayPal?
- Magento paypal付完款后订单状态还是pendding payment 待付款状态如何解决?
- EXE和SYS通信(ReadFile WriteFile DO_DIRECT_IO) 直接方式
- Direct Push 学习
- Direct 3D学习笔记(三)——光照与材质
- 学习Direct 3D之Cube Example
- PayPal 付款,收款,转账各项费用参考
- c++学习笔记:直接排序
- paypal的即时付款通知参数列表
- 网站集成贝宝Paypal付款
- Tapestry学习九:关于组件(四)Loop, Output and DirectLink
- Direct 3D学习笔记(四)——纹理映射
- 常用在线支付方式对比:PayPal、信用卡和支票
- 直接初始化与拷贝初始化学习笔记
- 大学最后一个学习的半年,Do crazily without hesitation
- SIGGRAPH2007的一篇文章翻译:在GPU上直接处理细分曲面(Direct Manipulation of Subdivision Surfaces on GPUs)
- 新概念英语第二册 Lesson25 Do English speak English? 学习笔记