[英]switching from sandbox to paypal live
從沙盒切換到實時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
)
控制器:
<?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。您應在帳戶中啟用PayPal Payment Pro。 您可以嘗試執行以下操作:
打開您的developer.paypal.com帳戶。
打開應用程序以訪問您的帳戶。
單擊您要升級到Payment Pro的帳戶。
單擊配置文件,在對話框中找到選項升級到專業版。
如果它適用於您的沙盒,對我來說似乎是一個帳戶問題。
對於帳戶問題,我建議您與PayPal( http://www.paypal.com的底部)聯系,他們將找到合適的團隊為您提供支持。
即使以后發現技術問題,他們也會要求商人技術服務提供支持。 但是,我再次認為這是帳戶問題。 他們將指導您完成必要的過程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.