【问题标题】:Paypal Accept Credit CardPaypal 接受信用卡
【发布时间】:2014-01-25 01:08:37
【问题描述】:

我有一个网站,我有一个 Paypal 商业帐户(在英国注册)。贝宝已与我的网站集成,并且运行良好。当用户点击“Proceed To Pay”时,用户将被带到 Paypal 的网站(截图如下)。现在我对这个程序的唯一问题是客户必须先创建一个 Paypal 帐户才能向我付款。我对 Paypal 提供的所有选项(标准、专业、商家等)感到困惑,我不确定我到底做错了什么。

Screenshot http://ascensionnexus.com/Capture.jpg

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

编辑

我的确认订单页面上的 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
    }       
}
?>

【问题讨论】:

  • This link 可能有用,在 PayPal 网站上搜索“直接付款”
  • 另一个关于“无注册付款”的链接here。请注意,功能仅适用于 Premier 和 Business 帐户持有人
  • FDL,我的是企业帐户。
  • 您使用哪种支付方式?
  • 我已经编辑了我的问题,添加了我正在使用的代码。我实际上不确定您所说的付款方式是什么意思。我希望代码对所有人都有帮助。

标签: php paypal credit-card


【解决方案1】:

以下是开启可选PayPal帐户的方法:

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

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

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

【讨论】:

    【解决方案2】:

    启用 paypal pro 业务并使用 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.';
            }
    

    【讨论】:

      猜你喜欢
      • 2019-09-10
      • 1970-01-01
      • 2015-07-14
      • 2014-01-22
      • 1970-01-01
      • 2013-02-06
      • 2021-10-23
      • 2021-04-26
      • 2019-02-13
      相关资源
      最近更新 更多