From 8a67500a4af945edd4a97b198be6dbe4cf54154a Mon Sep 17 00:00:00 2001 From: vSchoener Date: Thu, 27 Oct 2011 15:15:30 +0000 Subject: [PATCH] [+] MO : Uptdate module to store payment cc information git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9683 b9a71923-0436-4b27-9f14-aed3839534dd --- modules/cashticket/cashticket.php | 15 ++++++++++++ modules/cashticket/payment.php | 6 +++-- modules/dibs/dibs.php | 37 ++++++++++++++++++++++++++++- modules/dibs/validation.php | 13 ++++++---- modules/paysafecard/payment.php | 6 ++++- modules/paysafecard/paysafecard.php | 16 +++++++++++++ 6 files changed, 85 insertions(+), 8 deletions(-) diff --git a/modules/cashticket/cashticket.php b/modules/cashticket/cashticket.php index b00591e7f..6f1e5f134 100644 --- a/modules/cashticket/cashticket.php +++ b/modules/cashticket/cashticket.php @@ -123,5 +123,20 @@ class CashTicket extends PrepaidServices return $error_msg[$error_code]; } + + /** + * Set the detail of a payment - Call before the validate order init + * correctly the pcc object + * See Authorize documentation to know the associated key => value + * @param array fields + */ + public function setTransactionDetail($response) + { + // If Exist we can store the details + if (isset($this->pcc)) + { + $this->pcc->transaction_id = (string)$response['transaction_id']; + } + } } diff --git a/modules/cashticket/payment.php b/modules/cashticket/payment.php index 9ff3d3151..bfc487bcd 100644 --- a/modules/cashticket/payment.php +++ b/modules/cashticket/payment.php @@ -88,8 +88,10 @@ if ($state != Configuration::get('PS_OS_ERROR')) } } - -$module->validateOrder((int)($cart->id), $state, (float)($cart->getOrderTotal(true, Cart::BOTH)), $module->displayName, $message, NULL, (int)($currency->id), false, $cart->secure_key); +$module->setTransactionDetail(array( + 'transaction_id', $disposition['mtid'])); +$module->validateOrder((int)($cart->id), $state, (float)($cart->getOrderTotal(true, Cart::BOTH)), + $module->displayName, $message, NULL, (int)($currency->id), false, $cart->secure_key); if ($state == Configuration::get('PS_OS_ERROR')) { diff --git a/modules/dibs/dibs.php b/modules/dibs/dibs.php index 075e21f97..aa27f64c0 100644 --- a/modules/dibs/dibs.php +++ b/modules/dibs/dibs.php @@ -25,6 +25,14 @@ * International Registered Trademark & Property of PrestaShop SA */ +function debugLog($content) +{ + ob_start(); + var_dump($content); + $result = ob_get_clean(); + file_put_contents(dirname(__FILE__).'/logTest.log', $result, FILE_APPEND); +} + if (!defined('_PS_VERSION_')) exit; @@ -73,7 +81,7 @@ class dibs extends PaymentModule * @var array */ private static $accepted_lang = array('da','en','es','fi','fo','fr','it','nl','no','pl','sv'); - + /** * Formular link to DIBS subscription * @var array @@ -404,4 +412,31 @@ class dibs extends PaymentModule $this->context->smarty->assign('logo_color', self::$MORE_SETTINGS['logo_color']); return $this->display(__FILE__, 'dibs.tpl'); } + + /** + * Set the detail of a payment to prepare the validate order + * See Authorize documentation to know the associated key => value + * @param array fields + * @return bool success state + */ + public function setTransactionDetail($response) + { + // If Exist we can store the details + if (isset($this->pcc)) + { + $this->pcc->transaction_id = (string)$response['transact']; + + // 50 => Card number (XXXX0000) + $this->pcc->card_number = (string)substr($response['cardnomask'], -4); + + // 51 => Card Mark (Visa, Master card) + $this->pcc->card_brand = (string)$response['paytype']; + + $this->pcc->card_expiration = '0000'; + + // 68 => Owner name + $this->pcc->card_holder = ''; + } + + } } diff --git a/modules/dibs/validation.php b/modules/dibs/validation.php index b50778a07..2ddda5379 100644 --- a/modules/dibs/validation.php +++ b/modules/dibs/validation.php @@ -1,5 +1,5 @@ validateOrder((int)$posted_values['orderid'], Configuration::get('PS_OS_PAYMENT'), (float)((int)$posted_values['amount'] / 100), $obj_dibs->displayName, $message, array(), NULL, false, $secure_cart[2]); - if ($valid_order === false) - $obj_dibs->validateOrder((int)$posted_values['orderid'], Configuration::get('PS_OS_ERROR'), 0, $obj_dibs->displayName, $message, array(), NULL, false, $secure_cart[2]); + { + $obj_dibs->setTransactionDetail($posted_values); + $obj_dibs->validateOrder((int)$posted_values['orderid'], Configuration::get('PS_OS_PAYMENT'), + (float)((int)$posted_values['amount'] / 100), $obj_dibs->displayName, $message, array(), NULL, false, $secure_cart[2]); + } + else if ($valid_order === false) + $obj_dibs->validateOrder((int)$posted_values['orderid'], Configuration::get('PS_OS_ERROR'), 0, $obj_dibs->displayName, + $message, array(), NULL, false, $secure_cart[2]); } \ No newline at end of file diff --git a/modules/paysafecard/payment.php b/modules/paysafecard/payment.php index 2d4081725..ae8a4cd4d 100644 --- a/modules/paysafecard/payment.php +++ b/modules/paysafecard/payment.php @@ -84,7 +84,11 @@ if ($state != Configuration::get('PS_OS_ERROR')) } } -$module->validateOrder((int)($cart->id), $state, (float)($cart->getOrderTotal(true, Cart::BOTH)), $module->displayName, $message, NULL, (int)($currency->id), false, $cart->secure_key); +$module->setTransactionDetail(array( + 'transaction_id', $disposition['mtid'])); + +$module->validateOrder((int)($cart->id), $state, (float)($cart->getOrderTotal(true, Cart::BOTH)), + $module->displayName, $message, NULL, (int)($currency->id), false, $cart->secure_key); if ($state == Configuration::get('PS_OS_ERROR')) { diff --git a/modules/paysafecard/paysafecard.php b/modules/paysafecard/paysafecard.php index 7d135459c..2915172fe 100644 --- a/modules/paysafecard/paysafecard.php +++ b/modules/paysafecard/paysafecard.php @@ -123,5 +123,21 @@ class PaysafeCard extends PSCPrepaidServices return $error_msg[$error_code]; } + + /** + * Set the detail of a payment - Call before the validate order init + * correctly the pcc object + * See Authorize documentation to know the associated key => value + * @param array fields + */ + public function setTransactionDetail($response) + { + // If Exist we can store the details + if (isset($this->pcc)) + { + $this->pcc->transaction_id = (string)$response['transaction_id']; + } + } + }