php - 从沙盒切换到 paypal live

标签 php codeigniter paypal

从沙箱切换到实时 paypal 时出现以下错误。请帮助我解决此错误。

Array
(
    [TIMESTAMP] => 2015-06-10T01:59:03Z
    [CORRELATIONID] => 4ce24a1abd742
    [ACK] => Failure
    [VERSION] => 85.0
    [BUILD] => 16770825
    [L_ERRORCODE0] => 10501
    [L_SHORTMESSAGE0] => Invalid Configuration
    [L_LONGMESSAGE0] => This transaction cannot be processed due to an invalid merchant configuration.
    [L_SEVERITYCODE0] => Error
    [AMT] => 555.00
    [CURRENCYCODE] => USD
)

Controller :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Checkout extends CI_Controller {


public function direct_payment() {

$item = $this->session->userdata['item_data']['item'];

$price = $this->session->userdata['item_data']['price'];

$quantity = $this->session->userdata['item_data']['quantity'];

$card_type = $this->input->post('card_type');

$card_fname = $this->input->post('card_fname');

$card_lname = $this->input->post('card_lname');

$creditcard_number = $this->input->post('creditcard_number');

$crd_month=$this->input->post('crd_month');

$crd_year=$this->input->post('crd_year');

$security_code=$this->input->post('security_code'); 

//$order_id  = $this->payment_model->save_order();

$respounse  = $this->payment_model->do_direct_payment($card_type,$card_fname,$card_lname,$creditcard_number,$crd_month,$crd_year,$security_code); 

echo '<pre>';

print_r($respounse);

exit;

if($respounse['ACK'] == 'SuccessWithWarning' or $respounse['ACK']== 'Success' or $respounse['ACK']== 'Pending') {

    //$this->db->update('orders', array('order_status'=>'New', 'transaction_id'=>$respounse['TRANSACTIONID'], 'payment_type' =>'Credit Card', 

    //'payment_status' =>$respounse['ACK'],'payment_recevied'=>$respounse['AMT'], 'payment_symbol'=>$respounse['CURRENCYCODE']), array('id'=> $order_id));

    //$this->cart->destroy();

    //$this->session->set_userdata(array(

    //'last_id'=> $order_id,'transaction'=>$respounse['TRANSACTIONID']));

    $this->session->set_flashdata("succes","Your Order is succesfully placed.");

    redirect("contents/credit");

    } else {

    //$this->db->update('orders', array('order_status'=>'Failed', 'payment_type' =>'Credit Card', 

    //'payment_status' =>$respounse['ACK']), array('id'=> $order_id));

    $this->session->set_flashdata("error","Error occur in your payment transacion.");

    redirect("contents/credit");        

    }   

    }

}

型号:

class payment_model extends CI_Model {

function do_direct_payment($card_type,$card_fname,$card_lname,$creditcard_number,$crd_month,$crd_year,$security_code) {

    $sandbox = TRUE;
    // Set PayPal API version and credentials.

    $api_version = '85.0';

    $api_endpoint = ($sandbox == 0 )? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';

    $api_username = ($sandbox == 0) ? '------' : '-------';

    $api_password = ($sandbox == 0) ? '-------' : '------';

    $api_signature =  ($sandbox == 0) ? '--------' : '-------';

    $request_params = array (
        'METHOD' => 'DoDirectPayment', 
        'USER' => $api_username, 
        'PWD' => $api_password, 
        'SIGNATURE' => $api_signature, 
        'VERSION' => $api_version, 
        'PAYMENTACTION' => 'Sale',                  
        'IPADDRESS' => $_SERVER['REMOTE_ADDR'],
        'CREDITCARDTYPE' => $card_type, 
        'ACCT' => $creditcard_number,                       
        'EXPDATE' => $crd_month.$crd_year,          
        'CVV2' => $security_code, 
        'FIRSTNAME' => 'ibad', 
        'LASTNAME' => 'anjum', 
        'STREET' => '11 gg', 
        'CITY' => 'peshawar', 
        'STATE' => 'state',                     
        'COUNTRYCODE' => 'PK', 
        'ZIP' => '10200', 
        'EMAIL' => '-----',
        'AMT' => 555, 
        '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);    
    }

    // 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);
    //print_r($result);

    return $result_array = $this->NVPToArray($result);
}

public function NVPToArray($NVPString) {
    $proArray = array();
    while(strlen($NVPString)) {
        // name
        $keypos= strpos($NVPString,'=');
        $keyval = substr($NVPString,0,$keypos);
        // value
        $valuepos = strpos($NVPString,'&') ? strpos($NVPString,'&'): strlen($NVPString);
        $valval = substr($NVPString,$keypos+1,$valuepos-$keypos-1);
        // decoding the respose
        $proArray[$keyval] = urldecode($valval);
        $NVPString = substr($NVPString,$valuepos+1,strlen($NVPString));
    }
    return $proArray;
}   

}

最佳答案

根据文档,错误代码 10501当结算协议(protocol)被禁用或不活动时发生。您应该在您的帐户中启用您的 PayPal Payment Pro。 您可以尝试执行以下操作::

  • 打开您的 developer.paypal.com 帐户。

  • 打开应用程序以访问您的帐户。

  • 单击您要升级到 Payment Pro 的帐户。

  • 单击“配置文件”以在对话框中找到“升级到专业版”选项。

关于php - 从沙盒切换到 paypal live,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30745999/

相关文章:

php - 如何防止服务器端从非预期来源接收数据

php - 如何编写子查询子查询多行父查询单行返回

Paypal 自适应付款接收方限制 1-5

paypal - PayPal的CUSTOM变量可以在eBay上使用吗?

php - Wordpress 我怎么知道分页是否处于事件状态?

php time() 与 mktime() 当前时间戳

php - 如何在 codeigniter 中发送多个具有相同名称属性的选择框值

php - MySQL PHP - SELECT WHERE id = 多维数组

paypal - 为什么使用 Paypal 付款后,我的商店页面显示为空白?

php - Codeigniter 中的枚举:未定义的属性:ProjectStatus_Enum::$Open