Version Notes
Première version de l'extension.
Implémente le paiement simple, le paiement différé et le paiement avec validation.
Download this release
Release Info
| Developer | Smile Buyster |
| Extension | Buyster_Buyster |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Buyster/Buyster/Block/Redirect.php +12 -0
- app/code/community/Buyster/Buyster/Block/System/Config/Form/Field/Label.php +16 -0
- app/code/community/Buyster/Buyster/Helper/Data.php +322 -0
- app/code/community/Buyster/Buyster/Model/Observer.php +401 -0
- app/code/community/Buyster/Buyster/Model/Order/Config.php +67 -0
- app/code/community/Buyster/Buyster/Model/Service.php +192 -0
- app/code/community/Buyster/Buyster/Model/Service/Message/Abstract.php +28 -0
- app/code/community/Buyster/Buyster/Model/Service/Payment/Cashmanagement/Request.php +110 -0
- app/code/community/Buyster/Buyster/Model/Service/Payment/Cashmanagement/Response.php +13 -0
- app/code/community/Buyster/Buyster/Model/Service/Payment/Initialize/Request.php +79 -0
- app/code/community/Buyster/Buyster/Model/Service/Payment/Initialize/Response.php +12 -0
- app/code/community/Buyster/Buyster/Model/Standard.php +692 -0
- app/code/community/Buyster/Buyster/Model/System/Config/Source/Order/Status.php +52 -0
- app/code/community/Buyster/Buyster/Model/System/Config/Source/Order/Status/Final.php +28 -0
- app/code/community/Buyster/Buyster/Model/System/Config/Source/Paymenttype.php +37 -0
- app/code/community/Buyster/Buyster/Model/System/Config/Source/Serviceurl.php +34 -0
- app/code/community/Buyster/Buyster/controllers/PaymentController.php +169 -0
- app/code/community/Buyster/Buyster/etc/config.xml +214 -0
- app/code/community/Buyster/Buyster/etc/system.xml +217 -0
- app/code/community/Buyster/Buyster/sql/buyster_setup/mysql4-install-0.0.1.0.php +42 -0
- app/code/community/Buyster/Buyster/sql/buyster_setup/mysql4-upgrade-0.0.1.0-0.0.1.1.php +33 -0
- app/design/adminhtml/default/default/layout/buyster.xml +19 -0
- app/design/frontend/base/default/layout/buyster.xml +25 -0
- app/design/frontend/base/default/template/buyster/redirect.phtml +34 -0
- app/etc/modules/Buyster_Buyster.xml +20 -0
- app/locale/en_US/Buyster_Buyster.csv +2 -0
- app/locale/fr_FR/Buyster_Buyster.csv +50 -0
- package.xml +21 -0
- skin/adminhtml/default/default/buyster.css +10 -0
- skin/adminhtml/default/default/images/buyster/buyster_logo.png +0 -0
- skin/frontend/base/default/css/buyster.css +22 -0
- skin/frontend/base/default/images/buyster/buyster_logo.png +0 -0
app/code/community/Buyster/Buyster/Block/Redirect.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster Redirect Block
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Block_Redirect extends Mage_Core_Block_Template
|
| 11 |
+
{
|
| 12 |
+
}
|
app/code/community/Buyster/Buyster/Block/System/Config/Form/Field/Label.php
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster system config label Block
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Block_System_Config_Form_Field_Label extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 11 |
+
{
|
| 12 |
+
protected function _getElement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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster helper
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Helper_Data extends Mage_Payment_Helper_Data
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Return currencies supported by Buyster
|
| 14 |
+
* Defined in config.xml
|
| 15 |
+
* Keys are Magento values
|
| 16 |
+
* Values are Buyster values
|
| 17 |
+
* Example with euro only: array('EUR', 978)
|
| 18 |
+
*
|
| 19 |
+
* @return array
|
| 20 |
+
*/
|
| 21 |
+
public function getSupportedCurrencies()
|
| 22 |
+
{
|
| 23 |
+
return Mage::getConfig()->getNode('global/buyster/supported_currencies')->asArray();
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* Converts Magento price to cents
|
| 28 |
+
* Basically multiply by 100
|
| 29 |
+
*
|
| 30 |
+
* @param float $price Price from Magento
|
| 31 |
+
*
|
| 32 |
+
* @return int
|
| 33 |
+
*/
|
| 34 |
+
public function getBuysterPrice($price)
|
| 35 |
+
{
|
| 36 |
+
return (string) ($price * 100.0);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Depends of transaction_type value
|
| 41 |
+
* if 'payment' => return '' (empty string)
|
| 42 |
+
* if 'paymentDelayed' => return 'captureDelay=N' , and N stands for capture_delay config value
|
| 43 |
+
* if 'paymentValidation' => return 'validationDelay=N' , and N stands for validation_delay config value
|
| 44 |
+
* => This method is used to store data when transaction is created
|
| 45 |
+
*
|
| 46 |
+
* @return string Parameter used in SOAP web service call
|
| 47 |
+
*/
|
| 48 |
+
public function getTransactionParameters()
|
| 49 |
+
{
|
| 50 |
+
$transactionParameters = '';
|
| 51 |
+
$transactionType = $this->getTransactionType();
|
| 52 |
+
|
| 53 |
+
if ($transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_DELAYED) {
|
| 54 |
+
|
| 55 |
+
$captureDelay = Mage::getStoreConfig('payment/buyster/capture_delay');
|
| 56 |
+
if ($captureDelay == '') {
|
| 57 |
+
Mage::log(
|
| 58 |
+
'payment/buyster/capture_delay config parameter should not be empty',
|
| 59 |
+
Zend_Log::WARN,
|
| 60 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 61 |
+
);
|
| 62 |
+
}
|
| 63 |
+
$transactionParameters = 'captureDelay=' . (string)$captureDelay . ';';
|
| 64 |
+
|
| 65 |
+
} else if ($transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION) {
|
| 66 |
+
|
| 67 |
+
$validationDelay = Mage::getStoreConfig('payment/buyster/validation_delay');
|
| 68 |
+
if ($validationDelay == '') {
|
| 69 |
+
Mage::log(
|
| 70 |
+
'payment/buyster/validation_delay config parameter should not be empty',
|
| 71 |
+
Zend_Log::WARN,
|
| 72 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 73 |
+
);
|
| 74 |
+
}
|
| 75 |
+
$transactionParameters = 'validationDelay=' . (string)$validationDelay . ';';
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return $transactionParameters;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Create transaction raw details array
|
| 83 |
+
* Add detail field for payments with validation
|
| 84 |
+
* => This method is used to store data when transaction is created
|
| 85 |
+
*
|
| 86 |
+
* @see Buyster_Buyster_Model_Standard::_addTransaction
|
| 87 |
+
*
|
| 88 |
+
* @param array $data Data from Buyster server from $_POST, has been validated
|
| 89 |
+
*
|
| 90 |
+
* @return array Transaction details to add to order
|
| 91 |
+
*/
|
| 92 |
+
public function getTransactionRawDetails($data)
|
| 93 |
+
{
|
| 94 |
+
$additionalDetails = array();
|
| 95 |
+
$transactionRawDetails = array();
|
| 96 |
+
|
| 97 |
+
$detailResponseCode = $data->getResponseCode();
|
| 98 |
+
$enrollmentIndicator = $data->getEnrollmentIndicator();
|
| 99 |
+
$guaranteeIndicator = $data->getGuaranteeIndicator();
|
| 100 |
+
$status = $data->getStatus();
|
| 101 |
+
$transactionDateTime = urldecode($data->getTransactionDateTime());
|
| 102 |
+
$transactionType = $this->getTransactionType();
|
| 103 |
+
$transactionParameters = $this->getTransactionParameters();
|
| 104 |
+
|
| 105 |
+
$guaranteeDescription = $this->getGuaranteeDescription($guaranteeIndicator);
|
| 106 |
+
|
| 107 |
+
// Add description field for payments with validation
|
| 108 |
+
if ($this->getTransactionType() == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION)
|
| 109 |
+
{
|
| 110 |
+
$additionalDetails['Description'] = $this->__("Buyster fingerprint");
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
$transactionRawDetails = array(
|
| 114 |
+
'Garantie' => $guaranteeDescription,
|
| 115 |
+
'detailResponseCode' => $detailResponseCode,
|
| 116 |
+
'enrollmentIndicator' => $enrollmentIndicator,
|
| 117 |
+
'guaranteeIndicator' => $guaranteeIndicator,
|
| 118 |
+
'status' => $status,
|
| 119 |
+
'transactionDateTime' => $transactionDateTime,
|
| 120 |
+
'transactionType' => $transactionType,
|
| 121 |
+
'transactionParameters' => $transactionParameters
|
| 122 |
+
);
|
| 123 |
+
|
| 124 |
+
$transactionRawDetails = array_merge($additionalDetails, $transactionRawDetails);
|
| 125 |
+
|
| 126 |
+
return $transactionRawDetails;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/**
|
| 130 |
+
* Return garantee description mapping to $guaranteeIndicator
|
| 131 |
+
* Visible in transaction details attached to order
|
| 132 |
+
*
|
| 133 |
+
* @param string $guaranteeIndicator Guarantee code (Y, N, U or Empty)
|
| 134 |
+
*
|
| 135 |
+
* @return string Guarantee Description
|
| 136 |
+
*/
|
| 137 |
+
public function getGuaranteeDescription($guaranteeIndicator)
|
| 138 |
+
{
|
| 139 |
+
$guaranteeDescription = '';
|
| 140 |
+
|
| 141 |
+
switch ($guaranteeIndicator) {
|
| 142 |
+
case "Y" :
|
| 143 |
+
$guaranteeDescription = $this->__("Buyster guarantee is accepted for this transaction");
|
| 144 |
+
break;
|
| 145 |
+
case "N" :
|
| 146 |
+
$guaranteeDescription = $this->__("Buyster guarantee is refused for this transaction");
|
| 147 |
+
break;
|
| 148 |
+
case "U" :
|
| 149 |
+
$guaranteeDescription = $this->__("Buyster guarantee is not defined for this transaction");
|
| 150 |
+
break;
|
| 151 |
+
case "" :
|
| 152 |
+
$guaranteeDescription = $this->__("Buyster guarantee can not apply to this transaction");
|
| 153 |
+
break;
|
| 154 |
+
default :
|
| 155 |
+
$guaranteeDescription = $this->__("Unknown guarantee indicator");
|
| 156 |
+
break;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
return $guaranteeDescription;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* Return operationParameters used in cashManagementOperation web service method
|
| 164 |
+
* Return format: operationCaptureNewDelay=N;
|
| 165 |
+
* where N is payment/buyster/capture_delay config parameter
|
| 166 |
+
*
|
| 167 |
+
* @return string Parameter used in SOAP web service call
|
| 168 |
+
*/
|
| 169 |
+
public function getOperationParameters()
|
| 170 |
+
{
|
| 171 |
+
$captureDelay = Mage::getStoreConfig('payment/buyster/capture_delay');
|
| 172 |
+
$operationParameters = 'operationCaptureNewDelay=' . (string)$captureDelay . ';';
|
| 173 |
+
|
| 174 |
+
return $operationParameters;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
/**
|
| 178 |
+
* Return current transaction type set in Back Office
|
| 179 |
+
*
|
| 180 |
+
* @return string Current transaction type
|
| 181 |
+
*/
|
| 182 |
+
public function getTransactionType()
|
| 183 |
+
{
|
| 184 |
+
return Mage::getStoreConfig('payment/buyster/payment_type');
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* Return current transaction origin
|
| 189 |
+
*
|
| 190 |
+
* @return string Static transaction origin (default 'Magento')
|
| 191 |
+
*/
|
| 192 |
+
public function getTransactionOrigin()
|
| 193 |
+
{
|
| 194 |
+
return 'Magento';
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
/**
|
| 198 |
+
* Return current customer language
|
| 199 |
+
*
|
| 200 |
+
* @return string Static customer language (default 'fr')
|
| 201 |
+
*/
|
| 202 |
+
public function getCustomerLanguage()
|
| 203 |
+
{
|
| 204 |
+
return 'fr';
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/**
|
| 208 |
+
* Return transaction details for given $transaction
|
| 209 |
+
* at format Buyster_Buyster_Model_Service_Message_Abstract
|
| 210 |
+
* => This method is used to retrieve store data
|
| 211 |
+
*
|
| 212 |
+
* @param Mage_Sales_Model_Order_Payment_Transaction $transaction Current transaction
|
| 213 |
+
*
|
| 214 |
+
* @return Buyster_Buyster_Model_Service_Message_Abstract
|
| 215 |
+
*/
|
| 216 |
+
public function getTransactionDetails($transaction)
|
| 217 |
+
{
|
| 218 |
+
$details = null;
|
| 219 |
+
if ($transaction) {
|
| 220 |
+
$addInfo = $transaction->getAdditionalInformation();
|
| 221 |
+
if (array_key_exists('raw_details_info', $addInfo)) {
|
| 222 |
+
$addInfo = $addInfo['raw_details_info'];
|
| 223 |
+
}
|
| 224 |
+
$details = Mage::getModel('buyster/service_message_abstract');
|
| 225 |
+
$details->addData($addInfo);
|
| 226 |
+
}
|
| 227 |
+
return $details;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
/**
|
| 231 |
+
* Return transaction type set for given order
|
| 232 |
+
*
|
| 233 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 234 |
+
*
|
| 235 |
+
* @return string Transaction type
|
| 236 |
+
*/
|
| 237 |
+
public function getOrderTransactionType($order)
|
| 238 |
+
{
|
| 239 |
+
$transactionType = null;
|
| 240 |
+
if ($order) {
|
| 241 |
+
$payment = $order->getPayment();
|
| 242 |
+
$transaction = $payment->getAuthorizationTransaction();
|
| 243 |
+
|
| 244 |
+
// Load transaction details
|
| 245 |
+
$transactionDetails = $this->getTransactionDetails($transaction);
|
| 246 |
+
if ($transactionDetails) {
|
| 247 |
+
$transactionType = $transactionDetails->getTransactionType();
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
return $transactionType;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
/**
|
| 254 |
+
* Disable invoice feature if paymentType is payment or paymentDelayed
|
| 255 |
+
* In that case, invoice is automatically generated by Cron
|
| 256 |
+
*
|
| 257 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 258 |
+
*
|
| 259 |
+
* @see Buyster_Buyster_Model_Observer -> valorizeOrders
|
| 260 |
+
* @return void
|
| 261 |
+
*/
|
| 262 |
+
public function disableCanInvoice($order)
|
| 263 |
+
{
|
| 264 |
+
if (
|
| 265 |
+
$this->getTransactionType() !=
|
| 266 |
+
Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION
|
| 267 |
+
) {
|
| 268 |
+
$items = $order->getAllItems();
|
| 269 |
+
foreach ($items as $item) {
|
| 270 |
+
// Disable invoice button in Back Office for this order
|
| 271 |
+
$item->setLockedDoInvoice(true);
|
| 272 |
+
$item->save();
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
/**
|
| 278 |
+
* Reenable invoice feature
|
| 279 |
+
* because it has been blocked before
|
| 280 |
+
*
|
| 281 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 282 |
+
*
|
| 283 |
+
* @see $this->disableCanInvoice()
|
| 284 |
+
* @see Buyster_Buyster_Model_Observer -> valorizeOrders
|
| 285 |
+
* @return void
|
| 286 |
+
*/
|
| 287 |
+
public function enableCanInvoice($order)
|
| 288 |
+
{
|
| 289 |
+
$items = $order->getAllItems();
|
| 290 |
+
foreach ($items as $item) {
|
| 291 |
+
// Reenable invoice button in Back Office for this order
|
| 292 |
+
$item->unsLockedDoInvoice();
|
| 293 |
+
$item->save();
|
| 294 |
+
}
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
/**
|
| 298 |
+
* Takes transaction parameters as a string and
|
| 299 |
+
* return a more easily usable object
|
| 300 |
+
* For example:
|
| 301 |
+
* validationDelay=3;
|
| 302 |
+
* Will return object where
|
| 303 |
+
* $object->getValidationDelay() returns 3
|
| 304 |
+
*
|
| 305 |
+
* @param string $parameters Transaction parameters to extract
|
| 306 |
+
*
|
| 307 |
+
* @return Buyster_Buyster_Model_Service_Message_Abstract
|
| 308 |
+
*/
|
| 309 |
+
public function extractParameters($parameters)
|
| 310 |
+
{
|
| 311 |
+
$return = Mage::getModel('buyster/service_message_abstract');
|
| 312 |
+
|
| 313 |
+
$params = explode(';', $parameters);
|
| 314 |
+
foreach ($params as $param) {
|
| 315 |
+
if (!empty($param)) {
|
| 316 |
+
list($key, $value) = explode('=', $param);
|
| 317 |
+
$return->setData($key, $value);
|
| 318 |
+
}
|
| 319 |
+
}
|
| 320 |
+
return $return;
|
| 321 |
+
}
|
| 322 |
+
}
|
app/code/community/Buyster/Buyster/Model/Observer.php
ADDED
|
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
+
* Buyster Observer, used to trap checkout/onepage/success predispatch
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Observer extends Mage_Core_Model_Abstract
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Valorize orders
|
| 14 |
+
* Task called by cron daily (during night)
|
| 15 |
+
* - Whatever transactionType ('payment', 'paymentDelayed' or 'paymentValidation')
|
| 16 |
+
* order status is 'validated' Magento side and 'CAPTURED' Buyster side -> capture order
|
| 17 |
+
* - For paymentValidation, need to call updateStatusValidated method,
|
| 18 |
+
* otherwise order status would be 'payment_review'
|
| 19 |
+
*
|
| 20 |
+
* @param Varien_Event_Observer $observer Observer
|
| 21 |
+
*
|
| 22 |
+
* @return void
|
| 23 |
+
*/
|
| 24 |
+
public function valorize($observer)
|
| 25 |
+
{
|
| 26 |
+
// Enforce translations loading
|
| 27 |
+
Mage::getSingleton('core/translate')->init('frontend');
|
| 28 |
+
|
| 29 |
+
// Retrieve orders with status = 'validated'
|
| 30 |
+
$validatedOrders = Mage::getModel('sales/order')
|
| 31 |
+
->getCollection()
|
| 32 |
+
->addAttributeToFilter('status', Buyster_Buyster_Model_Service::STATUS_VALIDATED)
|
| 33 |
+
->getItems();
|
| 34 |
+
|
| 35 |
+
try {
|
| 36 |
+
|
| 37 |
+
foreach ($validatedOrders as $order) {
|
| 38 |
+
|
| 39 |
+
// Retrieve payment and transaction
|
| 40 |
+
$payment = $order->getPayment();
|
| 41 |
+
$transaction = $payment->getAuthorizationTransaction();
|
| 42 |
+
|
| 43 |
+
// Filter Buyster payments which get transaction
|
| 44 |
+
if ($transaction && $payment->getMethod() == Buyster_Buyster_Model_Service::CODE) {
|
| 45 |
+
|
| 46 |
+
// Load transaction details
|
| 47 |
+
$transactionDetails = $this->_getHelper()->getTransactionDetails($transaction);
|
| 48 |
+
$transactionType = $transactionDetails->getTransactionType();
|
| 49 |
+
|
| 50 |
+
if (
|
| 51 |
+
$transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_SIMPLE ||
|
| 52 |
+
$transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_DELAYED
|
| 53 |
+
) {
|
| 54 |
+
// Valorize orders with transactionType = 'payment' or 'paymentDelayed'
|
| 55 |
+
$this->_valorizePaymentAndPaymentDelayed($order);
|
| 56 |
+
|
| 57 |
+
} elseif ($transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION) {
|
| 58 |
+
|
| 59 |
+
// Valorize orders with transactionType = 'paymentValidation'
|
| 60 |
+
$this->_valorizePaymentValidation($order);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
} catch (Exception $e) {
|
| 66 |
+
// Log exception
|
| 67 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Buyster_Buyster_Model_Service::LOGFILE);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Valorize orders with transactionType = 'payment' or 'paymentDelayed'
|
| 73 |
+
*
|
| 74 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 75 |
+
*
|
| 76 |
+
* @return void
|
| 77 |
+
*/
|
| 78 |
+
protected function _valorizePaymentAndPaymentDelayed($order)
|
| 79 |
+
{
|
| 80 |
+
// Payment method (Buyster sandard model)
|
| 81 |
+
$paymentMethod = Mage::getSingleton('buyster/standard');
|
| 82 |
+
|
| 83 |
+
// Web service diagnostic for current order
|
| 84 |
+
$response = $paymentMethod->cashManagementOperation(
|
| 85 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 86 |
+
);
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Check responseCode
|
| 90 |
+
* -> 00 = OK
|
| 91 |
+
* -> other = NOK
|
| 92 |
+
*/
|
| 93 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 94 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 95 |
+
|
| 96 |
+
// Reenable canInvoice if it has been disabled before
|
| 97 |
+
$this->_getHelper()->enableCanInvoice($order);
|
| 98 |
+
|
| 99 |
+
// Check if order can be invoiced
|
| 100 |
+
if (!$order->canInvoice()) {
|
| 101 |
+
Mage::log(
|
| 102 |
+
'Cannot create an invoice for order id ' . $order->getId(),
|
| 103 |
+
Zend_Log::ERR,
|
| 104 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 105 |
+
);
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
|
| 109 |
+
|
| 110 |
+
if (!$invoice->getTotalQty()) {
|
| 111 |
+
Mage::log(
|
| 112 |
+
'Cannot create an invoice without products for order id ' . $order->getId(),
|
| 113 |
+
Zend_Log::ERR,
|
| 114 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 115 |
+
);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
// Emit invoice and create transaction, then automatically update status to 'processing'
|
| 119 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
| 120 |
+
$invoice->register();
|
| 121 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
| 122 |
+
->addObject($invoice)
|
| 123 |
+
->addObject($invoice->getOrder());
|
| 124 |
+
|
| 125 |
+
$transactionSave->save();
|
| 126 |
+
|
| 127 |
+
}
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* Valorize orders with transactionType = 'paymentValidation'
|
| 132 |
+
*
|
| 133 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 134 |
+
*
|
| 135 |
+
* @return void
|
| 136 |
+
*/
|
| 137 |
+
protected function _valorizePaymentValidation($order)
|
| 138 |
+
{
|
| 139 |
+
// Payment method (Buyster sandard model)
|
| 140 |
+
$paymentMethod = Mage::getSingleton('buyster/standard');
|
| 141 |
+
|
| 142 |
+
// Call web service diagnostic
|
| 143 |
+
$response = $paymentMethod->cashManagementOperation(
|
| 144 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 145 |
+
);
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* Check responseCode
|
| 149 |
+
* -> 00 = OK
|
| 150 |
+
* -> other = NOK
|
| 151 |
+
*/
|
| 152 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 153 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 154 |
+
|
| 155 |
+
// Retrieve order collection and pay all -> there can be only one invoice
|
| 156 |
+
$invoiceCollection = $order->getInvoiceCollection();
|
| 157 |
+
foreach ($invoiceCollection as $invoice) {
|
| 158 |
+
|
| 159 |
+
// Pay invoice and update order status
|
| 160 |
+
$invoice->pay()->save();
|
| 161 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__("Invoice has been captured");
|
| 162 |
+
$order->addStatusHistoryComment($msg, Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 163 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 164 |
+
$order->save();
|
| 165 |
+
|
| 166 |
+
}
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
/**
|
| 171 |
+
* Expire orders
|
| 172 |
+
* Task called by cron daily (during night)
|
| 173 |
+
* For orders where status is 'pending_validation' and payment method is Buyster
|
| 174 |
+
* check if has expired and update status
|
| 175 |
+
*
|
| 176 |
+
* @param Varien_Event_Observer $observer Observer
|
| 177 |
+
*
|
| 178 |
+
* @return void
|
| 179 |
+
*/
|
| 180 |
+
public function expire($observer)
|
| 181 |
+
{
|
| 182 |
+
// Enforce translations loading
|
| 183 |
+
Mage::getSingleton('core/translate')->init('frontend');
|
| 184 |
+
|
| 185 |
+
// Retrieve orders with status = 'validated'
|
| 186 |
+
$validatedOrders = Mage::getModel('sales/order')
|
| 187 |
+
->getCollection()
|
| 188 |
+
->addAttributeToFilter('status', Buyster_Buyster_Model_Service::STATUS_PENDING_VALIDATION)
|
| 189 |
+
->getItems();
|
| 190 |
+
|
| 191 |
+
foreach ($validatedOrders as $order) {
|
| 192 |
+
|
| 193 |
+
// Load payment and transaction
|
| 194 |
+
$payment = $order->getPayment();
|
| 195 |
+
$transaction = $payment->getAuthorizationTransaction();
|
| 196 |
+
|
| 197 |
+
// Filter Buyster payments which get transaction
|
| 198 |
+
if ($transaction && $payment->getMethod() == Buyster_Buyster_Model_Service::CODE) {
|
| 199 |
+
|
| 200 |
+
// Load transaction details
|
| 201 |
+
$transactionDetails = $this->_getHelper()->getTransactionDetails($transaction);
|
| 202 |
+
$transactionType = $transactionDetails->getTransactionType();
|
| 203 |
+
|
| 204 |
+
// Filter transactionType = 'payment' or 'paymentDelayed'
|
| 205 |
+
if ($transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION) {
|
| 206 |
+
|
| 207 |
+
// perform expiration logic for this order
|
| 208 |
+
$this->operationExpire($order);
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* Perform expire operation calling Buyster web service
|
| 216 |
+
* and updating order status and comments
|
| 217 |
+
* First, a DIAGNOSTIC is performed
|
| 218 |
+
* status can be TO_VALIDATE, TO_CAPTURE, CAPTURED, EXPIRED
|
| 219 |
+
* TO_VALIDATE: nothing to do, payment needs to be captured via Magento Back Office
|
| 220 |
+
* TO_CAPTURE: invoice is emitted and invoice payment status is pending
|
| 221 |
+
* CAPTURED: invoice is emitted and invoice is paid
|
| 222 |
+
* EXPIRED: expire order
|
| 223 |
+
* Assumes that transactionType for current order is paymentValidation
|
| 224 |
+
*
|
| 225 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 226 |
+
*
|
| 227 |
+
* @return void
|
| 228 |
+
*/
|
| 229 |
+
public function operationExpire($order)
|
| 230 |
+
{
|
| 231 |
+
// Payment method (Buyster sandard model)
|
| 232 |
+
$paymentMethod = Mage::getSingleton('buyster/standard');
|
| 233 |
+
|
| 234 |
+
// Web service diagnostic
|
| 235 |
+
$response = $paymentMethod->cashManagementOperation(
|
| 236 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 237 |
+
);
|
| 238 |
+
|
| 239 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 240 |
+
|
| 241 |
+
if ($response->getStatus() == Buyster_Buyster_Model_Service::TO_VALIDATE) {
|
| 242 |
+
|
| 243 |
+
// Buyster status is TO_VALIDATE => nothing to do
|
| 244 |
+
|
| 245 |
+
} else if (
|
| 246 |
+
$response->getStatus() == Buyster_Buyster_Model_Service::TO_CAPTURE ||
|
| 247 |
+
$response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED
|
| 248 |
+
) {
|
| 249 |
+
|
| 250 |
+
// Perform order capture, to use logic written in capture method
|
| 251 |
+
$invoice = null;
|
| 252 |
+
$payment = $order->getPayment();
|
| 253 |
+
$payment->capture($invoice);
|
| 254 |
+
|
| 255 |
+
if ($response->getStatus() == Buyster_Buyster_Model_Service::TO_CAPTURE) {
|
| 256 |
+
// Update order status
|
| 257 |
+
$order->setStatus(Buyster_Buyster_Model_Service::STATUS_VALIDATED);
|
| 258 |
+
} else if ($response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 259 |
+
// Update order status
|
| 260 |
+
$order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 261 |
+
}
|
| 262 |
+
$order->save();
|
| 263 |
+
|
| 264 |
+
} else if ($response->getStatus() == Buyster_Buyster_Model_Service::EXPIRED) {
|
| 265 |
+
|
| 266 |
+
// If order has expired => set status to 'expired'
|
| 267 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__("Transaction has expired");
|
| 268 |
+
$order->addStatusHistoryComment($msg, Buyster_Buyster_Model_Service::STATUS_EXPIRED);
|
| 269 |
+
$order->setStatus(Buyster_Buyster_Model_Service::STATUS_EXPIRED);
|
| 270 |
+
$order->save();
|
| 271 |
+
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
} else {
|
| 275 |
+
|
| 276 |
+
// Diagnostic failed. Write error description in order comments
|
| 277 |
+
$msg = 'Buyster : ' . utf8_decode($response->getResponseDescription());
|
| 278 |
+
$order->addStatusHistoryComment($msg);
|
| 279 |
+
$order->save();
|
| 280 |
+
}
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* Update order status where payment method is Buyster and current status
|
| 285 |
+
* is 'payment_review' to 'validated'
|
| 286 |
+
* Order status after invoicing is 'payment_review' by defaut,
|
| 287 |
+
* so change to 'validated'
|
| 288 |
+
*
|
| 289 |
+
* @param Varien_Event_Observer $observer Observer
|
| 290 |
+
*
|
| 291 |
+
* @see sales_order_invoice_save_before
|
| 292 |
+
* @return void
|
| 293 |
+
*/
|
| 294 |
+
public function updateStatusValidated($observer)
|
| 295 |
+
{
|
| 296 |
+
// Enforce translations loading
|
| 297 |
+
Mage::getSingleton('core/translate')->init('frontend');
|
| 298 |
+
|
| 299 |
+
// Update order status
|
| 300 |
+
$order = $observer->getEvent()->getInvoice()->getOrder();
|
| 301 |
+
if (
|
| 302 |
+
$order->getPayment()->getMethodInstance()->getCode() == Buyster_Buyster_Model_Service::CODE &&
|
| 303 |
+
$order->getStatus() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW
|
| 304 |
+
) {
|
| 305 |
+
$order->setStatus(Buyster_Buyster_Model_Service::STATUS_VALIDATED);
|
| 306 |
+
|
| 307 |
+
// Retrieve payment and transaction
|
| 308 |
+
$payment = $order->getPayment();
|
| 309 |
+
$transaction = $payment->getAuthorizationTransaction();
|
| 310 |
+
|
| 311 |
+
// payment shall get transaction
|
| 312 |
+
if ($transaction) {
|
| 313 |
+
// Load transaction details
|
| 314 |
+
$transactionDetails = $this->_getHelper()->getTransactionDetails($transaction);
|
| 315 |
+
$guaranteeDescription = $transactionDetails->getData('Garantie');
|
| 316 |
+
|
| 317 |
+
// Retrieve invoice
|
| 318 |
+
$invoice = $observer->getEvent()->getInvoice();
|
| 319 |
+
|
| 320 |
+
// Add comment containing guarantee description in invoice history
|
| 321 |
+
$invoice->addComment("Buyster : " . $guaranteeDescription);
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
/**
|
| 327 |
+
* Cancel invoice and order
|
| 328 |
+
* Call Buyster diagnostic web service
|
| 329 |
+
* If it has been captured, pay invoice and set order status to 'processing'
|
| 330 |
+
* Else, cancel order Buyster side, then cancel invoice and order Magento side
|
| 331 |
+
*
|
| 332 |
+
* @param Varien_Event_Observer $observer Observer
|
| 333 |
+
*
|
| 334 |
+
* @return void
|
| 335 |
+
*/
|
| 336 |
+
public function cancelInvoice($observer)
|
| 337 |
+
{
|
| 338 |
+
// Enforce translations loading
|
| 339 |
+
Mage::getSingleton('core/translate')->init('frontend');
|
| 340 |
+
|
| 341 |
+
$invoice = $observer->getEvent()->getInvoice();
|
| 342 |
+
$order = $invoice->getOrder();
|
| 343 |
+
|
| 344 |
+
if ($order->getPayment()->getMethodInstance()->getCode() == Buyster_Buyster_Model_Service::CODE) {
|
| 345 |
+
|
| 346 |
+
// Payment method (Buyster sandard model)
|
| 347 |
+
$paymentMethod = Mage::getSingleton('buyster/standard');
|
| 348 |
+
|
| 349 |
+
// Call web service diagnostic
|
| 350 |
+
$response = $paymentMethod->cashManagementOperation(
|
| 351 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 352 |
+
);
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* If order has been captured by Buyster in the meantime, DO NOT CANCEL this order
|
| 356 |
+
*/
|
| 357 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 358 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 359 |
+
|
| 360 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__(
|
| 361 |
+
"Invoice has been captured in the meantime by Buyster. It hadn't been canceled and can be shipped."
|
| 362 |
+
);
|
| 363 |
+
$invoice->pay()->save();
|
| 364 |
+
$order->addStatusHistoryComment($msg, Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 365 |
+
$order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
|
| 366 |
+
$order->save();
|
| 367 |
+
|
| 368 |
+
Mage::getSingleton('adminhtml/session')->addWarning($msg);
|
| 369 |
+
|
| 370 |
+
} elseif ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 371 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CANCELLED) {
|
| 372 |
+
|
| 373 |
+
// Nothing to do, order already cancelled Buyster side
|
| 374 |
+
|
| 375 |
+
} elseif ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 376 |
+
$paymentMethod->operationCancel($order);
|
| 377 |
+
}
|
| 378 |
+
}
|
| 379 |
+
return $this;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* Function to retrieve current checkout session
|
| 384 |
+
*
|
| 385 |
+
* @return Mage_Checkout_Model_Session the current session
|
| 386 |
+
*/
|
| 387 |
+
protected function _getSession()
|
| 388 |
+
{
|
| 389 |
+
return Mage::getSingleton('checkout/session');
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
/**
|
| 393 |
+
* Retrieve model helper
|
| 394 |
+
*
|
| 395 |
+
* @return Buyster_Buyster_Helper_Data
|
| 396 |
+
*/
|
| 397 |
+
protected function _getHelper()
|
| 398 |
+
{
|
| 399 |
+
return Mage::helper('buyster');
|
| 400 |
+
}
|
| 401 |
+
}
|
app/code/community/Buyster/Buyster/Model/Order/Config.php
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Order configuration model - correct bug on getStateStatuses
|
| 4 |
+
* => caching $this->_stateStatuses was wrong when $state was 'Array'
|
| 5 |
+
* => Solution: add unique key
|
| 6 |
+
*
|
| 7 |
+
* @category Buyster
|
| 8 |
+
* @package Buyster_Buyster
|
| 9 |
+
* @copyright 2011 Buyster
|
| 10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 11 |
+
*/
|
| 12 |
+
class Buyster_Buyster_Model_Order_Config extends Mage_Sales_Model_Order_Config
|
| 13 |
+
{
|
| 14 |
+
/**
|
| 15 |
+
* Retrieve statuses available for state
|
| 16 |
+
* Get all possible statuses, or for specified state, or specified states array
|
| 17 |
+
* Add labels by default. Return plain array of statuses, if no labels.
|
| 18 |
+
*
|
| 19 |
+
* @param mixed $state State
|
| 20 |
+
* @param bool $addLabels Add labelds by default (default true)
|
| 21 |
+
* @param string $uniqueKey String unique key to avoid bug of duplicate key when $state is array
|
| 22 |
+
*
|
| 23 |
+
* @return array
|
| 24 |
+
*/
|
| 25 |
+
public function getStateStatuses($state, $addLabels = true, $uniqueKey = '')
|
| 26 |
+
{
|
| 27 |
+
$key = $state . $addLabels . $uniqueKey;
|
| 28 |
+
if (isset($this->_stateStatuses[$key])) {
|
| 29 |
+
return $this->_stateStatuses[$key];
|
| 30 |
+
}
|
| 31 |
+
$statuses = array();
|
| 32 |
+
if (empty($state) || !is_array($state)) {
|
| 33 |
+
$state = array($state);
|
| 34 |
+
}
|
| 35 |
+
foreach ($state as $_state) {
|
| 36 |
+
if ($stateNode = $this->_getState($_state)) {
|
| 37 |
+
|
| 38 |
+
// Check if this resource model exists. only in last versions
|
| 39 |
+
if (class_exists('Mage_Sales_Model_Mysql4_Order_Status_Collection', false)) {
|
| 40 |
+
$collection = Mage::getResourceModel('sales/order_status_collection')
|
| 41 |
+
->addStateFilter($_state)
|
| 42 |
+
->orderByLabel();
|
| 43 |
+
foreach ($collection as $status) {
|
| 44 |
+
$code = $status->getStatus();
|
| 45 |
+
if ($addLabels) {
|
| 46 |
+
$statuses[$code] = $status->getStoreLabel();
|
| 47 |
+
} else {
|
| 48 |
+
$statuses[] = $code;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
} else {
|
| 52 |
+
// This resource model does not exist in old versions
|
| 53 |
+
foreach ($stateNode->statuses->children() as $statusNode) {
|
| 54 |
+
$status = $statusNode->getName();
|
| 55 |
+
if ($addLabels) {
|
| 56 |
+
$statuses[$status] = $this->getStatusLabel($status);
|
| 57 |
+
} else {
|
| 58 |
+
$statuses[] = $status;
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
$this->_stateStatuses[$key] = $statuses;
|
| 65 |
+
return $statuses;
|
| 66 |
+
}
|
| 67 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service.php
ADDED
|
@@ -0,0 +1,192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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP adapter
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service extends Varien_Object
|
| 11 |
+
{
|
| 12 |
+
CONST CODE = 'buyster';
|
| 13 |
+
CONST SERVICE_RESPONSE_SUCCESS = '00';
|
| 14 |
+
CONST LOGFILE = 'buyster.log';
|
| 15 |
+
|
| 16 |
+
CONST STATUS_PENDING_VALIDATION = 'pending_validation';
|
| 17 |
+
CONST STATUS_VALIDATED = 'validated';
|
| 18 |
+
CONST STATUS_EXPIRED = 'expired';
|
| 19 |
+
|
| 20 |
+
CONST TRANSACTION_TYPE_SIMPLE = 'payment';
|
| 21 |
+
CONST TRANSACTION_TYPE_DELAYED = 'paymentDelayed';
|
| 22 |
+
CONST TRANSACTION_TYPE_VALIDATION = 'paymentValidation';
|
| 23 |
+
|
| 24 |
+
CONST OPERATION_DIAGNOSTIC = 'DIAGNOSTIC';
|
| 25 |
+
CONST OPERATION_CANCEL = 'CANCEL';
|
| 26 |
+
CONST OPERATION_REFUND = 'REFUND';
|
| 27 |
+
CONST OPERATION_VALIDATE = 'VALIDATE';
|
| 28 |
+
CONST OPERATION_DUPLICATE = 'DUPLICATE';
|
| 29 |
+
|
| 30 |
+
CONST CANCELLED = 'CANCELLED';
|
| 31 |
+
CONST CAPTURED = 'CAPTURED';
|
| 32 |
+
CONST REFUNDED = 'REFUNDED';
|
| 33 |
+
CONST EXPIRED = 'EXPIRED';
|
| 34 |
+
CONST REFUSED = 'REFUSED';
|
| 35 |
+
CONST FAILED = 'FAILED';
|
| 36 |
+
CONST TO_CAPTURE = 'TO_CAPTURE';
|
| 37 |
+
CONST TO_VALIDATE = 'TO_VALIDATE';
|
| 38 |
+
CONST TO_REFUND = 'TO_REFUND';
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Initialize Buyster Payment using SOAP web service
|
| 42 |
+
*
|
| 43 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 44 |
+
*
|
| 45 |
+
* @throws Exception if parameters are not correctly configured
|
| 46 |
+
* @return Varien_Object Request and Response from web service call
|
| 47 |
+
*/
|
| 48 |
+
public function initializePayment($order)
|
| 49 |
+
{
|
| 50 |
+
// Init SOAP client
|
| 51 |
+
$client = $this->_initSoapClient();
|
| 52 |
+
$helper = Mage::helper('buyster');
|
| 53 |
+
|
| 54 |
+
// Proceed to a payment link request
|
| 55 |
+
$request = Mage::getModel('buyster/service_payment_initialize_request');
|
| 56 |
+
$request->initOrder($order);
|
| 57 |
+
|
| 58 |
+
try {
|
| 59 |
+
// To use magic methods on response object
|
| 60 |
+
$response = Mage::getModel('buyster/service_payment_initialize_response');
|
| 61 |
+
// Call web service
|
| 62 |
+
$response->addData((array)$client->initializePayment($request->toArray()));
|
| 63 |
+
|
| 64 |
+
} catch(Exception $e) {
|
| 65 |
+
$response->setResponseDescription($helper->__('Buyster servers are unavailable'));
|
| 66 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, self::LOGFILE);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
$requestResponse = array('request' => $request, 'response' => $response);
|
| 70 |
+
return new Varien_Object($requestResponse);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Manage Buyster cash operation using SOAP web service
|
| 75 |
+
* Operation Name can be 'DIAGNOSTIC', 'CANCEL', 'REFUND', 'VALIDATE', 'DUPLICATE'
|
| 76 |
+
*
|
| 77 |
+
* @param Mages_Sales_Model_Order $order Current order
|
| 78 |
+
* @param string $operationName Operation Name
|
| 79 |
+
* @param string $amount Total due invoice amount
|
| 80 |
+
*
|
| 81 |
+
* @return Varien_Object Request and Response from web service call
|
| 82 |
+
*/
|
| 83 |
+
public function cashManagementOperation($order, $operationName, $amount=null)
|
| 84 |
+
{
|
| 85 |
+
// Init SOAP client
|
| 86 |
+
$client = $this->_initSoapClient();
|
| 87 |
+
$helper = Mage::helper('buyster');
|
| 88 |
+
|
| 89 |
+
// Proceed to a payment link request
|
| 90 |
+
$request = Mage::getModel('buyster/service_payment_cashmanagement_request');
|
| 91 |
+
|
| 92 |
+
if ($operationName == self::OPERATION_DIAGNOSTIC) {
|
| 93 |
+
// Call diagnostic using Buyster web service
|
| 94 |
+
$request->diagnostic($order);
|
| 95 |
+
} elseif ($operationName == self::OPERATION_VALIDATE) {
|
| 96 |
+
// Call validation method using Buyster web service
|
| 97 |
+
$request->validate($order, $amount);
|
| 98 |
+
} elseif ($operationName == self::OPERATION_CANCEL) {
|
| 99 |
+
// Call cancel method using Buyster web service
|
| 100 |
+
$request->cancel($order);
|
| 101 |
+
} elseif ($operationName == self::OPERATION_REFUND) {
|
| 102 |
+
// Call refund method using Buyster web service
|
| 103 |
+
$request->refund($order, $amount);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
try {
|
| 107 |
+
// To use magic methods on response object
|
| 108 |
+
$response = Mage::getModel('buyster/service_payment_cashmanagement_response');
|
| 109 |
+
// Call web service
|
| 110 |
+
$response->addData((array)$client->cashManagementOperation($request->toArray()));
|
| 111 |
+
|
| 112 |
+
} catch(Exception $e) {
|
| 113 |
+
$response->setResponseDescription($helper->__("Buyster servers are unavailable"));
|
| 114 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, self::LOGFILE);
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
$requestResponse = array('request' => $request, 'response' => $response);
|
| 118 |
+
return new Varien_Object($requestResponse);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/**
|
| 122 |
+
* Log web service error
|
| 123 |
+
*
|
| 124 |
+
* @param Varien_Object $requestResponse Contain request and response
|
| 125 |
+
* @param string $method Web service method
|
| 126 |
+
* @param string $additionalInfo Additional info for logs
|
| 127 |
+
*
|
| 128 |
+
* @return void
|
| 129 |
+
*/
|
| 130 |
+
public function logError($requestResponse, $method, $additionalInfo='')
|
| 131 |
+
{
|
| 132 |
+
Mage::log(
|
| 133 |
+
$method . ' call to Buyster web service failed',
|
| 134 |
+
Zend_Log::INFO,
|
| 135 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 136 |
+
);
|
| 137 |
+
if ($additionalInfo != '') {
|
| 138 |
+
Mage::log(
|
| 139 |
+
(string)$additionalInfo,
|
| 140 |
+
Zend_Log::INFO,
|
| 141 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 142 |
+
);
|
| 143 |
+
}
|
| 144 |
+
Mage::log(
|
| 145 |
+
'REQUEST',
|
| 146 |
+
Zend_Log::INFO,
|
| 147 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 148 |
+
);
|
| 149 |
+
Mage::log(
|
| 150 |
+
$requestResponse->getRequest()->toArray(),
|
| 151 |
+
Zend_Log::INFO,
|
| 152 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 153 |
+
);
|
| 154 |
+
Mage::log(
|
| 155 |
+
'RESPONSE',
|
| 156 |
+
Zend_Log::INFO,
|
| 157 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 158 |
+
);
|
| 159 |
+
Mage::log(
|
| 160 |
+
$requestResponse->getResponse()->toArray(),
|
| 161 |
+
Zend_Log::INFO,
|
| 162 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 163 |
+
);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/**
|
| 167 |
+
* Init web service connection
|
| 168 |
+
*
|
| 169 |
+
* @return Zend_Soap_Client Service connection
|
| 170 |
+
*/
|
| 171 |
+
protected function _initSoapClient()
|
| 172 |
+
{
|
| 173 |
+
// Init client. Soap version is 1.1
|
| 174 |
+
$client = new Zend_Soap_Client(
|
| 175 |
+
Mage::getStoreConfig('payment/buyster/service_url'),
|
| 176 |
+
array('soap_version' => SOAP_1_1)
|
| 177 |
+
);
|
| 178 |
+
|
| 179 |
+
// Append auth header
|
| 180 |
+
$namespace = 'urn:mnop:acceptor:contract';
|
| 181 |
+
$header = array(
|
| 182 |
+
'merchantId' => Mage::getStoreConfig('payment/buyster/merchant_id'),
|
| 183 |
+
'merchantPassword' => Mage::getStoreConfig('payment/buyster/merchant_password'),
|
| 184 |
+
'merchantSignature' => Mage::getStoreConfig('payment/buyster/merchant_signature')
|
| 185 |
+
);
|
| 186 |
+
|
| 187 |
+
// Add SOAP header
|
| 188 |
+
$client->addSoapInputHeader(new SoapHeader($namespace, 'authenticationHeader', $header), true);
|
| 189 |
+
|
| 190 |
+
return $client;
|
| 191 |
+
}
|
| 192 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service/Message/Abstract.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP abstract message
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service_Message_Abstract extends Varien_Object
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Use web service convention for attribute names
|
| 14 |
+
* Converts field names for setters and getters
|
| 15 |
+
* $this->setMyField($value) === $this->setData('myField', $value)
|
| 16 |
+
*
|
| 17 |
+
* Do not use cache to avoid side effects with Varien_Object one
|
| 18 |
+
*
|
| 19 |
+
* @param string $name Attribute name
|
| 20 |
+
*
|
| 21 |
+
* @return string
|
| 22 |
+
*/
|
| 23 |
+
protected function _underscore($name)
|
| 24 |
+
{
|
| 25 |
+
$result = lcfirst($name);
|
| 26 |
+
return $result;
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service/Payment/Cashmanagement/Request.php
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP request for cashManagementOperation method
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service_Payment_Cashmanagement_Request
|
| 11 |
+
extends Buyster_Buyster_Model_Service_Message_Abstract
|
| 12 |
+
{
|
| 13 |
+
/**
|
| 14 |
+
* Initialize default values
|
| 15 |
+
*
|
| 16 |
+
* @return void
|
| 17 |
+
*/
|
| 18 |
+
public function __construct()
|
| 19 |
+
{
|
| 20 |
+
$helper = $this->_getHelper();
|
| 21 |
+
|
| 22 |
+
// Init default values
|
| 23 |
+
$this->setOperationOrigin($helper->getTransactionOrigin())
|
| 24 |
+
->setRequestVersion(Mage::getConfig()->getNode('global/buyster/request_version')->asArray());
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Diagnostic for this order
|
| 29 |
+
* Call Buyster platform to get information
|
| 30 |
+
*
|
| 31 |
+
* @param Mage_Sales_Model_Order $order Order to diagnose
|
| 32 |
+
*
|
| 33 |
+
* @return void
|
| 34 |
+
*/
|
| 35 |
+
public function diagnostic($order)
|
| 36 |
+
{
|
| 37 |
+
$this->setOperationName(Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC)
|
| 38 |
+
->setTransactionReference($order->getIncrementId());
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Validate payment for this order
|
| 43 |
+
* Call Buyster platform to valorize this order
|
| 44 |
+
* Buyster status should be TO_VALIDATE
|
| 45 |
+
* After validation, it should be CAPTURED or TO_VALIDATE if partial payment
|
| 46 |
+
*
|
| 47 |
+
* @param Mage_Sales_Model_Order $order Order to diagnose
|
| 48 |
+
* @param float|string $amount Invoice total due, in currency unit
|
| 49 |
+
*
|
| 50 |
+
* @return void
|
| 51 |
+
*/
|
| 52 |
+
public function validate($order, $amount)
|
| 53 |
+
{
|
| 54 |
+
$this->setOperationName(Buyster_Buyster_Model_Service::OPERATION_VALIDATE)
|
| 55 |
+
->setAmount($this->_getHelper()->getBuysterPrice($amount))
|
| 56 |
+
->setTransactionReference($order->getIncrementId());
|
| 57 |
+
|
| 58 |
+
$operationParameters = $this->_getHelper()->getOperationParameters();
|
| 59 |
+
if (!empty($operationParameters)) {
|
| 60 |
+
$this->setOperationParameters($operationParameters);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* Cancel order
|
| 66 |
+
* Only full cancel is available
|
| 67 |
+
*
|
| 68 |
+
* @param Mage_Sales_Model_Order $order Order to diagnose
|
| 69 |
+
*
|
| 70 |
+
* @return void
|
| 71 |
+
*/
|
| 72 |
+
public function cancel($order)
|
| 73 |
+
{
|
| 74 |
+
$this->setOperationName(Buyster_Buyster_Model_Service::OPERATION_CANCEL)
|
| 75 |
+
->setAmount($this->_getHelper()->getBuysterPrice($order->getGrandTotal()))
|
| 76 |
+
->setTransactionReference($order->getIncrementId());
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* Refund order
|
| 81 |
+
* Can be total or partial
|
| 82 |
+
* In Magento, emit credit-memo and send email to final customer
|
| 83 |
+
*
|
| 84 |
+
* @param Mage_Sales_Model_Order $order Order to diagnose
|
| 85 |
+
* @param float|string $amount Credit-memo total due, in currency unit
|
| 86 |
+
*
|
| 87 |
+
* @return void
|
| 88 |
+
*/
|
| 89 |
+
public function refund($order, $amount)
|
| 90 |
+
{
|
| 91 |
+
$this->setOperationName(Buyster_Buyster_Model_Service::OPERATION_REFUND)
|
| 92 |
+
->setAmount($this->_getHelper()->getBuysterPrice($amount))
|
| 93 |
+
->setTransactionReference($order->getIncrementId());
|
| 94 |
+
|
| 95 |
+
$operationParameters = $this->_getHelper()->getOperationParameters();
|
| 96 |
+
if (!empty($operationParameters)) {
|
| 97 |
+
$this->setOperationParameters($operationParameters);
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* Return Buyster helper
|
| 103 |
+
*
|
| 104 |
+
* @return mixed
|
| 105 |
+
*/
|
| 106 |
+
protected function _getHelper()
|
| 107 |
+
{
|
| 108 |
+
return Mage::helper('buyster');
|
| 109 |
+
}
|
| 110 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service/Payment/Cashmanagement/Response.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP response for cashManagementOperation method
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service_Payment_Cashmanagement_Response
|
| 11 |
+
extends Buyster_Buyster_Model_Service_Message_Abstract
|
| 12 |
+
{
|
| 13 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service/Payment/Initialize/Request.php
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP request for initializePayment method
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service_Payment_Initialize_Request extends Buyster_Buyster_Model_Service_Message_Abstract
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Intialize default values
|
| 14 |
+
*
|
| 15 |
+
* @return void
|
| 16 |
+
*/
|
| 17 |
+
public function __construct()
|
| 18 |
+
{
|
| 19 |
+
$helper = $this->_getHelper();
|
| 20 |
+
$transactionType = $helper->getTransactionType();
|
| 21 |
+
|
| 22 |
+
$customerId = '';
|
| 23 |
+
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
|
| 24 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomer()->getId();
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
// Init default values
|
| 28 |
+
$this->setAutomaticResponseUrl(Mage::getUrl('buyster/payment/automatic'))
|
| 29 |
+
->setCustomerId($customerId)
|
| 30 |
+
->setCustomerLanguage($helper->getCustomerLanguage()) // only french is supported by now
|
| 31 |
+
->setOrderChannel(Mage::app()->getStore()->getCode())
|
| 32 |
+
->setRequestVersion(Mage::getConfig()->getNode('global/buyster/request_version')->asArray())
|
| 33 |
+
->setReturnUrl(Mage::getUrl('buyster/payment/return'))
|
| 34 |
+
->setTransactionOrigin($helper->getTransactionOrigin())
|
| 35 |
+
->setTransactionParameters($helper->getTransactionParameters())
|
| 36 |
+
->setTransactionType($transactionType);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Init request params for given order
|
| 41 |
+
*
|
| 42 |
+
* @param Mage_Sales_Model_Order $order Order to initialize
|
| 43 |
+
*
|
| 44 |
+
* @return void
|
| 45 |
+
*/
|
| 46 |
+
public function initOrder($order)
|
| 47 |
+
{
|
| 48 |
+
$helper = $this->_getHelper();
|
| 49 |
+
|
| 50 |
+
if ($order) {
|
| 51 |
+
$this->setAmount($helper->getBuysterPrice($order->getGrandTotal()))
|
| 52 |
+
->setMerchantTransactionDateTime(
|
| 53 |
+
Mage::app()->getLocale()->date(now())->toString(Zend_Date::ISO_8601) // now() ISO 8601
|
| 54 |
+
)
|
| 55 |
+
->setOrderId($order->getIncrementId())
|
| 56 |
+
->setTransactionReference($order->getIncrementId());
|
| 57 |
+
|
| 58 |
+
$supportedCurrencies = $helper->getSupportedCurrencies();
|
| 59 |
+
if (array_key_exists($order->getOrderCurrencyCode(), $supportedCurrencies)) {
|
| 60 |
+
// convert from Magento code to Buyster One
|
| 61 |
+
$this->setCurrencyCode($supportedCurrencies[$order->getOrderCurrencyCode()]);
|
| 62 |
+
} else {
|
| 63 |
+
Mage::throwException(
|
| 64 |
+
$helper->__('%s currency is not supported by Buyster', $order->getOrderCurrencyCode())
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
/**
|
| 71 |
+
* Return Buyster helper
|
| 72 |
+
*
|
| 73 |
+
* @return mixed
|
| 74 |
+
*/
|
| 75 |
+
protected function _getHelper()
|
| 76 |
+
{
|
| 77 |
+
return Mage::helper('buyster');
|
| 78 |
+
}
|
| 79 |
+
}
|
app/code/community/Buyster/Buyster/Model/Service/Payment/Initialize/Response.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster SOAP response for initializePayment method
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Service_Payment_Initialize_Response extends Buyster_Buyster_Model_Service_Message_Abstract
|
| 11 |
+
{
|
| 12 |
+
}
|
app/code/community/Buyster/Buyster/Model/Standard.php
ADDED
|
@@ -0,0 +1,692 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster payment method adapter
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_Standard extends Mage_Payment_Model_Method_Abstract
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* unique internal payment method identifier
|
| 14 |
+
*
|
| 15 |
+
* @var string
|
| 16 |
+
*/
|
| 17 |
+
protected $_code = 'buyster';
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* ResponseCode to validate order
|
| 21 |
+
* Code returned by Buyste
|
| 22 |
+
*
|
| 23 |
+
* @var array
|
| 24 |
+
*/
|
| 25 |
+
protected $_validateCodes = array('00');
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* ResponseCode to cancel order
|
| 29 |
+
* Code returned by Buyste
|
| 30 |
+
*
|
| 31 |
+
* @var array
|
| 32 |
+
*/
|
| 33 |
+
protected $_cancelCodes = array('17');
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* ResponseCode to block order
|
| 37 |
+
* Code returned by Buyste
|
| 38 |
+
*
|
| 39 |
+
* @var array
|
| 40 |
+
*/
|
| 41 |
+
protected $_onHoldCodes = array('05', '34', '40', '69', '75', '99');
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* Is this payment method a gateway (online auth/charge) ?
|
| 45 |
+
*/
|
| 46 |
+
protected $_isGateway = true;
|
| 47 |
+
|
| 48 |
+
/**
|
| 49 |
+
* Can authorize online?
|
| 50 |
+
*/
|
| 51 |
+
protected $_canAuthorize = true;
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* Can capture funds online?
|
| 55 |
+
*/
|
| 56 |
+
protected $_canCapture = true;
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* Can capture partial amounts online?
|
| 60 |
+
*/
|
| 61 |
+
protected $_canCapturePartial = false;
|
| 62 |
+
|
| 63 |
+
/**
|
| 64 |
+
* Can refund online?
|
| 65 |
+
*/
|
| 66 |
+
protected $_canRefund = true;
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* Can refund partially
|
| 70 |
+
*/
|
| 71 |
+
protected $_canRefundInvoicePartial = true;
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Can void transactions online?
|
| 75 |
+
*/
|
| 76 |
+
protected $_canVoid = true;
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Can use this payment method in administration panel?
|
| 80 |
+
*/
|
| 81 |
+
protected $_canUseInternal = true;
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* Can show this payment method as an option on checkout payment page?
|
| 85 |
+
*/
|
| 86 |
+
protected $_canUseCheckout = true;
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* Is this payment method suitable for multi-shipping checkout?
|
| 90 |
+
*/
|
| 91 |
+
protected $_canUseForMultishipping = true;
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* Can save credit card information?
|
| 95 |
+
*/
|
| 96 |
+
protected $_canSaveCc = false;
|
| 97 |
+
|
| 98 |
+
/**
|
| 99 |
+
* Add transaction to current order
|
| 100 |
+
*
|
| 101 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 102 |
+
* @param Varien_Object $data Data from Buyster, after validation
|
| 103 |
+
*
|
| 104 |
+
* @return void
|
| 105 |
+
*/
|
| 106 |
+
protected function _addTransaction($order, $data)
|
| 107 |
+
{
|
| 108 |
+
$authorisationId = $data->getAuthorisationId();
|
| 109 |
+
$detailResponseCode = $data->getResponseCode();
|
| 110 |
+
$enrollmentIndicator = $data->getEnrollmentIndicator();
|
| 111 |
+
$guaranteeIndicator = $data->getGuaranteeIndicator();
|
| 112 |
+
$transactionReference = $data->getTransactionReference();
|
| 113 |
+
$responseCode = $data->getResponseCode();
|
| 114 |
+
$responseDescription = $data->getResponseDescription();
|
| 115 |
+
$status = $data->getStatus();
|
| 116 |
+
$transactionDateTime = urldecode($data->getTransactionDateTime());
|
| 117 |
+
$transactionType = $this->_getHelper()->getTransactionType();
|
| 118 |
+
$transactionParameters = $this->_getHelper()->getTransactionParameters();
|
| 119 |
+
$transactionRawDetails = $this->_getHelper()->getTransactionRawDetails($data);
|
| 120 |
+
|
| 121 |
+
if ($order) {
|
| 122 |
+
// Check if transaction already exists
|
| 123 |
+
$transaction = $order->getPayment()->getTransaction($authorisationId);
|
| 124 |
+
|
| 125 |
+
// Log warning if transaction already exists
|
| 126 |
+
if ($transaction != false) {
|
| 127 |
+
$msg = 'Buyster : Transaction ' . $authorisationId .
|
| 128 |
+
' already exists for order ' . $transactionReference;
|
| 129 |
+
Mage::log(
|
| 130 |
+
$msg,
|
| 131 |
+
Zend_Log::ERR,
|
| 132 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 133 |
+
);
|
| 134 |
+
Mage::throwException($msg);
|
| 135 |
+
} else {
|
| 136 |
+
$transaction = Mage::getModel('sales/order_payment_transaction');
|
| 137 |
+
$transaction->setOrder($order)
|
| 138 |
+
->setTxnId($authorisationId)
|
| 139 |
+
->setOrderPaymentObject($order->getPayment())
|
| 140 |
+
->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)
|
| 141 |
+
->setIsClosed(false)
|
| 142 |
+
->setAdditionalInformation(
|
| 143 |
+
Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
|
| 144 |
+
$transactionRawDetails
|
| 145 |
+
)
|
| 146 |
+
->save();
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* Check response data integrity and return response formatted as
|
| 153 |
+
* Buyster_Buyster_Model_Service_Payment_Initialize_Response
|
| 154 |
+
*
|
| 155 |
+
* @param array $data Data from Buyster server from $_POST
|
| 156 |
+
*
|
| 157 |
+
* @throws Mage_Core_Exception If mandatory parameters are missing
|
| 158 |
+
* @return Buyster_Buyster_Model_Service_Payment_Initialize_Response
|
| 159 |
+
*/
|
| 160 |
+
protected function _validate($data)
|
| 161 |
+
{
|
| 162 |
+
$validatedData = $data;
|
| 163 |
+
|
| 164 |
+
// Check if all parameters contain data
|
| 165 |
+
foreach ($data as $key => $value) {
|
| 166 |
+
if ($value === '') {
|
| 167 |
+
Mage::throwException('Buyster : ' . $key . ' parameter should not be empty.');
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
$response = Mage::getModel('buyster/service_payment_initialize_response');
|
| 172 |
+
// Call web service
|
| 173 |
+
$response->addData($data);
|
| 174 |
+
|
| 175 |
+
return $response->addData($data);
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* Check if currency is supported by Buyster
|
| 180 |
+
*
|
| 181 |
+
* @param string $currencyCode Currency code
|
| 182 |
+
*
|
| 183 |
+
* @return boolean
|
| 184 |
+
*/
|
| 185 |
+
public function canUseForCurrency($currencyCode)
|
| 186 |
+
{
|
| 187 |
+
return array_key_exists($currencyCode, $this->_getHelper()->getSupportedCurrencies());
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
/**
|
| 191 |
+
* Redirect if Buyster payment is used
|
| 192 |
+
*
|
| 193 |
+
* @see Mage_Checkout_Model_Type_Onepage (getOrderPlaceRedirectUrl line 790)
|
| 194 |
+
*
|
| 195 |
+
* @return string Order Redirect URL
|
| 196 |
+
*/
|
| 197 |
+
public function getOrderPlaceRedirectUrl()
|
| 198 |
+
{
|
| 199 |
+
return Mage::getUrl('buyster/payment/redirect');
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
/**
|
| 203 |
+
* Call SOAP web service method initializePayment
|
| 204 |
+
* and return Redirection URL to display on interstitial
|
| 205 |
+
* page to initialize Buyster payment
|
| 206 |
+
*
|
| 207 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 208 |
+
*
|
| 209 |
+
* @return Buyster_Buyster_Model_Service_Payment_Initialize_Response
|
| 210 |
+
*/
|
| 211 |
+
public function initializePayment($order)
|
| 212 |
+
{
|
| 213 |
+
$service = Mage::getSingleton('buyster/service');
|
| 214 |
+
$requestResponse = $service->initializePayment($order);
|
| 215 |
+
|
| 216 |
+
if (
|
| 217 |
+
$requestResponse->getResponse()->getResponseCode() !=
|
| 218 |
+
Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 219 |
+
) {
|
| 220 |
+
/**
|
| 221 |
+
* If responseCode NOK
|
| 222 |
+
*/
|
| 223 |
+
|
| 224 |
+
// Cancel order
|
| 225 |
+
$msg = $requestResponse->getResponse()->getResponseDescription();
|
| 226 |
+
|
| 227 |
+
// Cancel order only if its status was pending payment. Do nothing when order status is different
|
| 228 |
+
if (!empty($msg) && $order->getStatus() == Mage::getStoreConfig('payment/buyster/order_status')) {
|
| 229 |
+
$order->addStatusHistoryComment(
|
| 230 |
+
'Buyster : ' . $msg,
|
| 231 |
+
Mage::getStoreConfig('payment/buyster/canceled_order_status')
|
| 232 |
+
);
|
| 233 |
+
}
|
| 234 |
+
$order->save();
|
| 235 |
+
|
| 236 |
+
// Log request and response in buyster.log
|
| 237 |
+
$service->logError($requestResponse, 'initializePayment');
|
| 238 |
+
|
| 239 |
+
// Restore cart
|
| 240 |
+
$this->restoreCart();
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
return $requestResponse->getResponse();
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
/**
|
| 247 |
+
* Call SOAP web service method cashManagementOperation
|
| 248 |
+
*
|
| 249 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 250 |
+
* @param string $operationName Operation Name
|
| 251 |
+
* @param string $amount Total due invoice amount
|
| 252 |
+
*
|
| 253 |
+
* @return Buyster_Buyster_Model_Service_Payment_Cashmanagement_Response
|
| 254 |
+
*/
|
| 255 |
+
public function cashManagementOperation($order, $operationName, $amount=null)
|
| 256 |
+
{
|
| 257 |
+
$service = Mage::getSingleton('buyster/service');
|
| 258 |
+
$requestResponse = $service->cashManagementOperation($order, $operationName, $amount);
|
| 259 |
+
|
| 260 |
+
if (
|
| 261 |
+
$requestResponse->getResponse()->getResponseCode() !=
|
| 262 |
+
Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 263 |
+
) {
|
| 264 |
+
/**
|
| 265 |
+
* If responseCode NOK
|
| 266 |
+
* -> log request and response
|
| 267 |
+
*/
|
| 268 |
+
$service->logError($requestResponse, 'cashManagementOperation', 'MODE=' . $operationName);
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
return $requestResponse->getResponse();
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* Operate with order using data from $_POST which came from Buyster server
|
| 276 |
+
*
|
| 277 |
+
* @param array $data Data from Buyster server from $_POST
|
| 278 |
+
*
|
| 279 |
+
* @throws Mage_Core_Exception in case of validation error or order creation error
|
| 280 |
+
* @return void
|
| 281 |
+
*/
|
| 282 |
+
public function automaticProcess($data)
|
| 283 |
+
{
|
| 284 |
+
// Check response integrity
|
| 285 |
+
$validatedData = $this->_validate($data);
|
| 286 |
+
$responseCode = $validatedData->getResponseCode();
|
| 287 |
+
$transactionReference = $validatedData->getTransactionReference();
|
| 288 |
+
$responseDescription = $validatedData->getResponseDescription();
|
| 289 |
+
|
| 290 |
+
// Check response code
|
| 291 |
+
if ($responseCode === '') {
|
| 292 |
+
Mage::throwException('responseCode should not be empty in automaticProcess');
|
| 293 |
+
} else if ($transactionReference === '') {
|
| 294 |
+
Mage::throwException('transactionReference should not be empty in automaticProcess');
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Load order
|
| 298 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($transactionReference);
|
| 299 |
+
if (empty($order)) {
|
| 300 |
+
Mage::throwException('Order ' . $transactionReference . ' does not exist or could not be loaded.');
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
// Order must be validated
|
| 304 |
+
if (in_array($responseCode, $this->_validateCodes)) {
|
| 305 |
+
|
| 306 |
+
// Update order status
|
| 307 |
+
if ($validatedData['status'] == Buyster_Buyster_Model_Service::TO_VALIDATE) {
|
| 308 |
+
// If payment with validation, set specific status -> pending_validation
|
| 309 |
+
$order->setStatus(Buyster_Buyster_Model_Service::STATUS_PENDING_VALIDATION);
|
| 310 |
+
} else {
|
| 311 |
+
// In other cases, set status defined in system config -> validated by default
|
| 312 |
+
$order->setStatus(Mage::getStoreConfig('payment/buyster/authorized_order_status'));
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
// Add transaction to order
|
| 316 |
+
$this->_addTransaction($order, $validatedData);
|
| 317 |
+
|
| 318 |
+
// Send confirm email
|
| 319 |
+
try {
|
| 320 |
+
$order->sendNewOrderEmail();
|
| 321 |
+
} catch (Exception $e) {
|
| 322 |
+
Mage::log(
|
| 323 |
+
$e->getMessage(),
|
| 324 |
+
Zend_Log::ERR,
|
| 325 |
+
Buyster_Buyster_Model_Service::LOGFILE
|
| 326 |
+
);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
} else if (in_array($responseCode, $this->_cancelCodes)) {
|
| 330 |
+
// Order must be canceled
|
| 331 |
+
$order->setStatus(Mage::getStoreConfig('payment/buyster/canceled_order_status'));
|
| 332 |
+
} else if (in_array($responseCode, $this->_onHoldCodes)) {
|
| 333 |
+
// Order must be blocked
|
| 334 |
+
$order->setStatus(Mage::getStoreConfig('payment/buyster/refused_order_status'));
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
// Add order status history comment
|
| 338 |
+
if (!empty($responseDescription)) {
|
| 339 |
+
$order->addStatusHistoryComment('Buyster : ' . urldecode($responseDescription));
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
// Disable canInvoice if paymentType is payment or paymentDelayed
|
| 343 |
+
$this->_getHelper()->disableCanInvoice($order);
|
| 344 |
+
|
| 345 |
+
// Save order modifications
|
| 346 |
+
$order->save();
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* Restore last cart using quote in session
|
| 351 |
+
*
|
| 352 |
+
* @return void
|
| 353 |
+
*/
|
| 354 |
+
public function restoreCart()
|
| 355 |
+
{
|
| 356 |
+
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 357 |
+
if ($incrementId != false) {
|
| 358 |
+
$lastOrder = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
| 359 |
+
$lastQuoteId = $lastOrder->getQuoteId();
|
| 360 |
+
$lastQuote = Mage::getModel('sales/quote')->load($lastQuoteId);
|
| 361 |
+
$lastQuote->setIsActive(true)->save();
|
| 362 |
+
}
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
/**
|
| 366 |
+
* Capture payment and emit invoice
|
| 367 |
+
*
|
| 368 |
+
* @param Varien_Object $payment Order payment
|
| 369 |
+
* @param string $amount Order amount
|
| 370 |
+
*
|
| 371 |
+
* @return Buyster_Buyster_Model_Standard
|
| 372 |
+
*/
|
| 373 |
+
public function capture(Varien_Object $payment, $amount)
|
| 374 |
+
{
|
| 375 |
+
parent::capture($payment, $amount);
|
| 376 |
+
|
| 377 |
+
// Retrieve order
|
| 378 |
+
$order = $payment->getOrder();
|
| 379 |
+
if ($order->getStatus() == Mage::getStoreConfig('payment/buyster/order_status')) {
|
| 380 |
+
Mage::throwException(
|
| 381 |
+
$this->_getHelper()->__('This order cannot be invoiced before validation')
|
| 382 |
+
);
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
// Retrieve transaction
|
| 386 |
+
$transaction = $payment->getAuthorizationTransaction();
|
| 387 |
+
|
| 388 |
+
// Filter 'buyster' payments
|
| 389 |
+
if ($transaction && $payment->getMethod() == Buyster_Buyster_Model_Service::CODE) {
|
| 390 |
+
|
| 391 |
+
// Load transaction details
|
| 392 |
+
$transactionDetails = $this->_getHelper()->getTransactionDetails($transaction);
|
| 393 |
+
$transactionType = $transactionDetails->getTransactionType();
|
| 394 |
+
|
| 395 |
+
// Filter transactionType = 'paymentValidation'
|
| 396 |
+
if (
|
| 397 |
+
$transactionType == Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION
|
| 398 |
+
) {
|
| 399 |
+
|
| 400 |
+
// Web service diagnostic
|
| 401 |
+
$response = $this->cashManagementOperation(
|
| 402 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 403 |
+
);
|
| 404 |
+
|
| 405 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 406 |
+
|
| 407 |
+
/**
|
| 408 |
+
* Normal case: Buyster status is TO_VALIDATE
|
| 409 |
+
* Can perform OPERATION_VALIDATE
|
| 410 |
+
*/
|
| 411 |
+
if ($response->getStatus() == Buyster_Buyster_Model_Service::TO_VALIDATE) {
|
| 412 |
+
|
| 413 |
+
// Call cashManagementOperation method in SOAP web service, with operationName VALIDATE
|
| 414 |
+
$response = $this->cashManagementOperation(
|
| 415 |
+
$order,
|
| 416 |
+
Buyster_Buyster_Model_Service::OPERATION_VALIDATE,
|
| 417 |
+
$amount
|
| 418 |
+
);
|
| 419 |
+
|
| 420 |
+
// operation VALIDATE is success
|
| 421 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 422 |
+
|
| 423 |
+
// Update guarantee information in transaction details
|
| 424 |
+
$addInfo = $transaction->getAdditionalInformation('raw_details_info');
|
| 425 |
+
if (
|
| 426 |
+
array_key_exists('guaranteeIndicator', $addInfo) &&
|
| 427 |
+
array_key_exists('Garantie', $addInfo)
|
| 428 |
+
) {
|
| 429 |
+
$addInfo['guaranteeIndicator'] = $response->getGuaranteeIndicator();
|
| 430 |
+
$addInfo['Garantie'] = $this->_getHelper()->getGuaranteeDescription(
|
| 431 |
+
$response->getGuaranteeIndicator()
|
| 432 |
+
);
|
| 433 |
+
}
|
| 434 |
+
$transaction->setAdditionalInformation('raw_details_info', $addInfo);
|
| 435 |
+
$transaction->save();
|
| 436 |
+
|
| 437 |
+
/**
|
| 438 |
+
* Order status is set to 'validated'
|
| 439 |
+
* and invoice is emitted but its status is STATE_OPEN, and not STATE_PAID
|
| 440 |
+
* @see Mage_Sales_Model_Order_Payment->capture
|
| 441 |
+
*/
|
| 442 |
+
$payment->setIsTransactionPending(true);
|
| 443 |
+
|
| 444 |
+
} else {
|
| 445 |
+
|
| 446 |
+
// Add comments in order status history
|
| 447 |
+
$order->addStatusHistoryComment('Buyster : ' . utf8_decode($response->getResponseDescription()));
|
| 448 |
+
$order->save();
|
| 449 |
+
|
| 450 |
+
// Error => Display description
|
| 451 |
+
Mage::throwException('Buyster : ' . utf8_decode($response->getResponseDescription()));
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
} else if ($response->getStatus() == Buyster_Buyster_Model_Service::TO_CAPTURE) {
|
| 455 |
+
|
| 456 |
+
/**
|
| 457 |
+
* If order has been validated by Buyster in the meantime,
|
| 458 |
+
* Order status is set to 'validated'
|
| 459 |
+
* and invoice is emitted but its status is STATE_OPEN, and not STATE_PAID
|
| 460 |
+
* @see Mage_Sales_Model_Order_Payment->capture
|
| 461 |
+
*/
|
| 462 |
+
$payment->setIsTransactionPending(true);
|
| 463 |
+
|
| 464 |
+
// Add comments in order status history
|
| 465 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__(
|
| 466 |
+
"Transaction validated by Buyster in the meantime."
|
| 467 |
+
);
|
| 468 |
+
$order->addStatusHistoryComment($msg);
|
| 469 |
+
$order->save();
|
| 470 |
+
|
| 471 |
+
} else if ($response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 472 |
+
|
| 473 |
+
/**
|
| 474 |
+
* If order has been captured by Buyster in the meantime,
|
| 475 |
+
* Order status is set to 'processing'
|
| 476 |
+
* and invoice is emitted with status STATE_PAID (native behavior, nothing to do)
|
| 477 |
+
* @see Mage_Sales_Model_Order_Payment->capture
|
| 478 |
+
*/
|
| 479 |
+
|
| 480 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__(
|
| 481 |
+
"Transaction captured by Buyster in the meantime."
|
| 482 |
+
);
|
| 483 |
+
$order->addStatusHistoryComment($msg);
|
| 484 |
+
$order->save();
|
| 485 |
+
|
| 486 |
+
} else if ($response->getStatus() == Buyster_Buyster_Model_Service::EXPIRED) {
|
| 487 |
+
|
| 488 |
+
// If order has expired => set status to 'expired'
|
| 489 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__("Validay delay is outdated");
|
| 490 |
+
$order->addStatusHistoryComment($msg, Buyster_Buyster_Model_Service::STATUS_EXPIRED);
|
| 491 |
+
$order->save();
|
| 492 |
+
|
| 493 |
+
// Error => Display description
|
| 494 |
+
Mage::throwException($this->_getHelper()->__('Validay delay is outdated'));
|
| 495 |
+
}
|
| 496 |
+
|
| 497 |
+
} else {
|
| 498 |
+
|
| 499 |
+
// Diagnostic failed. Error => Display description
|
| 500 |
+
Mage::throwException('Buyster : ' . utf8_decode($response->getResponseDescription()));
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
} else {
|
| 504 |
+
// $transactionType == 'payment' OR 'paymentDelayed' -> nothing to do
|
| 505 |
+
}
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
return $this;
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
/**
|
| 512 |
+
* Cancel transaction online
|
| 513 |
+
* if transactionType = 'payment' or 'paymentDelayed'
|
| 514 |
+
* -> perform diagnostic before cancelling for real
|
| 515 |
+
* if transactionType = 'paymentValidation'
|
| 516 |
+
* -> cancel Magento side and do nothing Buyster side -> order will expire
|
| 517 |
+
*
|
| 518 |
+
* @param Varien_Object $payment Order payment
|
| 519 |
+
*
|
| 520 |
+
* @return Buyster_Buyster_Model_Standard
|
| 521 |
+
*/
|
| 522 |
+
public function cancel(Varien_Object $payment)
|
| 523 |
+
{
|
| 524 |
+
parent::cancel($payment);
|
| 525 |
+
|
| 526 |
+
$order = $payment->getOrder();
|
| 527 |
+
|
| 528 |
+
// Nothing to do if transactionType == 'paymentValidation'
|
| 529 |
+
$transactionType = $this->_getHelper()->getOrderTransactionType($order);
|
| 530 |
+
if ($transactionType != Buyster_Buyster_Model_Service::TRANSACTION_TYPE_VALIDATION) {
|
| 531 |
+
|
| 532 |
+
// Web service diagnostic
|
| 533 |
+
$response = $this->cashManagementOperation(
|
| 534 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 535 |
+
);
|
| 536 |
+
|
| 537 |
+
/**
|
| 538 |
+
* If order has been captured by Buyster in the meantime,
|
| 539 |
+
* REFUND all this order Buyster side
|
| 540 |
+
*/
|
| 541 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 542 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 543 |
+
|
| 544 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__(
|
| 545 |
+
"Transaction captured by Buyster in the meantime. Cannot be canceled, will be refunded."
|
| 546 |
+
);
|
| 547 |
+
$order->addStatusHistoryComment($msg);
|
| 548 |
+
|
| 549 |
+
// Refund all
|
| 550 |
+
$amount = $payment->getOrder()->getGrandTotal();
|
| 551 |
+
$this->operationRefund($order, $amount);
|
| 552 |
+
|
| 553 |
+
} else if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 554 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::TO_CAPTURE) {
|
| 555 |
+
|
| 556 |
+
// Perform cancel operation
|
| 557 |
+
$this->operationCancel($order);
|
| 558 |
+
|
| 559 |
+
} else {
|
| 560 |
+
// Else display message
|
| 561 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__(
|
| 562 |
+
"Current transaction status does not allow to cancel order"
|
| 563 |
+
);
|
| 564 |
+
Mage::getSingleton('adminhtml/session')->addWarning($msg);
|
| 565 |
+
}
|
| 566 |
+
} else {
|
| 567 |
+
// No online call to perform for paymentValidation transactions -> just wait for transaction to expire
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
return $this;
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
/**
|
| 574 |
+
* Perform cancel operation calling Buyster web service
|
| 575 |
+
* and updating order status and comments
|
| 576 |
+
*
|
| 577 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 578 |
+
*
|
| 579 |
+
* @return void
|
| 580 |
+
*/
|
| 581 |
+
public function operationCancel($order)
|
| 582 |
+
{
|
| 583 |
+
// Call web service cancel method
|
| 584 |
+
$response = $this->cashManagementOperation(
|
| 585 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_CANCEL
|
| 586 |
+
);
|
| 587 |
+
|
| 588 |
+
// Cancel Buyster side is OK
|
| 589 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 590 |
+
|
| 591 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__("Order cancellation has been performed successfully.");
|
| 592 |
+
|
| 593 |
+
$order->addStatusHistoryComment($msg, Mage::getStoreConfig('payment/buyster/canceled_order_status'));
|
| 594 |
+
$order->setStatus(Mage::getStoreConfig('payment/buyster/canceled_order_status'));
|
| 595 |
+
|
| 596 |
+
} else {
|
| 597 |
+
|
| 598 |
+
// Cancel Buyster side is NOK
|
| 599 |
+
$msg = 'Buyster : ' . utf8_decode($response->getResponseDescription());
|
| 600 |
+
$order->addStatusHistoryComment($msg);
|
| 601 |
+
$order->setStatus(Mage::getStoreConfig('payment/buyster/canceled_order_status'));
|
| 602 |
+
|
| 603 |
+
Mage::throwException($msg);
|
| 604 |
+
}
|
| 605 |
+
}
|
| 606 |
+
|
| 607 |
+
/**
|
| 608 |
+
* Refund order
|
| 609 |
+
* Can be partial or total
|
| 610 |
+
*
|
| 611 |
+
* @param Varien_Object $payment Invoice payment
|
| 612 |
+
* @param float $amount Amount to refund
|
| 613 |
+
*
|
| 614 |
+
* @return Buyster_Buyster_Model_Standard
|
| 615 |
+
*/
|
| 616 |
+
public function refund(Varien_Object $payment, $amount)
|
| 617 |
+
{
|
| 618 |
+
parent::refund($payment, $amount);
|
| 619 |
+
|
| 620 |
+
// Retrieve order
|
| 621 |
+
$order = $payment->getOrder();
|
| 622 |
+
|
| 623 |
+
// Web service diagnostic
|
| 624 |
+
$response = $this->cashManagementOperation(
|
| 625 |
+
$order, Buyster_Buyster_Model_Service::OPERATION_DIAGNOSTIC
|
| 626 |
+
);
|
| 627 |
+
|
| 628 |
+
/**
|
| 629 |
+
* If transaction status Buyster side id CAPTURED => perform refund
|
| 630 |
+
*/
|
| 631 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS
|
| 632 |
+
&& $response->getStatus() == Buyster_Buyster_Model_Service::CAPTURED) {
|
| 633 |
+
|
| 634 |
+
$this->operationRefund($order, $amount);
|
| 635 |
+
|
| 636 |
+
} else {
|
| 637 |
+
$msg = 'Buyster : ' . $this->_getHelper()->__("Transaction status does not allow to perform refund");
|
| 638 |
+
$order->addStatusHistoryComment($msg);
|
| 639 |
+
$order->save();
|
| 640 |
+
Mage::throwException($msg);
|
| 641 |
+
}
|
| 642 |
+
|
| 643 |
+
return $this;
|
| 644 |
+
}
|
| 645 |
+
|
| 646 |
+
/**
|
| 647 |
+
* Perform refund operation calling Buyster web service
|
| 648 |
+
* and updating order status and comments
|
| 649 |
+
*
|
| 650 |
+
* @param Mage_Sales_Model_Order $order Current order
|
| 651 |
+
* @param float $amount Amount to refund
|
| 652 |
+
*
|
| 653 |
+
* @return void
|
| 654 |
+
*/
|
| 655 |
+
public function operationRefund($order, $amount)
|
| 656 |
+
{
|
| 657 |
+
// Call cashManagementOperation method in SOAP web service, with operationName REFUND
|
| 658 |
+
$response = $this->cashManagementOperation(
|
| 659 |
+
$order,
|
| 660 |
+
Buyster_Buyster_Model_Service::OPERATION_REFUND,
|
| 661 |
+
$amount
|
| 662 |
+
);
|
| 663 |
+
|
| 664 |
+
// Success
|
| 665 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 666 |
+
|
| 667 |
+
/**
|
| 668 |
+
* Order status is unchanged ('processing') if some order items are not refunded or not shipped
|
| 669 |
+
* Nothing to do -> native Magento behavior
|
| 670 |
+
*/
|
| 671 |
+
|
| 672 |
+
} else {
|
| 673 |
+
|
| 674 |
+
// Add comments in order status history
|
| 675 |
+
$msg = 'Buyster : ' . utf8_decode($response->getResponseDescription());
|
| 676 |
+
$order->addStatusHistoryComment($msg);
|
| 677 |
+
|
| 678 |
+
// Error => Display description
|
| 679 |
+
Mage::throwException($msg);
|
| 680 |
+
}
|
| 681 |
+
}
|
| 682 |
+
|
| 683 |
+
/**
|
| 684 |
+
* Retrieve model helper
|
| 685 |
+
*
|
| 686 |
+
* @return Buyster_Buyster_Helper_Data
|
| 687 |
+
*/
|
| 688 |
+
protected function _getHelper()
|
| 689 |
+
{
|
| 690 |
+
return Mage::helper('buyster');
|
| 691 |
+
}
|
| 692 |
+
}
|
app/code/community/Buyster/Buyster/Model/System/Config/Source/Order/Status.php
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Order Statuses available for order_status field (@see system.xml)
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_System_Config_Source_Order_Status extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
|
| 11 |
+
{
|
| 12 |
+
protected $_stateStatuses = array(
|
| 13 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
| 14 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
| 15 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
| 16 |
+
);
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Unique key to avoid bug while caching statuses array
|
| 20 |
+
*
|
| 21 |
+
* @var string
|
| 22 |
+
*/
|
| 23 |
+
protected $_uniqueKey = 'buyster_order_status';
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Display order statuses in Back Office config
|
| 27 |
+
*
|
| 28 |
+
* @return array
|
| 29 |
+
*/
|
| 30 |
+
public function toOptionArray()
|
| 31 |
+
{
|
| 32 |
+
if ($this->_stateStatuses) {
|
| 33 |
+
$statuses = Mage::getSingleton('buyster/order_config')
|
| 34 |
+
->getStateStatuses($this->_stateStatuses, true, $this->_uniqueKey);
|
| 35 |
+
} else {
|
| 36 |
+
$statuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
$options = array();
|
| 40 |
+
$options[] = array(
|
| 41 |
+
'value' => '',
|
| 42 |
+
'label' => Mage::helper('adminhtml')->__('-- Please Select --')
|
| 43 |
+
);
|
| 44 |
+
foreach ($statuses as $code=>$label) {
|
| 45 |
+
$options[] = array(
|
| 46 |
+
'value' => $code,
|
| 47 |
+
'label' => $label
|
| 48 |
+
);
|
| 49 |
+
}
|
| 50 |
+
return $options;
|
| 51 |
+
}
|
| 52 |
+
}
|
app/code/community/Buyster/Buyster/Model/System/Config/Source/Order/Status/Final.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Order Statuses available for authorized_order_status, refused_order_status and canceled_order_status
|
| 4 |
+
* fields (@see system.xml), at final step
|
| 5 |
+
*
|
| 6 |
+
* @category Buyster
|
| 7 |
+
* @package Buyster_Buyster
|
| 8 |
+
* @copyright 2011 Buyster
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
class Buyster_Buyster_Model_System_Config_Source_Order_Status_Final extends Buyster_Buyster_Model_System_Config_Source_Order_Status
|
| 12 |
+
{
|
| 13 |
+
protected $_stateStatuses = array(
|
| 14 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
| 15 |
+
Mage_Sales_Model_Order::STATE_COMPLETE,
|
| 16 |
+
Mage_Sales_Model_Order::STATE_CLOSED,
|
| 17 |
+
Mage_Sales_Model_Order::STATE_CANCELED,
|
| 18 |
+
Mage_Sales_Model_Order::STATE_HOLDED,
|
| 19 |
+
Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW
|
| 20 |
+
);
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* Unique key to avoid bug while caching statuses array
|
| 24 |
+
*
|
| 25 |
+
* @var string
|
| 26 |
+
*/
|
| 27 |
+
protected $_uniqueKey = 'buyster_order_status_final';
|
| 28 |
+
}
|
app/code/community/Buyster/Buyster/Model/System/Config/Source/Paymenttype.php
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Used in creating options for payment_type config value selection (@see system.xml)
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_System_Config_Source_Paymenttype
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Options getter
|
| 14 |
+
* 3 possible values: payment, paymentDelayed and paymentValidation
|
| 15 |
+
*
|
| 16 |
+
* @return array
|
| 17 |
+
*/
|
| 18 |
+
public function toOptionArray()
|
| 19 |
+
{
|
| 20 |
+
return array(
|
| 21 |
+
array(
|
| 22 |
+
'value' => 'payment',
|
| 23 |
+
'label' => Mage::helper('buyster')->__('Simple payment')
|
| 24 |
+
),
|
| 25 |
+
array(
|
| 26 |
+
'value' => 'paymentDelayed',
|
| 27 |
+
'label' => Mage::helper('buyster')->__('Delayed payment')
|
| 28 |
+
),
|
| 29 |
+
array(
|
| 30 |
+
'value' => 'paymentValidation',
|
| 31 |
+
'label' => Mage::helper('buyster')->__('Validation payment')
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
);
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
}
|
app/code/community/Buyster/Buyster/Model/System/Config/Source/Serviceurl.php
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Used in creating options for service_url config value selection (@see system.xml)
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_Model_System_Config_Source_Serviceurl
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Options getter
|
| 14 |
+
* 2 possible values: Production and Test
|
| 15 |
+
* Use default url values defined in config.xml
|
| 16 |
+
* Cannot be changed manually in Back Office
|
| 17 |
+
*
|
| 18 |
+
* @return array
|
| 19 |
+
*/
|
| 20 |
+
public function toOptionArray()
|
| 21 |
+
{
|
| 22 |
+
return array(
|
| 23 |
+
array(
|
| 24 |
+
'value' => Mage::getConfig()->getNode('global/buyster/service_url/production')->asArray(),
|
| 25 |
+
'label' => Mage::helper('buyster')->__('Production')
|
| 26 |
+
),
|
| 27 |
+
array(
|
| 28 |
+
'value' => Mage::getConfig()->getNode('global/buyster/service_url/test')->asArray(),
|
| 29 |
+
'label' => Mage::helper('buyster')->__('Test')
|
| 30 |
+
)
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
}
|
app/code/community/Buyster/Buyster/controllers/PaymentController.php
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Buyster Payment Controller
|
| 4 |
+
*
|
| 5 |
+
* @category Buyster
|
| 6 |
+
* @package Buyster_Buyster
|
| 7 |
+
* @copyright 2011 Buyster
|
| 8 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 9 |
+
*/
|
| 10 |
+
class Buyster_Buyster_PaymentController extends Mage_Core_Controller_Front_Action
|
| 11 |
+
{
|
| 12 |
+
/**
|
| 13 |
+
* Call Buyster web service and display interstitial page if possible
|
| 14 |
+
* If problem occurs, log and redirect to checkout cart
|
| 15 |
+
*
|
| 16 |
+
* @return void
|
| 17 |
+
*/
|
| 18 |
+
public function redirectAction()
|
| 19 |
+
{
|
| 20 |
+
// Retrieve order from session
|
| 21 |
+
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
| 22 |
+
if ($incrementId == false) {
|
| 23 |
+
// Session lost -> redirect to cart
|
| 24 |
+
$this->_redirect('checkout/cart');
|
| 25 |
+
|
| 26 |
+
} else {
|
| 27 |
+
|
| 28 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
| 29 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
| 30 |
+
$helper = Mage::helper('buyster');
|
| 31 |
+
|
| 32 |
+
// Check if Buyster payment is being used
|
| 33 |
+
if ($order->getPayment()->getMethod() == "buyster") {
|
| 34 |
+
|
| 35 |
+
try {
|
| 36 |
+
|
| 37 |
+
$paymentMethod = Mage::getModel('buyster/standard');
|
| 38 |
+
|
| 39 |
+
// Process order payment
|
| 40 |
+
$response = $paymentMethod->initializePayment($order);
|
| 41 |
+
$redirectionUrl = $response->getRedirectionURL();
|
| 42 |
+
$this->loadLayout();
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* Check responseCode
|
| 46 |
+
* -> 00 = OK
|
| 47 |
+
* -> other = NOK
|
| 48 |
+
*/
|
| 49 |
+
if ($response->getResponseCode() == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 50 |
+
// Load redirect page with correct link given
|
| 51 |
+
$this->getLayout()->getBlock('buyster_redirect')->setLink($redirectionUrl);
|
| 52 |
+
}
|
| 53 |
+
$this->renderLayout();
|
| 54 |
+
|
| 55 |
+
} catch (Exception $e) {
|
| 56 |
+
|
| 57 |
+
// Retrieve message
|
| 58 |
+
$msg = $e->getMessage();
|
| 59 |
+
|
| 60 |
+
// Log error
|
| 61 |
+
Mage::log($msg, Zend_Log::ERR, Buyster_Buyster_Model_Service::LOGFILE);
|
| 62 |
+
|
| 63 |
+
// Add error message in session to be displayed in cart
|
| 64 |
+
$checkoutSession->addError($msg);
|
| 65 |
+
|
| 66 |
+
// Redirect to cart
|
| 67 |
+
$this->_redirect('checkout/cart');
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Buyster servers directly call that action
|
| 75 |
+
* to manage order update and associate operations
|
| 76 |
+
* Asynchronous mode, server to server
|
| 77 |
+
*
|
| 78 |
+
* @see automaticResponseUrl in SOAP web service parameters
|
| 79 |
+
*
|
| 80 |
+
* @return void
|
| 81 |
+
* @throws Exception If POST parameters are not configured or order does not exist
|
| 82 |
+
*/
|
| 83 |
+
public function automaticAction()
|
| 84 |
+
{
|
| 85 |
+
if ($this->getRequest()->isPost()) {
|
| 86 |
+
|
| 87 |
+
try {
|
| 88 |
+
$requestParams = $this->getRequest()->getParams();
|
| 89 |
+
|
| 90 |
+
/* @var $paymentMethod Buyster_Buyster_Model_Standard */
|
| 91 |
+
$paymentMethod = Mage::getSingleton('buyster/standard');
|
| 92 |
+
$paymentMethod->automaticProcess($requestParams);
|
| 93 |
+
|
| 94 |
+
} catch (Exception $e) {
|
| 95 |
+
|
| 96 |
+
// Log errors
|
| 97 |
+
Mage::log($e->getMessage(), Zend_Log::ERR, Buyster_Buyster_Model_Service::LOGFILE);
|
| 98 |
+
Mage::log($requestParams, Zend_Log::ERR, Buyster_Buyster_Model_Service::LOGFILE);
|
| 99 |
+
|
| 100 |
+
// Add error message in order status history if order can be retrieved and description is not empty
|
| 101 |
+
$responseDescription = $this->getRequest()->getParam('responseDescription', false);
|
| 102 |
+
if ($responseDescription != false) {
|
| 103 |
+
|
| 104 |
+
$orderIncId = $this->getRequest()->getParam('transactionReference', false);
|
| 105 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncId);
|
| 106 |
+
if (
|
| 107 |
+
$order &&
|
| 108 |
+
$order->getStatus() == Mage::getStoreConfig('payment/buyster/order_status')
|
| 109 |
+
) {
|
| 110 |
+
|
| 111 |
+
// Add comment and cancel order
|
| 112 |
+
$order->addStatusHistoryComment(
|
| 113 |
+
'Buyster : ' . urldecode($responseDescription),
|
| 114 |
+
Mage::getStoreConfig('payment/buyster/canceled_order_status')
|
| 115 |
+
);
|
| 116 |
+
$order->save();
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
} else {
|
| 122 |
+
// If it is not POST request, redirect to checkout cart
|
| 123 |
+
$this->_redirect('checkout/cart');
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* The customer is redirected to that action
|
| 129 |
+
* when coming back from Buyster server,
|
| 130 |
+
* where he/she paid or clicked on Come back button
|
| 131 |
+
* If OK, redirect to checkout onepage success
|
| 132 |
+
* If NOK, restore cart, redirect to cart and display error
|
| 133 |
+
*
|
| 134 |
+
* @see returnUrl in SOAP web service parameters
|
| 135 |
+
*
|
| 136 |
+
* @return void
|
| 137 |
+
*/
|
| 138 |
+
public function returnAction()
|
| 139 |
+
{
|
| 140 |
+
// Check if it is POST request
|
| 141 |
+
if ($this->getRequest()->isPost()) {
|
| 142 |
+
|
| 143 |
+
$responseCode = $this->getRequest()->getParam('responseCode', false);
|
| 144 |
+
if ($responseCode == Buyster_Buyster_Model_Service::SERVICE_RESPONSE_SUCCESS) {
|
| 145 |
+
|
| 146 |
+
// If ok, redirect to success page
|
| 147 |
+
$this->getResponse()
|
| 148 |
+
->setRedirect(Mage::getUrl('checkout/onepage/success'))
|
| 149 |
+
->sendResponse();
|
| 150 |
+
|
| 151 |
+
} else {
|
| 152 |
+
$responseDescription = $this->getRequest()->getParam('responseDescription', false);
|
| 153 |
+
|
| 154 |
+
if ($responseDescription != false) {
|
| 155 |
+
$session = Mage::getSingleton('checkout/session');
|
| 156 |
+
$session->addError($responseDescription);
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// If it is not POST request, restore cart and redirect to checkout cart
|
| 160 |
+
Mage::getSingleton('buyster/standard')->restoreCart();
|
| 161 |
+
$this->_redirect('checkout/cart');
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
} else {
|
| 165 |
+
// If it is not POST request, redirect to checkout cart
|
| 166 |
+
$this->_redirect('checkout/cart');
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
}
|
app/code/community/Buyster/Buyster/etc/config.xml
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Buyster
|
| 5 |
+
* @package Buyster_Buyster
|
| 6 |
+
* @copyright 2011 Buyster
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Buyster_Buyster>
|
| 13 |
+
<version>0.0.1.1</version>
|
| 14 |
+
</Buyster_Buyster>
|
| 15 |
+
</modules>
|
| 16 |
+
|
| 17 |
+
<global>
|
| 18 |
+
|
| 19 |
+
<blocks>
|
| 20 |
+
<buyster>
|
| 21 |
+
<class>Buyster_Buyster_Block</class>
|
| 22 |
+
</buyster>
|
| 23 |
+
</blocks>
|
| 24 |
+
|
| 25 |
+
<models>
|
| 26 |
+
<buyster>
|
| 27 |
+
<class>Buyster_Buyster_Model</class>
|
| 28 |
+
<resourceModel>buyster_mysql4</resourceModel>
|
| 29 |
+
</buyster>
|
| 30 |
+
<buyster_mysql4>
|
| 31 |
+
<class>Buyster_Buyster_Model_Mysql4</class>
|
| 32 |
+
<entities>
|
| 33 |
+
<transaction_reference>
|
| 34 |
+
<table>buyster_transaction_reference</table>
|
| 35 |
+
</transaction_reference>
|
| 36 |
+
</entities>
|
| 37 |
+
</buyster_mysql4>
|
| 38 |
+
</models>
|
| 39 |
+
|
| 40 |
+
<helpers>
|
| 41 |
+
<buyster>
|
| 42 |
+
<class>Buyster_Buyster_Helper</class>
|
| 43 |
+
</buyster>
|
| 44 |
+
</helpers>
|
| 45 |
+
|
| 46 |
+
<resources>
|
| 47 |
+
<buyster_setup>
|
| 48 |
+
<setup>
|
| 49 |
+
<module>Buyster_Buyster</module>
|
| 50 |
+
</setup>
|
| 51 |
+
<connection>
|
| 52 |
+
<use>core_setup</use>
|
| 53 |
+
</connection>
|
| 54 |
+
</buyster_setup>
|
| 55 |
+
<buyster_write>
|
| 56 |
+
<connection>
|
| 57 |
+
<use>core_write</use>
|
| 58 |
+
</connection>
|
| 59 |
+
</buyster_write>
|
| 60 |
+
<buyster_read>
|
| 61 |
+
<connection>
|
| 62 |
+
<use>core_read</use>
|
| 63 |
+
</connection>
|
| 64 |
+
</buyster_read>
|
| 65 |
+
</resources>
|
| 66 |
+
|
| 67 |
+
<events>
|
| 68 |
+
<sales_order_invoice_save_before>
|
| 69 |
+
<observers>
|
| 70 |
+
<buyster_invoice_save_before>
|
| 71 |
+
<class>buyster/observer</class>
|
| 72 |
+
<method>updateStatusValidated</method>
|
| 73 |
+
</buyster_invoice_save_before>
|
| 74 |
+
</observers>
|
| 75 |
+
</sales_order_invoice_save_before>
|
| 76 |
+
<sales_order_invoice_cancel>
|
| 77 |
+
<observers>
|
| 78 |
+
<buyster_cancel_invoice>
|
| 79 |
+
<class>buyster/observer</class>
|
| 80 |
+
<method>cancelInvoice</method>
|
| 81 |
+
</buyster_cancel_invoice>
|
| 82 |
+
</observers>
|
| 83 |
+
</sales_order_invoice_cancel>
|
| 84 |
+
</events>
|
| 85 |
+
|
| 86 |
+
<buyster>
|
| 87 |
+
<request_version>1.0</request_version>
|
| 88 |
+
<service_url>
|
| 89 |
+
<production>https://www.inscripaiement.buyster.fr/net.atos.mnop.ServicePayment?wsdl</production>
|
| 90 |
+
<test>https://mnop-acceptor.aw.atosorigin.com/net.atos.mnop.ServicePayment?wsdl</test>
|
| 91 |
+
</service_url>
|
| 92 |
+
<supported_currencies>
|
| 93 |
+
<EUR>978</EUR>
|
| 94 |
+
</supported_currencies>
|
| 95 |
+
</buyster>
|
| 96 |
+
|
| 97 |
+
<sales>
|
| 98 |
+
<order>
|
| 99 |
+
<statuses>
|
| 100 |
+
<pending_validation translate="label">
|
| 101 |
+
<label>Pending validation</label>
|
| 102 |
+
</pending_validation>
|
| 103 |
+
<validated translate="label">
|
| 104 |
+
<label>Validated</label>
|
| 105 |
+
</validated>
|
| 106 |
+
<expired translate="label">
|
| 107 |
+
<label>Passed</label>
|
| 108 |
+
</expired>
|
| 109 |
+
</statuses>
|
| 110 |
+
<states>
|
| 111 |
+
<processing>
|
| 112 |
+
<statuses>
|
| 113 |
+
<pending_validation/>
|
| 114 |
+
<validated/>
|
| 115 |
+
</statuses>
|
| 116 |
+
</processing>
|
| 117 |
+
<canceled>
|
| 118 |
+
<statuses>
|
| 119 |
+
<expired/>
|
| 120 |
+
</statuses>
|
| 121 |
+
</canceled>
|
| 122 |
+
</states>
|
| 123 |
+
</order>
|
| 124 |
+
</sales>
|
| 125 |
+
|
| 126 |
+
</global>
|
| 127 |
+
|
| 128 |
+
<frontend>
|
| 129 |
+
<routers>
|
| 130 |
+
<buyster>
|
| 131 |
+
<use>standard</use>
|
| 132 |
+
<args>
|
| 133 |
+
<module>Buyster_Buyster</module>
|
| 134 |
+
<frontName>buyster</frontName>
|
| 135 |
+
</args>
|
| 136 |
+
</buyster>
|
| 137 |
+
</routers>
|
| 138 |
+
<translate>
|
| 139 |
+
<modules>
|
| 140 |
+
<Buyster_Buyster>
|
| 141 |
+
<files>
|
| 142 |
+
<default>Buyster_Buyster.csv</default>
|
| 143 |
+
</files>
|
| 144 |
+
</Buyster_Buyster>
|
| 145 |
+
</modules>
|
| 146 |
+
</translate>
|
| 147 |
+
<layout>
|
| 148 |
+
<updates>
|
| 149 |
+
<buyster>
|
| 150 |
+
<file>buyster.xml</file>
|
| 151 |
+
</buyster>
|
| 152 |
+
</updates>
|
| 153 |
+
</layout>
|
| 154 |
+
</frontend>
|
| 155 |
+
|
| 156 |
+
<adminhtml>
|
| 157 |
+
<translate>
|
| 158 |
+
<modules>
|
| 159 |
+
<Buyster_Buyster>
|
| 160 |
+
<files>
|
| 161 |
+
<default>Buyster_Buyster.csv</default>
|
| 162 |
+
</files>
|
| 163 |
+
</Buyster_Buyster>
|
| 164 |
+
<Mage_Sales>
|
| 165 |
+
<files>
|
| 166 |
+
<buyster>Buyster_Buyster.csv</buyster>
|
| 167 |
+
</files>
|
| 168 |
+
</Mage_Sales>
|
| 169 |
+
</modules>
|
| 170 |
+
</translate>
|
| 171 |
+
|
| 172 |
+
<layout>
|
| 173 |
+
<updates>
|
| 174 |
+
<buyster>
|
| 175 |
+
<file>buyster.xml</file>
|
| 176 |
+
</buyster>
|
| 177 |
+
</updates>
|
| 178 |
+
</layout>
|
| 179 |
+
</adminhtml>
|
| 180 |
+
|
| 181 |
+
<crontab>
|
| 182 |
+
<jobs>
|
| 183 |
+
<!-- Valorisation and expiration are performed every hour / Frequency can be changed freely -->
|
| 184 |
+
<buyster_valorize>
|
| 185 |
+
<schedule><cron_expr>0 * * * *</cron_expr></schedule>
|
| 186 |
+
<run><model>buyster/observer::valorize</model></run>
|
| 187 |
+
</buyster_valorize>
|
| 188 |
+
<buyster_expire>
|
| 189 |
+
<schedule><cron_expr>0 * * * *</cron_expr></schedule>
|
| 190 |
+
<run><model>buyster/observer::expire</model></run>
|
| 191 |
+
</buyster_expire>
|
| 192 |
+
</jobs>
|
| 193 |
+
</crontab>
|
| 194 |
+
|
| 195 |
+
<default>
|
| 196 |
+
<payment>
|
| 197 |
+
<buyster>
|
| 198 |
+
<active>0</active>
|
| 199 |
+
<model>buyster/standard</model>
|
| 200 |
+
<order_status>pending_payment</order_status>
|
| 201 |
+
<title>Buyster</title>
|
| 202 |
+
<allowspecific>0</allowspecific>
|
| 203 |
+
<min_order_total>1</min_order_total>
|
| 204 |
+
<max_order_total>1800</max_order_total>
|
| 205 |
+
<payment_type>payment</payment_type>
|
| 206 |
+
<capture_delay>0</capture_delay>
|
| 207 |
+
<validation_delay>1</validation_delay>
|
| 208 |
+
<authorized_order_status>validated</authorized_order_status>
|
| 209 |
+
<refused_order_status>holded</refused_order_status>
|
| 210 |
+
<canceled_order_status>canceled</canceled_order_status>
|
| 211 |
+
</buyster>
|
| 212 |
+
</payment>
|
| 213 |
+
</default>
|
| 214 |
+
</config>
|
app/code/community/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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Buyster
|
| 5 |
+
* @package Buyster_Buyster
|
| 6 |
+
* @copyright 2011 Buyster
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<sections>
|
| 12 |
+
<payment>
|
| 13 |
+
<groups>
|
| 14 |
+
<buyster translate="label" module="buyster">
|
| 15 |
+
<label>Buyster</label>
|
| 16 |
+
<sort_order>670</sort_order>
|
| 17 |
+
<show_in_default>1</show_in_default>
|
| 18 |
+
<show_in_website>1</show_in_website>
|
| 19 |
+
<show_in_store>0</show_in_store>
|
| 20 |
+
<comment><![CDATA[<div class="buyster-header"></div><div class="buyster-comment"><a href="http://www.buyster.fr" target="_blank">Consulter le site Buyster</a></div>]]></comment>
|
| 21 |
+
<fields>
|
| 22 |
+
<heading_generic_config translate="label">
|
| 23 |
+
<label>Payment method configuration</label>
|
| 24 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 25 |
+
<sort_order>5</sort_order>
|
| 26 |
+
<show_in_default>1</show_in_default>
|
| 27 |
+
<show_in_website>1</show_in_website>
|
| 28 |
+
</heading_generic_config>
|
| 29 |
+
<active translate="label">
|
| 30 |
+
<label>Enabled</label>
|
| 31 |
+
<frontend_type>select</frontend_type>
|
| 32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 33 |
+
<sort_order>10</sort_order>
|
| 34 |
+
<show_in_default>1</show_in_default>
|
| 35 |
+
<show_in_website>1</show_in_website>
|
| 36 |
+
<show_in_store>0</show_in_store>
|
| 37 |
+
</active>
|
| 38 |
+
<title translate="label">
|
| 39 |
+
<label>Title</label>
|
| 40 |
+
<frontend_type>text</frontend_type>
|
| 41 |
+
<sort_order>20</sort_order>
|
| 42 |
+
<show_in_default>1</show_in_default>
|
| 43 |
+
<show_in_website>1</show_in_website>
|
| 44 |
+
<show_in_store>0</show_in_store>
|
| 45 |
+
<validate>required-entry validate-length maximum-length-255</validate>
|
| 46 |
+
</title>
|
| 47 |
+
<order_status translate="label">
|
| 48 |
+
<label>New order status</label>
|
| 49 |
+
<frontend_type>select</frontend_type>
|
| 50 |
+
<source_model>buyster/system_config_source_order_status</source_model>
|
| 51 |
+
<sort_order>200</sort_order>
|
| 52 |
+
<show_in_default>1</show_in_default>
|
| 53 |
+
<show_in_website>1</show_in_website>
|
| 54 |
+
<show_in_store>0</show_in_store>
|
| 55 |
+
</order_status>
|
| 56 |
+
<allowspecific translate="label">
|
| 57 |
+
<label>Payment Applicable From</label>
|
| 58 |
+
<frontend_type>select</frontend_type>
|
| 59 |
+
<sort_order>40</sort_order>
|
| 60 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>1</show_in_website>
|
| 63 |
+
<show_in_store>0</show_in_store>
|
| 64 |
+
</allowspecific>
|
| 65 |
+
<specificcountry translate="label">
|
| 66 |
+
<label>Countries Payment Applicable From</label>
|
| 67 |
+
<frontend_type>multiselect</frontend_type>
|
| 68 |
+
<sort_order>50</sort_order>
|
| 69 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
| 70 |
+
<show_in_default>1</show_in_default>
|
| 71 |
+
<show_in_website>1</show_in_website>
|
| 72 |
+
<show_in_store>0</show_in_store>
|
| 73 |
+
<depends><allowspecific>1</allowspecific></depends>
|
| 74 |
+
</specificcountry>
|
| 75 |
+
<min_order_total translate="label">
|
| 76 |
+
<label>Minimum Order Total</label>
|
| 77 |
+
<frontend_type>text</frontend_type>
|
| 78 |
+
<sort_order>60</sort_order>
|
| 79 |
+
<show_in_default>1</show_in_default>
|
| 80 |
+
<show_in_website>1</show_in_website>
|
| 81 |
+
<show_in_store>0</show_in_store>
|
| 82 |
+
<validate>validate-number</validate>
|
| 83 |
+
<comment>Buyster only supports transactions above 1 €. Below values will be ignored.</comment>
|
| 84 |
+
</min_order_total>
|
| 85 |
+
<max_order_total translate="label">
|
| 86 |
+
<label>Maximum Order Total</label>
|
| 87 |
+
<frontend_type>text</frontend_type>
|
| 88 |
+
<sort_order>70</sort_order>
|
| 89 |
+
<show_in_default>1</show_in_default>
|
| 90 |
+
<show_in_website>1</show_in_website>
|
| 91 |
+
<show_in_store>0</show_in_store>
|
| 92 |
+
<validate>validate-number</validate>
|
| 93 |
+
</max_order_total>
|
| 94 |
+
<sort_order translate="label">
|
| 95 |
+
<label>Sort Order</label>
|
| 96 |
+
<frontend_type>text</frontend_type>
|
| 97 |
+
<sort_order>100</sort_order>
|
| 98 |
+
<show_in_default>1</show_in_default>
|
| 99 |
+
<show_in_website>1</show_in_website>
|
| 100 |
+
<show_in_store>0</show_in_store>
|
| 101 |
+
<validate>validate-digits</validate>
|
| 102 |
+
</sort_order>
|
| 103 |
+
|
| 104 |
+
<heading_specific_buyster translate="label">
|
| 105 |
+
<label>Buyster specific configuration</label>
|
| 106 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
| 107 |
+
<sort_order>105</sort_order>
|
| 108 |
+
<show_in_default>1</show_in_default>
|
| 109 |
+
<show_in_website>1</show_in_website>
|
| 110 |
+
</heading_specific_buyster>
|
| 111 |
+
<service_url translate="label">
|
| 112 |
+
<label>SOAP Service URL</label>
|
| 113 |
+
<frontend_type>select</frontend_type>
|
| 114 |
+
<source_model>buyster/system_config_source_serviceurl</source_model>
|
| 115 |
+
<sort_order>110</sort_order>
|
| 116 |
+
<show_in_default>1</show_in_default>
|
| 117 |
+
<show_in_website>1</show_in_website>
|
| 118 |
+
<show_in_store>0</show_in_store>
|
| 119 |
+
</service_url>
|
| 120 |
+
<merchant_id translate="label">
|
| 121 |
+
<label>Merchant ID</label>
|
| 122 |
+
<frontend_type>text</frontend_type>
|
| 123 |
+
<sort_order>120</sort_order>
|
| 124 |
+
<show_in_default>1</show_in_default>
|
| 125 |
+
<show_in_website>1</show_in_website>
|
| 126 |
+
<show_in_store>0</show_in_store>
|
| 127 |
+
<validate>validate-length maximum-length-255</validate>
|
| 128 |
+
</merchant_id>
|
| 129 |
+
<merchant_password translate="label">
|
| 130 |
+
<label>Merchant password</label>
|
| 131 |
+
<frontend_type>text</frontend_type>
|
| 132 |
+
<sort_order>130</sort_order>
|
| 133 |
+
<show_in_default>1</show_in_default>
|
| 134 |
+
<show_in_website>1</show_in_website>
|
| 135 |
+
<show_in_store>0</show_in_store>
|
| 136 |
+
<validate>validate-length maximum-length-255</validate>
|
| 137 |
+
</merchant_password>
|
| 138 |
+
<merchant_signature translate="label">
|
| 139 |
+
<label>Merchant signature</label>
|
| 140 |
+
<frontend_type>textarea</frontend_type>
|
| 141 |
+
<sort_order>140</sort_order>
|
| 142 |
+
<show_in_default>1</show_in_default>
|
| 143 |
+
<show_in_website>1</show_in_website>
|
| 144 |
+
<show_in_store>0</show_in_store>
|
| 145 |
+
</merchant_signature>
|
| 146 |
+
<automatic_response_url translate="label">
|
| 147 |
+
<label>Automatic Response URL</label>
|
| 148 |
+
<frontend_type>label</frontend_type>
|
| 149 |
+
<frontend_model>buyster/system_config_form_field_label</frontend_model>
|
| 150 |
+
<sort_order>145</sort_order>
|
| 151 |
+
<show_in_default>1</show_in_default>
|
| 152 |
+
<show_in_website>1</show_in_website>
|
| 153 |
+
<show_in_store>0</show_in_store>
|
| 154 |
+
<readonly>readonly</readonly>
|
| 155 |
+
</automatic_response_url>
|
| 156 |
+
<payment_type translate="label">
|
| 157 |
+
<label>Payment type</label>
|
| 158 |
+
<frontend_type>select</frontend_type>
|
| 159 |
+
<source_model>buyster/system_config_source_paymenttype</source_model>
|
| 160 |
+
<sort_order>150</sort_order>
|
| 161 |
+
<show_in_default>1</show_in_default>
|
| 162 |
+
<show_in_website>1</show_in_website>
|
| 163 |
+
<show_in_store>0</show_in_store>
|
| 164 |
+
</payment_type>
|
| 165 |
+
<capture_delay translate="label">
|
| 166 |
+
<label>Capture delay</label>
|
| 167 |
+
<frontend_type>text</frontend_type>
|
| 168 |
+
<sort_order>160</sort_order>
|
| 169 |
+
<show_in_default>1</show_in_default>
|
| 170 |
+
<show_in_website>1</show_in_website>
|
| 171 |
+
<show_in_store>0</show_in_store>
|
| 172 |
+
<validate>validate-digits validate-digits-range digits-range-0-6</validate>
|
| 173 |
+
<comment>Between 0 and 6</comment>
|
| 174 |
+
</capture_delay>
|
| 175 |
+
<validation_delay translate="label">
|
| 176 |
+
<label>Validation delay</label>
|
| 177 |
+
<frontend_type>text</frontend_type>
|
| 178 |
+
<sort_order>170</sort_order>
|
| 179 |
+
<show_in_default>1</show_in_default>
|
| 180 |
+
<show_in_website>1</show_in_website>
|
| 181 |
+
<show_in_store>0</show_in_store>
|
| 182 |
+
<validate>validate-digits validate-digits-range digits-range-1-30</validate>
|
| 183 |
+
<comment>Between 1 and 30</comment>
|
| 184 |
+
</validation_delay>
|
| 185 |
+
<authorized_order_status translate="label">
|
| 186 |
+
<label>Authorized order status</label>
|
| 187 |
+
<frontend_type>select</frontend_type>
|
| 188 |
+
<source_model>buyster/system_config_source_order_status_final</source_model>
|
| 189 |
+
<sort_order>210</sort_order>
|
| 190 |
+
<show_in_default>1</show_in_default>
|
| 191 |
+
<show_in_website>1</show_in_website>
|
| 192 |
+
<show_in_store>0</show_in_store>
|
| 193 |
+
</authorized_order_status>
|
| 194 |
+
<refused_order_status translate="label">
|
| 195 |
+
<label>Refused order status</label>
|
| 196 |
+
<frontend_type>select</frontend_type>
|
| 197 |
+
<source_model>buyster/system_config_source_order_status_final</source_model>
|
| 198 |
+
<sort_order>220</sort_order>
|
| 199 |
+
<show_in_default>1</show_in_default>
|
| 200 |
+
<show_in_website>1</show_in_website>
|
| 201 |
+
<show_in_store>0</show_in_store>
|
| 202 |
+
</refused_order_status>
|
| 203 |
+
<canceled_order_status translate="label">
|
| 204 |
+
<label>Canceled order status</label>
|
| 205 |
+
<frontend_type>select</frontend_type>
|
| 206 |
+
<source_model>buyster/system_config_source_order_status_final</source_model>
|
| 207 |
+
<sort_order>230</sort_order>
|
| 208 |
+
<show_in_default>1</show_in_default>
|
| 209 |
+
<show_in_website>1</show_in_website>
|
| 210 |
+
<show_in_store>0</show_in_store>
|
| 211 |
+
</canceled_order_status>
|
| 212 |
+
</fields>
|
| 213 |
+
</buyster>
|
| 214 |
+
</groups>
|
| 215 |
+
</payment>
|
| 216 |
+
</sections>
|
| 217 |
+
</config>
|
app/code/community/Buyster/Buyster/sql/buyster_setup/mysql4-install-0.0.1.0.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Add new order statuses
|
| 4 |
+
* Add 'expired' status to 'processing' state
|
| 5 |
+
* Add 'expired' status to 'canceled' state
|
| 6 |
+
*
|
| 7 |
+
* @category Buyster
|
| 8 |
+
* @package Buyster_Buyster
|
| 9 |
+
* @copyright 2011 Buyster
|
| 10 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 14 |
+
$installer = $this;
|
| 15 |
+
$installer->startSetup();
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Check if this resource model exists. only in last versions
|
| 19 |
+
* Statuses are defined in config.xml for older versions
|
| 20 |
+
*/
|
| 21 |
+
if (class_exists('Mage_Sales_Model_Mysql4_Order_Status_Collection')) {
|
| 22 |
+
|
| 23 |
+
/*
|
| 24 |
+
* Add 'validated' status to 'processing' state
|
| 25 |
+
*/
|
| 26 |
+
$validatedStatus = Mage::getModel('sales/order_status');
|
| 27 |
+
$validatedStatus->setLabel('Validated')
|
| 28 |
+
->setStatus('validated')
|
| 29 |
+
->save();
|
| 30 |
+
$validatedStatus->assignState('processing');
|
| 31 |
+
|
| 32 |
+
/*
|
| 33 |
+
* Add 'expired' status to 'canceled' state
|
| 34 |
+
*/
|
| 35 |
+
$expiredStatus = Mage::getModel('sales/order_status');
|
| 36 |
+
$expiredStatus->setLabel('Passed')
|
| 37 |
+
->setStatus('expired')
|
| 38 |
+
->save();
|
| 39 |
+
$expiredStatus->assignState('canceled');
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
$installer->endSetup();
|
app/code/community/Buyster/Buyster/sql/buyster_setup/mysql4-upgrade-0.0.1.0-0.0.1.1.php
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Add new order status
|
| 4 |
+
* Add 'pending_validation' status to 'processing' state
|
| 5 |
+
*
|
| 6 |
+
* @category Buyster
|
| 7 |
+
* @package Buyster_Buyster
|
| 8 |
+
* @copyright 2011 Buyster
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
| 13 |
+
$installer = $this;
|
| 14 |
+
$installer->startSetup();
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Check if this resource model exists. only in last versions
|
| 18 |
+
* Statuses are defined in config.xml for older versions
|
| 19 |
+
*/
|
| 20 |
+
if (class_exists('Mage_Sales_Model_Mysql4_Order_Status_Collection')) {
|
| 21 |
+
|
| 22 |
+
/*
|
| 23 |
+
* Add 'pending_validation' status to 'processing' state
|
| 24 |
+
*/
|
| 25 |
+
$pendingValidationStatus = Mage::getModel('sales/order_status');
|
| 26 |
+
$pendingValidationStatus->setLabel('Pending Validation')
|
| 27 |
+
->setStatus('pending_validation')
|
| 28 |
+
->save();
|
| 29 |
+
$pendingValidationStatus->assignState('processing');
|
| 30 |
+
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/buyster.xml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Buyster admin layout update
|
| 5 |
+
*
|
| 6 |
+
* @category design
|
| 7 |
+
* @package base_default
|
| 8 |
+
* @copyright 2011 Buyster
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
-->
|
| 13 |
+
<layout version="0.1.0">
|
| 14 |
+
<default>
|
| 15 |
+
<reference name="head">
|
| 16 |
+
<action method="addCss"><name>buyster.css</name></action>
|
| 17 |
+
</reference>
|
| 18 |
+
</default>
|
| 19 |
+
</layout>
|
app/design/frontend/base/default/layout/buyster.xml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Buyster layout update
|
| 5 |
+
*
|
| 6 |
+
* @category design
|
| 7 |
+
* @package base_default
|
| 8 |
+
* @copyright 2011 Buyster
|
| 9 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
-->
|
| 13 |
+
<layout version="0.1.0">
|
| 14 |
+
<buyster_payment_redirect>
|
| 15 |
+
<reference name="head">
|
| 16 |
+
<action method="addCss"><stylesheet>css/buyster.css</stylesheet></action>
|
| 17 |
+
</reference>
|
| 18 |
+
<reference name="root">
|
| 19 |
+
<action method="setTemplate"><template>page/empty.phtml</template></action>
|
| 20 |
+
</reference>
|
| 21 |
+
<reference name="content">
|
| 22 |
+
<block name="buyster_redirect" type="buyster/redirect" template="buyster/redirect.phtml"/>
|
| 23 |
+
</reference>
|
| 24 |
+
</buyster_payment_redirect>
|
| 25 |
+
</layout>
|
app/design/frontend/base/default/template/buyster/redirect.phtml
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div id="buyster_placeholder">
|
| 2 |
+
<?php if ($this->getLink() != "") : ?>
|
| 3 |
+
<div>
|
| 4 |
+
<span><?php echo $this->__("You will be redirected to Buyster payment page shortly."); ?></span>
|
| 5 |
+
</div>
|
| 6 |
+
<div>
|
| 7 |
+
<span><?php echo $this->__("If you are not redirected, please click on below image."); ?></span>
|
| 8 |
+
</div>
|
| 9 |
+
<div id="buyster_link">
|
| 10 |
+
<a href="<?php echo html_entity_decode($this->getLink()); ?>" class="buyster_redirect">
|
| 11 |
+
<img src="<?php echo $this->getSkinUrl('images/buyster/buyster_logo.png') ?>"
|
| 12 |
+
alt="buyster_logo"
|
| 13 |
+
title="<?php echo $this->__("If you are not redirected, please click on below image."); ?>" />
|
| 14 |
+
</a>
|
| 15 |
+
</div>
|
| 16 |
+
<script type="text/javascript">
|
| 17 |
+
//<![CDATA[
|
| 18 |
+
document.observe("dom:loaded", function() {
|
| 19 |
+
// call a click on buyster link
|
| 20 |
+
window.setTimeout("window.location.href = '<?php echo html_entity_decode($this->getLink()); ?>'", 1500);
|
| 21 |
+
});
|
| 22 |
+
//]]>
|
| 23 |
+
</script>
|
| 24 |
+
<?php else : ?>
|
| 25 |
+
<div>
|
| 26 |
+
<span><?php echo $this->__("An error occur while trying to redirect to Buyster. Thank you to try again later."); ?></span>
|
| 27 |
+
</div>
|
| 28 |
+
<div id="buyster_link">
|
| 29 |
+
<a href="<?php echo $this->getUrl('checkout/cart'); ?>" class="buyster_redirect">
|
| 30 |
+
<?php echo $this->__("Continue shopping"); ?>
|
| 31 |
+
</a>
|
| 32 |
+
</div>
|
| 33 |
+
<?php endif; ?>
|
| 34 |
+
</div>
|
app/etc/modules/Buyster_Buyster.xml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* @category Buyster
|
| 5 |
+
* @package Buyster_Buyster
|
| 6 |
+
* @copyright Buyster 2011
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
-->
|
| 10 |
+
<config>
|
| 11 |
+
<modules>
|
| 12 |
+
<Buyster_Buyster>
|
| 13 |
+
<active>true</active>
|
| 14 |
+
<codePool>community</codePool>
|
| 15 |
+
<depends>
|
| 16 |
+
<Mage_Payment />
|
| 17 |
+
</depends>
|
| 18 |
+
</Buyster_Buyster>
|
| 19 |
+
</modules>
|
| 20 |
+
</config>
|
app/locale/en_US/Buyster_Buyster.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
| 1 |
+
"Buyster only supports transactions above 2,00 €. Below values will be ignored.","Buyster only supports transactions above 2,00 €. Below values will be ignored."
|
| 2 |
+
"Buyster only supports transactions below 1 800,00 €. Above values will be ignored.","Buyster only supports transactions below 1 800,00 €. Above values will be ignored."
|
app/locale/fr_FR/Buyster_Buyster.csv
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"Buyster only supports transactions above 1 €. Below values will be ignored.","Le montant minimal d'une transaction supportée par Buyster est de 1 €. Les valeurs inférieures seront ignorées."
|
| 2 |
+
"New order status","Statut des nouvelles commandes"
|
| 3 |
+
"SOAP Service URL","URL du service SOAP"
|
| 4 |
+
"Production","Production"
|
| 5 |
+
"Test","Test"
|
| 6 |
+
"Merchant ID","Identifiant marchand"
|
| 7 |
+
"Merchant password","Mot de passe marchand"
|
| 8 |
+
"Merchant signature","Signature marchand"
|
| 9 |
+
"Payment type","Type de paiement"
|
| 10 |
+
"Simple payment","Paiement simple"
|
| 11 |
+
"Delayed payment","Paiement différé"
|
| 12 |
+
"Validation payment","Paiement avec validation"
|
| 13 |
+
"Capture delay","Délai de remise"
|
| 14 |
+
"Validation delay","Délai de validation"
|
| 15 |
+
"Payment method configuration","Configuration de la méthode de paiement"
|
| 16 |
+
"Buyster specific configuration","Configuration spécifique Buyster"
|
| 17 |
+
"Authorized order status","Etat d'une commande validée"
|
| 18 |
+
"Refused order status","Etat d'une commande refusée"
|
| 19 |
+
"Canceled order status","Etat d'une commande annulée"
|
| 20 |
+
"%s currency is not supported by Buyster","La devise %s n'est pas supportée par Buyster"
|
| 21 |
+
"You will be redirected to Buyster payment page shortly.","Vous allez être redirigé vers la page de paiement Buyster dans quelques instants."
|
| 22 |
+
"If you are not redirected, please click on below image.","Si vous n'êtes pas redirigés, veuillez cliquer sur l'image ci-dessous."
|
| 23 |
+
"An error occur while trying to redirect to Buyster. Thank you to try again later.","Une erreur s'est produite lors de la redirection vers Buyster. Merci de réessayer plus tard."
|
| 24 |
+
"Continue shopping","Continuer mes achats"
|
| 25 |
+
"Between 0 and 6","Entre 0 et 6"
|
| 26 |
+
"Between 1 and 30","Entre 1 et 30"
|
| 27 |
+
"Validated","Validée"
|
| 28 |
+
"Paid","Payée"
|
| 29 |
+
"Passed","Expirée"
|
| 30 |
+
"Pending Validation","En attente de validation"
|
| 31 |
+
"Buyster servers are unavailable","Les serveurs de Buyster sont inaccessibles"
|
| 32 |
+
"Validay delay is outdated","Le délai de validation est dépassé"
|
| 33 |
+
"Transaction type should be paymentValidation","Le paramètre de transaction transactionType devrait être paymentValidation"
|
| 34 |
+
"This order cannot be invoiced before validation","Cette commande ne peut pas être facturée avant d'être validée"
|
| 35 |
+
"Transaction captured by Buyster in the meantime.","La transaction a été facturée par Buyster entre temps."
|
| 36 |
+
"Transaction captured by Buyster in the meantime. Cannot be canceled, will be refunded.","La transaction a été facturée par Buyster entre temps. L'annulation est impossible, un remboursement total va donc avoir lieu."
|
| 37 |
+
"Transaction validated by Buyster in the meantime.","La transaction a été validée par Buyster entre temps."
|
| 38 |
+
"Current transaction status does not allow to cancel order","Le statut actuel de la transaction ne permet pas de l'annuler"
|
| 39 |
+
"Order cancellation has been performed successfully.","Annulation de la commande effectuee avec succes."
|
| 40 |
+
"Transaction status does not allow to perform refund","Le statut actuel de la transaction ne permet pas de procéder au remboursement"
|
| 41 |
+
"Invoice has been captured","La facture a été financée"
|
| 42 |
+
"Transaction has expired","Transaction expiree"
|
| 43 |
+
"Invoice has been captured in the meantime by Buyster. It hadn't been canceled and can be shipped.","Facture encaissee entre temps par Buyster. Cette facture n'a pas ete annulee et peut etre expediee."
|
| 44 |
+
"Automatic Response URL","URL de réponse automatique"
|
| 45 |
+
"Buyster fingerprint","Prise d'empreinte Buyster"
|
| 46 |
+
"Buyster guarantee is accepted for this transaction","La garantie Buyster est acceptée pour cette transaction"
|
| 47 |
+
"Buyster guarantee is refused for this transaction","La garantie Buyster est refusée pour cette transaction"
|
| 48 |
+
"Buyster guarantee is not defined for this transaction","La garantie Buyster n'est pas définie pour cette transaction"
|
| 49 |
+
"Buyster guarantee can not apply to this transaction","La garantie Buyster est inapplicable pour cette transaction"
|
| 50 |
+
"Unknown guarantee indicator","Indicateur de garantie inconnu"
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Buyster_Buyster</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension officielle proposant le mode de paiement Buyster</summary>
|
| 10 |
+
<description>Buyster est une solution de paiement, simple et hautement sécurisée, accessible gratuitement pour vous, utilisateur. Elle vous permet de payer vos achats sur Internet auprès des marchands partenaires de Buyster et ce, depuis votre ordinateur ou votre téléphone mobile.
|
| 11 |
+

|
| 12 |
+
Retrouvez toutes les informations sur www.buyster.fr</description>
|
| 13 |
+
<notes>Première version de l'extension.
|
| 14 |
+
Implémente le paiement simple, le paiement différé et le paiement avec validation.</notes>
|
| 15 |
+
<authors><author><name>Smile Buyster</name><user>smileforbuyster</user><email>mx.guerin.smile@gmail.com</email></author></authors>
|
| 16 |
+
<date>2012-02-28</date>
|
| 17 |
+
<time>09:31:15</time>
|
| 18 |
+
<contents><target name="magecommunity"><dir name="Buyster"><dir name="Buyster"><dir name="Block"><file name="Redirect.php" hash="805002419db4ce1ea0422cea33a85f1e"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Label.php" hash="ef0be74852485c7eb62e99e11288b7f8"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="80504301b838a7a1435420e5d536e9a8"/></dir><dir name="Model"><file name="Observer.php" hash="6db8d0bfd0138b359bee57ef6cca0cd5"/><dir name="Order"><file name="Config.php" hash="d84f49c16000ad5024f852e6a1b754a8"/></dir><dir name="Service"><dir name="Message"><file name="Abstract.php" hash="f0b126e0f70fd64f3f6ba886d6326ac1"/></dir><dir name="Payment"><dir name="Cashmanagement"><file name="Request.php" hash="652e96dfe5692f23f432c1e6b71b78c6"/><file name="Response.php" hash="9e90e6fd99de30801d408b6d0c88b18c"/></dir><dir name="Initialize"><file name="Request.php" hash="58c23dc7a7c9aabe669c4677800809df"/><file name="Response.php" hash="ada42759b7a4818ea41ece10cccdb0c4"/></dir></dir></dir><file name="Service.php" hash="98a6ed9167681cb136889425342f9b78"/><file name="Standard.php" hash="5d3f9e43d9f22837697d11599ba5a805"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Order"><dir name="Status"><file name="Final.php" hash="6badfde1311de23a47579d01fdf777fd"/></dir><file name="Status.php" hash="6dd08f46c5b0fc66f009549e0311454f"/></dir><file name="Paymenttype.php" hash="db83fc42b9f9dc33060a43298ae17d8f"/><file name="Serviceurl.php" hash="8b6746df3432edf07c6fc59f43908ace"/></dir></dir></dir></dir><dir name="controllers"><file name="PaymentController.php" hash="ffa0b89d13edf886d22393acac0f9e2f"/></dir><dir name="etc"><file name="config.xml" hash="7af3bf9d426a0cc2d57a37abbf4cae52"/><file name="system.xml" hash="40fe5b5f4e00d828fb9087183837bc30"/></dir><dir name="sql"><dir name="buyster_setup"><file name="mysql4-install-0.0.1.0.php" hash="6dd863846bd9d6020a0e5162e52bef77"/><file name="mysql4-upgrade-0.0.1.0-0.0.1.1.php" hash="8fe4e7d1ce8fd6128ba9e9b182f9aaf2"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="buyster"><file name="redirect.phtml" hash="c48c7bf7c3f034497546acf8b3a0a23d"/></dir></dir><dir name="layout"><file name="buyster.xml" hash="a1464260a7a4dfe0240f0374febbd08c"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="buyster.xml" hash="df66b99c5e43d9c883b54cc001882e9e"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="buyster"><file name="buyster_logo.png" hash="1aaa2ee8cd8b63310d0115d38c78ec26"/></dir></dir><dir name="css"><file name="buyster.css" hash="0f1a845130f5215798669d5d30fc4e07"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><file name="buyster.css" hash="3c9f1d002c34bc07c0648957e9197f8c"/><dir name="images"><dir name="buyster"><file name="buyster_logo.png" hash="1aaa2ee8cd8b63310d0115d38c78ec26"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="fr_FR"><file name="Buyster_Buyster.csv" hash="2c3140405a74c2e48f3f2b0cfd0d2e56"/></dir><dir name="en_US"><file name="Buyster_Buyster.csv" hash="2937a19f6820b5d428aec40730358044"/></dir></target><target name="mageetc"><dir name="modules"><file name="Buyster_Buyster.xml" hash="9a70a9a71d3d5a0a94d70097eab61c7d"/></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.3.3</min><max>5.3.10</max></php><package><name>Mage_Payment</name><channel>core</channel><min>0.7.0</min><max>1.6.0.0</max></package></required></dependencies>
|
| 21 |
+
</package>
|
skin/adminhtml/default/default/buyster.css
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.buyster-header {
|
| 2 |
+
background: url(images/buyster/buyster_logo.png) no-repeat 0 0;
|
| 3 |
+
height: 0;
|
| 4 |
+
overflow: hidden;
|
| 5 |
+
padding: 45px 0 0;
|
| 6 |
+
width: 170px;
|
| 7 |
+
}
|
| 8 |
+
.buyster-comment {
|
| 9 |
+
padding-left: 10px;
|
| 10 |
+
}
|
skin/adminhtml/default/default/images/buyster/buyster_logo.png
ADDED
|
Binary file
|
skin/frontend/base/default/css/buyster.css
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Buyster specific css
|
| 3 |
+
*
|
| 4 |
+
* @category design
|
| 5 |
+
* @package base_default
|
| 6 |
+
* @copyright 2011 Buyster
|
| 7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
/* Embedded style: used on Buyster interstitial page ===================================== */
|
| 11 |
+
#buyster_placeholder {
|
| 12 |
+
font-size: 150%;
|
| 13 |
+
text-align: center;
|
| 14 |
+
padding-top: 100px;
|
| 15 |
+
}
|
| 16 |
+
#buyster_link {
|
| 17 |
+
width: 200px;
|
| 18 |
+
height: 100px;
|
| 19 |
+
margin: auto;
|
| 20 |
+
padding-top: 25px;
|
| 21 |
+
}
|
| 22 |
+
/* ======================================================================================= */
|
skin/frontend/base/default/images/buyster/buyster_logo.png
ADDED
|
Binary file
|
