繁体   English   中英

贝宝接受信用卡

[英]Paypal Accept Credit Card

好吧,我有一个我拥有Paypal商业帐户(在英国注册)的网站。 该贝宝已与我的网站集成在一起,并且工作正常。 当用户单击“继续付款”时,该用户将被带到Paypal的网站(以下屏幕截图)。 现在,我在此过程中遇到的唯一问题是客户必须先创建Paypal帐户才能向我付款。 我对贝宝提供的所有选项感到困惑(标准,专业,商人,不提供什么),而且我不确定自己做错了到底是什么。

截图http://ascensionnexus.com/Capture.jpg

请提出建议并解释我是否需要更改代码中的某些内容,以使客户直接使用他们的信用卡付款(在Paypal网站上),而不是先要求他们打开Paypal帐户。

编辑

我的ConfirmOrder页面上的HTML表单如下。

<form class="paypal" action="payments.php" method="post" id="paypal_form" target="_parent"> 
    <input type="hidden" name="cmd" value="_xclick" /> 
    <input type="hidden" name="no_note" value="1" />
    <input type="hidden" name="lc" value="US" />
    <input type="hidden" name="currency_code" value="USD" />
    <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynow_LG.gif:NonHostedGuest" />
    <input type="hidden" name="amount" value="<?php echo $productunit_price * 1.05;?>"  />
    <input type="hidden" name="quantity" value="<?php echo $product_quantity;?>"  />
    <input type="hidden" name="first_name" value="<?php echo $customer_first_name;?>"  />
    <input type="hidden" name="last_name" value="<?php echo $customer_last_name;?>"  />
    <input type="hidden" name="notify_url" value="http://mywebsite.com/payments.php"  />
    <input type="hidden" name="payer_email" value="<?php echo $customer_email;?>"  />
    <input type="hidden" name="item_name" value="<?php echo $service_name;?> (<?php echo $product_name;?>)" / >
    <input type="hidden" name="custom" value="<?php echo $orderalias.",".$_SESSION["user_id"];?>" / >
    <input type="image"  value="Submit Payment" src="imgs/proceed_btn.jpg"/>
</form>

Payments.php中的php代码如下:

<?php
// PayPal settings
$paypal_email = 'mypaypalid@gmail.com';
$return_url = 'http://mywebsite.com/thankyou.php?payment=1';
$cancel_url = 'http://mywebsite.com/orders.php';
$notify_url = 'http://mywebsite.com/payments.php';

if (!isset($_POST["txn_id"]) && !isset($_POST["txn_type"])){
    // Firstly Append paypal account to querystring
    $querystring .= "?business=".urlencode($paypal_email)."&";  
    //loop for posted values and append to querystring
    foreach($_POST as $key => $value){
        $value = urlencode(stripslashes($value));
        $querystring .= "$key=$value&";
    }
    // Append paypal return addresses
    $querystring .= "return=".urlencode(stripslashes($return_url))."&";
    $querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
    $querystring .= "notify_url=".urlencode($notify_url);   
    // Redirect to paypal IPN
    header('location:https://www.paypal.com/cgi-bin/webscr'.$querystring);
    exit();
}else{

    // read the post from PayPal system and add 'cmd'
    $req = 'cmd=_notify-validate';
    foreach ($_POST as $key => $value) {
        $value = urlencode(stripslashes($value));
        $value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);// IPN fix
        $req .= "&$key=$value";
    }

    // assign posted variables to local variables
    $data['item_name']          = $_POST['item_name'];
    $data['item_number']        = $_POST['item_number'];
    $data['payment_status']     = $_POST['payment_status'];

    $data['payment_amount']     = $_POST['mc_gross'] * 0.95;
    $data['payment_currency']   = $_POST['mc_currency'];
    $data['txn_id']             = $_POST['txn_id'];
    $data['receiver_email']     = $_POST['receiver_email'];
    $data['payer_email']        = $_POST['payer_email'];

    $data['custom']             = $_POST['custom'];
    $separatedata = explode(",",$data["custom"]);
    $orderalias = $separatedata[0];
    $user = $separatedata[1];

    if($data['payment_status']=="Completed" ){  
        // do my stuff here         
    }else{
        // do my stuff here
    }       
}
?>

这是打开 PayPal帐户(可选)的方法:

转到http://www.paypal.com/并登录到您的帐户。

点击页面顶部附近的个人资料。 点击我的销售工具。 在“在线销售”下,单击“网站偏好设置”附近的“更新”。 在页面底部附近的“可选的PayPal帐户”下选择“打开”。 单击保存。 这是关闭PayPal帐户(可选)的方法:

转到http://www.paypal.com/并登录到您的帐户。 点击页面顶部附近的个人资料。 点击我的销售工具。 单击“网站偏好设置”附近的更新。 在页面底部附近的“可选的PayPal帐户”下选择“关闭”。 点击保存

启用Paypal专业版业务并使用DoDirectPayment API。 下面是简单的DoDirectPayment代码。

$infos = array(
            'METHOD' => 'DoDirectPayment', 
            'USER' => $paypal_pros_username, 
            'PWD' => $paypal_pros_password, 
            'SIGNATURE' => $paypal_pros_signature, 
            'VERSION' => urlencode('115'), 
            'PAYMENTACTION' => $_POST['paypal_pros_transaction_type'],
            'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
            'CREDITCARDTYPE' => $_POST['creditCardType'], 
            'ACCT' => $_POST['creditCardNumber'],
            'EXPDATE' => $_POST['expDateMonth'].$_POST['expDateYear'],
            'CVV2' => $_POST['cvv2Number'], 
            //'EMAIL' => $_POST['email'], 
            'FIRSTNAME' => $_POST['firstName'], 
            'LASTNAME' => $_POST['lastName'], 
            'STREET' => $_POST['address1'], 
            'CITY' => $_POST['city'], 
            'STATE' => $_POST['state'],                     
            'ZIP' => $_POST['zip'], 
            'COUNTRYCODE' => $_POST['country'], 
            'AMT' => $_POST['amount'], 
            'CURRENCYCODE' => $_POST['PayPal_pros_curency'], 
            'DESC' => $_POST['paypal_pro_desc'], 
            'NOTIFYURL' => 'https://website.com/ipn.php'
            );

// Loop through $infos array to generate the NVP string.
$nvp_string = '';
foreach($infos as $var=>$val)
{
    $nvp_string .= '&'.$var.'='.urlencode($val);    
}

// Send NVP string to PayPal and store response
// Set the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $strPurchaseURL);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    // Turn off the server and peer verification (TrustManager Concept).
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvp_string);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);


// Get response from the server.
$result = curl_exec($ch);

// Parse the API response
parse_str($result, $output);

    if(array_key_exists('ACK', $output)){

print_r($output);

            if($output['ACK']=="Success"){
                //Success email
                }
            elseif($output['ACK']=="Failure"){

                }
            else {
                echo 'There is any error! Please go back and try again.';
                }   
        }
    else {
        echo 'There is any error! Please go back and try again.';
        }

暂无
暂无

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

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