简体   繁体   English

这是处理信用卡付款的正确方法吗?

[英]Is this a proper way to handle credit card payments?

I have a 3-page checkout process. 我有一个3页的结帐流程。 The first page is Customer information. 第一页是客户信息。 The second page is card information. 第二页是卡信息。 The third page is review & confirm order. 第三页是查看并确认订单。

I'm using the paypal api to handle payments processing. 我正在使用Paypal API处理付款处理。 Right now I have the payments page setup with the request parameters for the paypal api stored in an array, and after the customer clicks confirm & pay, I send the request over the paypal api. 现在,我已将付款页面设置与数组中存储的paypal api的请求参数一起设置,并且在客户单击“确认并付款”后,我通过Paypal api发送了请求。 Is this a proper way to handle credit card payments? 这是处理信用卡付款的正确方法吗? Would I just have to store the $nvp_string using mcrypt or some other encryption method? 我是否只需要使用mcrypt或其他某种加密方法来存储$nvp_string or temporarily store in a database and delete the info after the order is paid? 还是暂时存储在数据库中并在付款后删除信息?

Payment Information Page

// Store request params in an array THESE ARE STATIC VARIABLES FOR TESTING
$request_params = array
                (
                'METHOD' => 'DoDirectPayment', 
                'USER' => $api_username, 
                'PWD' => $api_password, 
                'SIGNATURE' => $api_signature, 
                'VERSION' => $api_version, 
                'PAYMENTACTION' => 'Sale',                   
                'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
                'CREDITCARDTYPE' => 'MasterCard', 
                'ACCT' => '5522340006063638',                        
                'EXPDATE' => '022018',           
                'CVV2' => '456', 
                'FIRSTNAME' => 'Tester', 
                'LASTNAME' => 'Testerson', 
                'STREET' => '707 W. Bay Drive', 
                'CITY' => 'Largo', 
                'STATE' => 'FL',                     
                'COUNTRYCODE' => 'US', 
                'ZIP' => '33770', 
                'AMT' => '100.00', 
                'CURRENCYCODE' => 'USD', 
                '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);    
}

Confirm & Pay Page

// 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);

// Parse the API response
$nvp_response_array = parse_str($result);

Storage of variables in a database for a 3 step process is an idea that's really fraught with issues. 在数据库中为3个步骤存储变量的想法确实充满了问题。 For one, you never want to get into the credit card info storage business, and it may actually be against TOS based on your payment provider and other factors. 首先,您永远不想涉足信用卡信息存储业务,并且根据您的支付提供商和其他因素,这实际上可能违反了TOS。 You'd have to consider things like abandoned processes too. 您还必须考虑诸如废弃流程之类的事情。

When I build a site like this, I'll have a 3 (or more) step process, but it's all in one page. 当我建立这样的网站时,我将需要3个(或更多)步骤,但全部都在一个页面中。 Build 3 different "screens" in divs/templates on one file and then toggle between those divs/templates without changing files. 在一个文件的div /模板中构建3个不同的“屏幕”,然后在这些div /模板之间切换而无需更改文件。 This way, the data is still in one common form (which spans the 3 divs/templates) and I don't have to deal with storage of variables on a session or database at all. 这样,数据仍然是一种通用形式(跨越3个div /模板),而且我根本不必处理会话或数据库中的变量存储。 It's also lightning quick to toggle between. 闪电般的快速切换。 Really, your only consideration of any significance is handling back button behavior, which can be accomplished with URL hashing. 实际上,您对任何意义的唯一考虑就是处理后退按钮行为,这可以通过URL哈希来完成。 When you've reached the last screen in your process, simply submit the form. 当您到达流程的最后一个屏幕时,只需提交表单即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM