2016-12-27 20 views
0

Я реализует 2c2p оплаты АФИ в пользовательских Друпал module.The ошибка показывает, какКак интегрировать 2c2p платеж api в модуль drupal?

9002: авторизация платежа не удалось.

в URL

https://demo2.2c2p.com/2C2PFrontEnd/RedirectV3/payment/Error?result=9002&result_desc=Payment%20authorization%20failed.

и вот мой код для отправки.

$controller_data = $payment->method->controller_data; 

// Get settings from controller data. 
$merchant_id = $controller_data['msp_2c2p_id']; 
$secret_key = $controller_data['msp_2c2p_secret']; 
$url = $controller_data['msp_2c2p_mode']; 
$version = $controller_data['msp_2c2p_version']; 
$version = '6.7'; 
$payment_description = 'test payment'; 
$order_id = '00000000010000091203'; 
$invoice_no = $payment->pid; 
$currency = '840'; //840 = USD, 104 = MMK 
$customer_email = '[email protected]'; 
$pay_category_id = ''; // (Optional) Merchant’s predefined payment category code for reporting purpose. Merchant can manage predefined codes from the my.2c2p interface, section merchant report. ACCOUNT => Options => Predefined References Use PAYCATEGORYID value from “Ref Code” column to show “Reference Name” in the homepage sales volume graph. 
$promotion = 'PROMO_VC'; 
$user_defined_1 = 'test1'; 
$user_defined_2 = 'test2'; 
$user_defined_3 = 'test3'; 
$user_defined_4 = 'test4'; 
$user_defined_5 = 'test5'; 
$result_url_1 = url(MSP_2C2P_PAYMENT_RETURN_PATH 
      . '/' . $payment->pid, array('absolute' => TRUE)); 
$result_url_2=url(MSP_2C2P_PAYMENT_RETURN_PATH 
      . '/' . $payment->pid, array('absolute' => TRUE)); 
$enable_store_card = 'N'; 
$stored_card_unique_id = '';//(Optional) Mandatory when payment is made by stored card 
$pan_masked = ''; 
$request_3ds = 'Y';    //(Optional) Y – Do 3ds (default) F – Force 3ds (Only ECI 02/05 are accepted) N - Do not do 3ds 
$recurring = 'N';     //(Optional) N – Not recurring (default) Y – Recurring transaction 
$order_prefix = '';    //Note: if it is recurring payment, it is mandatory. 
$recurring_amount = '000000199900'; //Example: THB (764) 
$allow_accumulate = 'N';   //N – Not allow Y – Allow accumulate Note: if it is recurring payment, it is mandatory. 
$max_accumulate_amount = '000000199900';//Note: if it is recurring payment, it is mandatory. 
$recurring_interval = '';  //Note: If it is recurring payment, it is mandatory if charge_on_date is blank. 
$recurring_count = '';   //Note: If it is recurring payment, it is mandatory 
$charge_next_date = '';   //Note: If it is recurring payment, it is mandatory 
$charge_on_date = '';   //Note: If it is recurring payment, either charge_on_date or recurring_interval is mandatory 
$payment_option = 'A';   //By default, all available options (A) will be shown. 
$ipp_interest_type = 'A';   //By default, all available options (A) will be shown 
$payment_expiry = '';   //By default, 1-2-3 system will set the expiry according to merchant configuration. 
$default_lang = 'en';    //ja – Japanese th – Thailand en – English (default) 
$statement_descriptor = 'A23';  //Only allows alphanumeric in latin character 

/** 
* Calculate amount to pay. 
*/ 
$amount = 0; 
foreach ($payment->line_items as $line_item) { 
    $amount += (1 + $line_item->tax_rate) * $line_item->amount 
      * $line_item->quantity; 
} 

$payment_data = array(
    //'amount' => $amount, 
    'amount' => '000000000100', 
    'description' => $payment->description, 
); 
$amount = $payment_data['amount']; 

и

$strSignatureString = $version . $merchant_id . $payment_description . $order_id . $invoice_no . $currency . $amount . $customer_email . $pay_category_id . $promotion . $user_defined_1 . $user_defined_2 . $user_defined_3 . $user_defined_4 . $user_defined_5 . $result_url_1 . $result_url_2 . $enable_store_card . $stored_card_unique_id . $pan_masked . $request_3ds . $recurring . $order_prefix . $recurring_amount . $allow_accumulate . $max_accumulate_amount . $recurring_interval . $recurring_count . $charge_next_date . $charge_on_date . $payment_option . $ipp_interest_type . $payment_expiry . $default_lang . $statement_descriptor; 

$data = array(
    'version' => $version, 
    'merchant_id' => $merchant_id, 
    'payment_description' =>$payment_description, 
    'order_id' => $order_id, 
    'invoice_no' => $invoice_no, 
    'currency' => $currency, 
    'amount' => $amount, 
    'customer_email' => $customer_email, 
    'pay_category_id' => $pay_category_id, 
    'promotion' => $promotion, 
    'user_defined_1' => $user_defined_1, 
    'user_defined_2' => $user_defined_2, 
    'user_defined_3' => $user_defined_3, 
    'user_defined_4' => $user_defined_4, 
    'user_defined_5' => $user_defined_5, 
    'result_url_1' => $result_url_1, 
    'result_url_2' => $result_url_2, 
    'enable_store_card' => $enable_store_card, 
    'stored_card_unique_id' => $stored_card_unique_id, 
    'pan_masked' => $pan_masked, 
    'request_3ds' => $request_3ds, 
    'recurring' => $recurring, 
    'order_prefix' => $order_prefix, 
    'recurring_amount' => $recurring_amount, 
    'allow_accumulate' => $allow_accumulate, 
    'max_accumulate_amount' => $max_accumulate_amount, 
    'recurring_interval' => $recurring_interval, 
    'recurring_count' => $recurring_count, 
    'charge_next_date' => $charge_next_date, 
    'charge_on_date' => $charge_on_date, 
    'payment_option' => $payment_option, 
    'ipp_interest_type' => $ipp_interest_type, 
    'payment_expiry' => $payment_expiry, 
    'default_lang' => $default_lang, 
    'statement_descriptor' => $statement_descriptor, 
    'hash_value' => strtoupper(hash_hmac('sha1', $strSignatureString, $secret_key, false)), 
); 



$form['#action'] = $url; 
//$form['#action'] = 'http://msp_2c2p.dd:8083/2c2ptest.php'; 
foreach($data as $name => $value) { 
    if (!empty($value)) { 
    $form[$name] = array('#type' => 'hidden', '#value' => $value); 
    } 
} 
$form['actions'] = array('#type' => 'actions'); 
$form['actions']['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('Pay with 2c2p'), 
); 

return $form; 

}

Есть ли неправильно в моих кодов? Мы следуем кулисных 2c2p developer doc и doc2 Спасибо заранее.

ответ

0

9002 - несоответствие значения хэш-функции.

https://developer.2c2p.com/docs/codes-dir

Пожалуйста, проверьте $strSignatureString и $secret_key.

Пожалуйста, проверьте на https://developer.2c2p.com/docs/payment-request-dir

+0

братана, я могу прошел now.The проблемы с торговым счетом и секретным ключом, и я просил, чтобы создать торговый счет для me.thanks, кстати, я должен проверить с реальным MPU или кредитом учетную запись для оплаты в демонстрационном режиме или любую пробную версию mpu или кредитную учетную запись для демонстрационного режима? Для проверки ответа от 2c2p. –

+0

Вы можете протестировать реальную карту в демонстрационном режиме. – saturngod