Проверка с Cardsave 3D безопасным
Кто-нибудь успешно интегрировал Cardsave, используя CI-Merchant и 3D Secure?
Теперь мне удалось заставить 3D Secure отвечать на мой веб-сайт (может показаться, что вам нужно добавить 'return_url' в качестве параметра к параметрам для всех, у кого возникли проблемы), но транзакции всегда возвращаются как неудачные, используя либо реальная карта или тестовая 3D-карта безопасности с успешной авторизацией.
К сожалению, на сайте CI-Merchant нет документации по драйверу Cardsave, только пример для Paypal.
Неудачные транзакции нигде не отображаются в моей учетной записи Cardsave, поэтому я даже не уверен, общается ли CI-Merchant с Cardsave в этот момент.
Вот пример кода, который я использую для теста:
public function test_live_payment()
{
$this->load->library('merchant');
$creditcard = $this->input->post('creditcard');
$creditcardtype = $this->input->post('creditcardtype');
$cardmonth = $this->input->post('cardmonth');
$cardyear = $this->input->post('cardyear');
$cardsecurecode = $this->input->post('cardsecurecode');
$cardnameon = $this->input->post('cardnameon');
$address1 = $this->input->post('address1');
$address2 = $this->input->post('address2');
$city = $this->input->post('city');
$postcode = $this->input->post('postcode');
$data['status'] = '';
$data['message'] = '';
$test = TRUE;
if ($test) :
$settings = array (
'merchant_id' => 'TEST ACCOUNT',
'password' => 'XXXX'
);
else :
$settings = array (
'merchant_id' => 'LIVE ACCOUNT',
'password' => 'XXXX'
);
endif;
if ($_POST) :
$this->merchant->load('cardsave');
$this->merchant->initialize($settings);
$data['transaction_id'] = '999' . rand(1, 999);
$params = array(
'amount' => '1.00',
'currency' => 'GBP',
'card_no' => $creditcard,
'name' => $cardnameon,
'exp_month' => $cardmonth,
'exp_year' => 20 . $cardyear,
'csc' => $cardsecurecode,
'transaction_id' => $data['transaction_id'],
'description' => 'Test payment',
'address1' => $address1,
'address2' => $address2,
'city' => $city,
'postcode' => $postcode,
'return_url' => site_url('/test-payment')
);
$response = $this->merchant->purchase($params);
if ($response->success()) :
$gateway_reference = $response->reference();
$data['status'] = 'Success';
$data['message'] = 'The transaction was successfully processed';
else :
$message = $response->message();
$data['status'] = 'Failed';
if ( ! empty($message)) :
$data['message'] = $message;
else :
$data['message'] = 'Transaction failed. No further details received.';
endif;
endif;
endif;
$this->load->view('test_payment_form', $data);
}
1 ответ
Похоже, что я решил свою собственную проблему: 1. убедившись, что я передаю URL-адрес возврата, и 2. отправив URL-адрес возврата новой функции, включающей функцию purchase_return(). Вот мой полный (тестовый) код:
public function test_live_payment()
{
$this->load->library('merchant');
$creditcard = $this->input->post('creditcard');
$creditcardtype = $this->input->post('creditcardtype');
$cardmonth = $this->input->post('cardmonth');
$cardyear = $this->input->post('cardyear');
$cardsecurecode = $this->input->post('cardsecurecode');
$cardnameon = $this->input->post('cardnameon');
$address1 = $this->input->post('address1');
$address2 = $this->input->post('address2');
$city = $this->input->post('city');
$postcode = $this->input->post('postcode');
$data['status'] = '';
$data['message'] = '';
$test = TRUE;
if ($test) :
$settings = array (
'merchant_id' => 'TEST ACCOUNT',
'password' => 'XXXX'
);
else :
$settings = array (
'merchant_id' => 'LIVE ACCOUNT',
'password' => 'XXXX'
);
endif;
if ($_POST) :
$this->merchant->load('cardsave');
$this->merchant->initialize($settings);
$data['transaction_id'] = '999' . rand(1, 999);
$data['transaction_id'] = '999' . rand(1, 999);
$newdata = array(
'transaction_id' => $data['transaction_id']
);
$this->session->set_userdata($newdata);
$params = array(
'amount' => '1.00',
'currency' => 'GBP',
'card_no' => $creditcard,
'name' => $cardnameon,
'exp_month' => $cardmonth,
'exp_year' => 20 . $cardyear,
'csc' => $cardsecurecode,
'transaction_id' => $data['transaction_id'],
'description' => 'Test payment',
'address1' => $address1,
'address2' => $address2,
'city' => $city,
'postcode' => $postcode,
'return_url' => site_url('/test-payment-response')
);
$response = $this->merchant->purchase($params);
if ($response->success()) :
$gateway_reference = $response->reference();
$data['status'] = 'Success';
$data['message'] = 'The transaction was successfully processed';
else :
$message = $response->message();
$data['status'] = 'Failed';
if ( ! empty($message)) :
$data['message'] = $message;
else :
$data['message'] = 'Transaction failed. No further details received.';
endif;
endif;
endif;
$this->load->view('test_payment_form', $data);
}
public function test_response()
{
$settings = array (
'merchant_id' => 'TEST ACCOUNT',
'password' => 'XXXX'
);
$this->load->library('merchant');
$this->merchant->load('cardsave');
$this->merchant->initialize($settings);
$data['transaction_id'] = $this->session->userdata('transaction_id');
$params = array(
'amount' => '1.00',
'currency' => 'GBP',
'transaction_id' => $data['transaction_id']
);
$response = $this->merchant->purchase_return($params);
if ($response->success()) :
$gateway_reference = $response->reference();
$data['status'] = 'Success';
$data['message'] = 'The transaction was successfully processed';
else :
$message = $response->message();
$data['status'] = 'Failed';
if ( ! empty($message)) :
$data['message'] = $message;
else :
$data['message'] = 'Transaction failed. No further details received.';
endif;
endif;
$this->load->view('test_payment_form', $data);
}