Payline - Version 1.6.0

Version Notes

Add the wallet paiement method and 1 clic checkout

Download this release

Release Info

Developer Magento Core Team
Extension Payline
Version 1.6.0
Comparing to
See all releases


Code changes from version 1.5.7 to 1.6.0

Files changed (44) hide show
  1. app/code/community/Monext/Payline/Block/Adminhtml/Sales/Order/Creditmemo/Create/Items.php +1 -0
  2. app/code/community/Monext/Payline/Block/Cpt.php +0 -1
  3. app/code/community/Monext/Payline/Block/Direct.php +9 -11
  4. app/code/community/Monext/Payline/Block/Logo.php +15 -0
  5. app/code/community/Monext/Payline/Block/Nx.php +0 -2
  6. app/code/community/Monext/Payline/Block/Wallet.php +24 -0
  7. app/code/community/Monext/Payline/Block/Wallet/Checkoutbtn.php +20 -0
  8. app/code/community/Monext/Payline/Block/Wallet/Details.php +15 -0
  9. app/code/community/Monext/Payline/Block/Wallet/Infos.php +29 -0
  10. app/code/community/Monext/Payline/Block/Wallet/Sidebar.php +128 -0
  11. app/code/community/Monext/Payline/Helper/Data.php +47 -20
  12. app/code/community/Monext/Payline/Model/Datasource/Billingcycles.php +4 -4
  13. app/code/community/Monext/Payline/Model/Datasource/Shippingmethods.php +22 -0
  14. app/code/community/Monext/Payline/Model/Resource/Eav/Mysql4/Setup.php +27 -0
  15. app/code/community/Monext/Payline/Model/Wallet.php +196 -0
  16. app/code/community/Monext/Payline/PaylinePHPKit/lib/paylineSDK.php +1308 -1282
  17. app/code/community/Monext/Payline/controllers/CheckoutonepageController.php +134 -0
  18. app/code/community/Monext/Payline/controllers/IndexController.php +258 -64
  19. app/code/community/Monext/Payline/controllers/UnloggedwalletController.php +118 -0
  20. app/code/community/Monext/Payline/controllers/WalletController.php +233 -0
  21. app/code/community/Monext/Payline/etc/config.xml +43 -8
  22. app/code/community/Monext/Payline/etc/system.xml +278 -6
  23. app/code/community/Monext/Payline/sql/payline_setup/mysql4-install-1.6.0.php +66 -0
  24. app/design/frontend/default/default/layout/payline.xml +128 -0
  25. app/design/frontend/default/default/template/payline/checkout/onepage.phtml +101 -0
  26. app/design/frontend/default/default/template/payline/checkout/onepage/shipping-method.phtml +39 -0
  27. app/design/frontend/default/default/template/payline/iframe.phtml +6 -0
  28. app/design/frontend/default/default/template/payline/iframeleaver.phtml +7 -0
  29. app/design/frontend/default/default/template/payline/logo.phtml +5 -0
  30. app/design/frontend/default/default/template/payline/page/empty.phtml +7 -0
  31. app/design/frontend/default/default/template/payline/wallet/checkoutbtn.phtml +8 -0
  32. app/design/frontend/default/default/template/payline/wallet/details.phtml +82 -0
  33. app/design/frontend/default/default/template/payline/wallet/form.phtml +15 -0
  34. app/design/frontend/default/default/template/payline/wallet/manage.phtml +22 -0
  35. app/design/frontend/default/default/template/payline/wallet/sidebar.phtml +11 -0
  36. app/design/frontend/default/default/template/payline/wallet/sidebar/form.phtml +13 -0
  37. app/design/frontend/default/default/template/payline/wallet/sidebar/notlogged.phtml +6 -0
  38. app/design/frontend/default/default/template/payline/wallet/subscribe.phtml +10 -0
  39. app/design/frontend/default/default/template/payline/wallet/update.phtml +6 -0
  40. app/etc/modules/Monext_Payline.xml +1 -0
  41. app/locale/en_US/Monext_Payline.csv +48 -3
  42. app/locale/fr_FR/Monext_Payline.csv +51 -6
  43. package.xml +4 -4
  44. skin/frontend/default/default/css/payline.css +72 -0
app/code/community/Monext/Payline/Block/Adminhtml/Sales/Order/Creditmemo/Create/Items.php CHANGED
@@ -2,6 +2,7 @@
2
 
3
  /**
4
  * This class corrects an unexpected behavour on Magento EE 1.9
 
5
  */
6
  class Monext_Payline_Block_Adminhtml_Sales_Order_Creditmemo_Create_Items extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items{
7
  /**
2
 
3
  /**
4
  * This class corrects an unexpected behavour on Magento EE 1.9
5
+ * (looks like invoice MUST be captured online to do a refund)
6
  */
7
  class Monext_Payline_Block_Adminhtml_Sales_Order_Creditmemo_Create_Items extends Mage_Adminhtml_Block_Sales_Order_Creditmemo_Create_Items{
8
  /**
app/code/community/Monext/Payline/Block/Cpt.php CHANGED
@@ -5,7 +5,6 @@ class Monext_Payline_Block_Cpt extends Mage_Payment_Block_Form {
5
 
6
  $this->setTemplate('payline/Payline.phtml');
7
  $redirectMsg=Mage::getStoreConfig('payment/PaylineCPT/redirect_message');
8
- //if (!$redirectMsg) $redirectMsg=Mage::helper('payline')->__('You\'ll be redirected to Payline to process your payment');
9
  $this->setRedirectMessage($redirectMsg);
10
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
11
  ;
5
 
6
  $this->setTemplate('payline/Payline.phtml');
7
  $redirectMsg=Mage::getStoreConfig('payment/PaylineCPT/redirect_message');
 
8
  $this->setRedirectMessage($redirectMsg);
9
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
10
  ;
app/code/community/Monext/Payline/Block/Direct.php CHANGED
@@ -7,10 +7,8 @@ class Monext_Payline_Block_Direct extends Mage_Payment_Block_Form {
7
 
8
  $this->setTemplate('payline/Direct.phtml');
9
  $redirectMsg=Mage::getStoreConfig('payment/PaylineNX/redirect_message');
10
- //if (!$redirectMsg) $redirectMsg=Mage::helper('payline')->__('You\'ll be redirected to Payline to process your payment');
11
  $this->setRedirectMessage($redirectMsg);
12
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
13
- ;
14
  }
15
 
16
  public function getCcAvailableTypes()
@@ -30,15 +28,15 @@ class Monext_Payline_Block_Direct extends Mage_Payment_Block_Form {
30
  {
31
  $months = array();
32
  $months[0] = Mage::helper('payline')->__('Month');
33
- $months['01'] = '01';
34
- $months['02'] = '02';
35
- $months['03'] = '03';
36
- $months['04'] = '04';
37
- $months['05'] = '05';
38
- $months['06'] = '06';
39
- $months['07'] = '07';
40
- $months['08'] = '08';
41
- $months['09'] = '09';
42
  $months['10'] = '10';
43
  $months['11'] = '11';
44
  $months['12'] = '12';
7
 
8
  $this->setTemplate('payline/Direct.phtml');
9
  $redirectMsg=Mage::getStoreConfig('payment/PaylineNX/redirect_message');
 
10
  $this->setRedirectMessage($redirectMsg);
11
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
 
12
  }
13
 
14
  public function getCcAvailableTypes()
28
  {
29
  $months = array();
30
  $months[0] = Mage::helper('payline')->__('Month');
31
+ $months['01'] = '01';
32
+ $months['02'] = '02';
33
+ $months['03'] = '03';
34
+ $months['04'] = '04';
35
+ $months['05'] = '05';
36
+ $months['06'] = '06';
37
+ $months['07'] = '07';
38
+ $months['08'] = '08';
39
+ $months['09'] = '09';
40
  $months['10'] = '10';
41
  $months['11'] = '11';
42
  $months['12'] = '12';
app/code/community/Monext/Payline/Block/Logo.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Block_Logo extends Mage_Core_Block_Template{
3
+ protected function isPaylineAvailable(){
4
+ if (
5
+ Mage::getStoreConfig('payment/PaylineCPT/active') ||
6
+ Mage::getStoreConfig('payment/PaylineNX/active') ||
7
+ Mage::getStoreConfig('payment/PaylineDIRECT/active') ||
8
+ Mage::getStoreConfig('payment/PaylineWALLET/active'))
9
+ {
10
+ return true;
11
+ }else{
12
+ return false;
13
+ }
14
+ }
15
+ }
app/code/community/Monext/Payline/Block/Nx.php CHANGED
@@ -5,10 +5,8 @@ class Monext_Payline_Block_Nx extends Mage_Payment_Block_Form {
5
 
6
  $this->setTemplate('payline/Payline.phtml');
7
  $redirectMsg=Mage::getStoreConfig('payment/PaylineNX/redirect_message');
8
- //if (!$redirectMsg) $redirectMsg=Mage::helper('payline')->__('You\'ll be redirected to Payline to process your payment');
9
  $this->setRedirectMessage($redirectMsg);
10
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
11
- ;
12
  }
13
  }
14
  ?>
5
 
6
  $this->setTemplate('payline/Payline.phtml');
7
  $redirectMsg=Mage::getStoreConfig('payment/PaylineNX/redirect_message');
 
8
  $this->setRedirectMessage($redirectMsg);
9
  $this->setBannerSrc('https://webpayment.payline.com/webpayment/image?key=img.product');
 
10
  }
11
  }
12
  ?>
app/code/community/Monext/Payline/Block/Wallet.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Block_Wallet extends Mage_Payment_Block_Form {
3
+ protected $_walletData;
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+
8
+ $this->setTemplate('payline/wallet/form.phtml');
9
+ }
10
+
11
+ public function getWalletData(){
12
+ if (!empty($this->_walletData)){
13
+ return $this->_walletData;
14
+ }
15
+ $wallet=$this->getMethod()->getWalletData();
16
+ $data=array(
17
+ $this->__('Card type')=>$wallet['card']['type'],
18
+ $this->__('Number')=>$wallet['card']['number'],
19
+ $this->__('Exp. date')=>$wallet['card']['expirationDate']
20
+ );
21
+ $this->_walletData=$data;
22
+ return $data;
23
+ }
24
+ }
app/code/community/Monext/Payline/Block/Wallet/Checkoutbtn.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Block_Wallet_Checkoutbtn extends Mage_Core_Block_Template{
3
+ protected $_template='payline/wallet/checkoutbtn.phtml';
4
+
5
+ public function getRedirectUrl(){
6
+ $redirectUrl = Mage::getBaseUrl()."/payline/wallet/subscribe";
7
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
8
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
9
+ if ($customer->getWalletId()){
10
+ //Check if the wallet payment is available
11
+ /* @var $walletPaymentMethod Monext_Payline_Model_Wallet */
12
+ $walletPaymentMethod=Mage::getModel('payline/wallet');
13
+ if ($walletPaymentMethod->checkExpirationDate()){
14
+ $redirectUrl = Mage::getBaseUrl().'/payline/checkoutonepage/';
15
+ }
16
+ }
17
+ }
18
+ return $redirectUrl;
19
+ }
20
+ }
app/code/community/Monext/Payline/Block/Wallet/Details.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Block_Wallet_Details extends Mage_Core_Block_Template{
3
+ public $wallet=array();
4
+ public $showShippingDetails;
5
+
6
+ public function _construct($flag=null){
7
+ if ($flag===null){
8
+ $flag=(bool)Mage::getStoreConfig('payment/PaylineWALLET/update_personal_details');
9
+ }
10
+ $this->showShippingDetails=$flag;
11
+
12
+ parent::_construct();
13
+ $this->setTemplate('payline/wallet/details.phtml');
14
+ }
15
+ }
app/code/community/Monext/Payline/Block/Wallet/Infos.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** Display wallet payment info (usually in the checkout progress bar
3
+ */
4
+ class Monext_Payline_Block_Wallet_Infos extends Mage_Payment_Block_Info{
5
+ /**
6
+ * Prepare credit card related payment info
7
+ *
8
+ * @param Varien_Object|array $transport
9
+ * @return Varien_Object
10
+ */
11
+ protected function _prepareSpecificInformation($transport = null)
12
+ {
13
+ if (null !== $this->_paymentSpecificInformation) {
14
+ return $this->_paymentSpecificInformation;
15
+ }
16
+ $transport = parent::_prepareSpecificInformation($transport);
17
+ $wallet=$this->getInfo()->getMethodInstance()->getWalletData();
18
+ $data=array();
19
+ if (!empty($wallet)){
20
+
21
+ $data=array(
22
+ $this->__('Card type')=>$wallet['card']['type'],
23
+ $this->__('Number')=>$wallet['card']['number'],
24
+ $this->__('Exp. date')=>$wallet['card']['expirationDate']
25
+ );
26
+ }
27
+ return $transport->setData(array_merge($data, $transport->getData()));
28
+ }
29
+ }
app/code/community/Monext/Payline/Block/Wallet/Sidebar.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Block_Wallet_Sidebar extends Mage_Core_Block_Template{
3
+
4
+ protected $_customer;
5
+
6
+ /**
7
+ * Get logged in customer
8
+ *
9
+ * @return Mage_Customer_Model_Customer
10
+ */
11
+ public function getCustomer()
12
+ {
13
+ if (empty($this->_customer)) {
14
+ $this->_customer = Mage::getSingleton('customer/session')->getCustomer();
15
+ }
16
+ return $this->_customer;
17
+ }
18
+
19
+ /**
20
+ * @return bool
21
+ */
22
+ public function isCustomerLoggedIn()
23
+ {
24
+ return Mage::getSingleton('customer/session')->isLoggedIn();
25
+ }
26
+
27
+ /**
28
+ * Define if the sidebar is displayed
29
+ *
30
+ * @return bool
31
+ */
32
+ public function getIsNeedToDisplaySideBar()
33
+ {
34
+ if (Mage::getStoreConfig('payment/PaylineWALLET/active')){
35
+ if (Mage::getStoreConfig('payment/PaylineWALLET/payline_display_register-oneclick_catalog')){
36
+ $showCmsBlock=true;
37
+ }else{
38
+ $showCmsBlock=false;
39
+ }
40
+ //If cart is empty we don't have to show any block
41
+ if (!Mage::getSingleton('checkout/session')->getQuote()->getAllVisibleItems()){
42
+ return false;
43
+ }
44
+ if($this->isCustomerLoggedIn()){
45
+ $customer=$this->getCustomer();
46
+ if ($walletId=$customer->getWalletId()){
47
+ //if user doesn't have addresses, we don't display block
48
+ if ($this->getAddressesHtmlSelect()){
49
+ return true;
50
+ }
51
+ }else{
52
+ //Customer doesn't have walletId, the CMS block will be shown if config is OK
53
+ return $showCmsBlock;
54
+ }
55
+ }else{
56
+ //Customer isn't logged in, the CMS blcok will be shown if config is OK
57
+ return $showCmsBlock;
58
+ }
59
+ }
60
+ return false;
61
+ }
62
+
63
+ /**
64
+ * If customer logged & registered to wallet, display form
65
+ * Otherwise, display configured static CMS bloc
66
+ * @return string html code
67
+ */
68
+ public function getContent(){
69
+ if($this->isCustomerLoggedIn()){
70
+ $customer=$this->getCustomer();
71
+ if ($walletId=$customer->getWalletId()){
72
+ $formBlock=$this->getLayout()->createBlock('core/template');
73
+ $formBlock->setTemplate('payline/wallet/sidebar/form.phtml');
74
+ $formBlock->setBillingAddresses($this->getAddressesHtmlSelect('billing'));
75
+ $formBlock->setShippingAddresses($this->getAddressesHtmlSelect('shipping'));
76
+
77
+ return $formBlock->toHtml();
78
+ }
79
+ }
80
+ $blockId=Mage::getStoreConfig('payment/PaylineWALLET/payline_register-oneclick_catalog');
81
+ /* @var $cmsBlock Mage_Cms_Block_Block */
82
+ $cmsBlock=$this->getLayout()->createBlock('cms/block')->setBlockId($blockId);
83
+ /* @var $notLoggedBlock Mage_Core_Block_Template */
84
+ $notLoggedBlock=$this->getLayout()->createBlock('core/template')->setTemplate('payline/wallet/sidebar/notlogged.phtml');
85
+ $notLoggedBlock->append($cmsBlock);
86
+ return $notLoggedBlock->toHtml();
87
+ }
88
+
89
+ /**
90
+ * Return a html select with the customer addresses
91
+ * Retrieve wether billing or shipping addresses, depending on the $type param
92
+ * @param string $type
93
+ */
94
+ public function getAddressesHtmlSelect($type=null)
95
+ {
96
+ if ($this->getCustomer()!=null) {
97
+ $options = array();
98
+ foreach ($this->getCustomer()->getAddresses() as $address) {
99
+ $options[] = array(
100
+ 'value'=>$address->getId(),
101
+ 'label'=>$address->format('oneline')
102
+ );
103
+ }
104
+ if (count($options)==0){
105
+ return '';
106
+ }
107
+ if ($type=='billing') {
108
+ $address = $this->getCustomer()->getPrimaryBillingAddress();
109
+ } else {
110
+ $address = $this->getCustomer()->getPrimaryShippingAddress();
111
+ }
112
+ if ($address) {
113
+ $addressId = $address->getId();
114
+ }
115
+
116
+ $select = $this->getLayout()->createBlock('core/html_select')
117
+ ->setName($type.'_address_id')
118
+ ->setId($type.'-address-select')
119
+ ->setClass('address-select')
120
+ ->setValue($addressId)
121
+ ->setOptions($options);
122
+
123
+
124
+ return $select->getHtml();
125
+ }
126
+ return '';
127
+ }
128
+ }
app/code/community/Monext/Payline/Helper/Data.php CHANGED
@@ -202,26 +202,28 @@ class Monext_Payline_Helper_Data extends Mage_Core_Helper_Data {
202
  'DIRECT', 'CPT', 'NX', 'WALLET'
203
  );
204
 
205
- public $merchantId ='';
206
- public $accessKey ='';
207
- public $proxyHost ='';
208
- public $proxyPort ='';
209
- public $proxyLogin ='';
210
- public $proxyPassword='' ;
211
- public $production ='';
212
- public $securityMode ='';
213
  public $languageCode='';
214
- public $paymentAction ='';
215
- public $paymentMode ='';
216
- public $cancelUrl ='';
217
- public $notificationUrl ='';
218
- public $returnUrl ='';
219
  public $customPaymentTemplateUrl ='';
220
- public $contractNumber ='';
221
- public $contractNumberList ='';
222
  public $customPaymentPageCode='' ;
223
  public $paymentCurrency ='';
224
  public $orderCurrency ='';
 
 
225
 
226
  /**
227
  * Check whether specified currency code is supported
@@ -248,7 +250,7 @@ class Monext_Payline_Helper_Data extends Mage_Core_Helper_Data {
248
 
249
  /**
250
  *
251
- * Initialize a payline webservice
252
  * @param string $paymentMethod (CPT, NX or DIRECT)
253
  * @param $_numericCurrencyCode If provided, will also initialize currency
254
  */
@@ -279,6 +281,29 @@ class Monext_Payline_Helper_Data extends Mage_Core_Helper_Data {
279
  $this->production = Mage::getStoreConfig($xmlConfigPath.'/production');
280
  $this->securityMode = Mage::getStoreConfig($xmlConfigPath.'/security_mode');
281
  $this->languageCode = Mage::getStoreConfig($xmlConfigPath.'/language');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  if ($paymentMethod=='NX'){
283
  $this->paymentMode = 'NX';
284
  $this->paymentAction=101;
@@ -294,9 +319,12 @@ class Monext_Payline_Helper_Data extends Mage_Core_Helper_Data {
294
  }elseif($paymentMethod=='WALLET'){//1 clic payment
295
  $this->paymentMode = 'CPT';
296
  $this->paymentAction = Mage::getStoreConfig($xmlConfigPath.'/payline_payment_action');
297
- $this->cancelUrl = "";
298
- $this->notificationUrl = "";
299
- $this->returnUrl = "";
 
 
 
300
  }else{//direct
301
  $this->paymentMode = 'CPT';
302
  $this->paymentAction = Mage::getStoreConfig($xmlConfigPath.'/payline_payment_action');
@@ -311,7 +339,6 @@ class Monext_Payline_Helper_Data extends Mage_Core_Helper_Data {
311
  $this->customPaymentPageCode = Mage::getStoreConfig($xmlConfigPath.'/custom_payment_page_code');
312
 
313
  require_once($paylineFolder.'lib/paylineSDK.php');
314
-
315
  return new paylineSDK();
316
  }
317
 
202
  'DIRECT', 'CPT', 'NX', 'WALLET'
203
  );
204
 
205
+ public $merchantId ='';
206
+ public $accessKey ='';
207
+ public $proxyHost ='';
208
+ public $proxyPort ='';
209
+ public $proxyLogin ='';
210
+ public $proxyPassword='' ;
211
+ public $production ='';
212
+ public $securityMode ='';
213
  public $languageCode='';
214
+ public $paymentAction ='';
215
+ public $paymentMode ='';
216
+ public $cancelUrl ='';
217
+ public $notificationUrl ='';
218
+ public $returnUrl ='';
219
  public $customPaymentTemplateUrl ='';
220
+ public $contractNumber ='';
221
+ public $contractNumberList ='';
222
  public $customPaymentPageCode='' ;
223
  public $paymentCurrency ='';
224
  public $orderCurrency ='';
225
+ public $walletId='';
226
+ public $isNewWallet=false;
227
 
228
  /**
229
  * Check whether specified currency code is supported
250
 
251
  /**
252
  *
253
+ * Initialize a payline webservice for payment
254
  * @param string $paymentMethod (CPT, NX or DIRECT)
255
  * @param $_numericCurrencyCode If provided, will also initialize currency
256
  */
281
  $this->production = Mage::getStoreConfig($xmlConfigPath.'/production');
282
  $this->securityMode = Mage::getStoreConfig($xmlConfigPath.'/security_mode');
283
  $this->languageCode = Mage::getStoreConfig($xmlConfigPath.'/language');
284
+
285
+ //Wallet :
286
+ //If wallet_id is sent & registered, Payline will offer a checkbox "use previous payment information"
287
+ $customerSession=Mage::getSingleton('customer/session');
288
+ if (Mage::getStoreConfig('payment/PaylineWALLET/active') && Mage::getStoreConfig('payment/PaylineWALLET/send_wallet_id')){
289
+ if ($customerSession->isLoggedIn()){
290
+ $customer=Mage::getModel('customer/customer')->load($customerSession->getId());
291
+ if ($walletId=$customer->getWalletId()){
292
+ $this->walletId=$walletId;
293
+ }
294
+ }
295
+ }
296
+ //If wallet_id is sent & NOT registered, Payline will save the wallet
297
+ // if isNewWallet walletId will be sent in privateData, so we'll be able to save it in notifyAction (if payment is OK)
298
+ if (Mage::getStoreConfig('payment/PaylineWALLET/active') && Mage::getStoreConfig('payment/PaylineWALLET/automate_subscription')){
299
+ if ($customerSession->isLoggedIn()){
300
+ $customer=Mage::getModel('customer/customer')->load($customerSession->getId());
301
+ if (!$customer->getWalletId()){
302
+ $this->walletId=Mage::getModel('payline/wallet')->generateWalletId();
303
+ $this->isNewWallet=true;
304
+ }
305
+ }
306
+ }
307
  if ($paymentMethod=='NX'){
308
  $this->paymentMode = 'NX';
309
  $this->paymentAction=101;
319
  }elseif($paymentMethod=='WALLET'){//1 clic payment
320
  $this->paymentMode = 'CPT';
321
  $this->paymentAction = Mage::getStoreConfig($xmlConfigPath.'/payline_payment_action');
322
+ $this->updatePersonalDetails = Mage::getStoreConfig($xmlConfigPath.'/update_personal_details');
323
+ $this->updatePaymentDetails = Mage::getStoreConfig($xmlConfigPath.'/update_payment_details');
324
+ // Those depend of the actions called (subscription? payment?), so we define them where the init is called
325
+ // $this->cancelUrl = "";
326
+ // $this->notificationUrl = "";
327
+ // $this->returnUrl = "";
328
  }else{//direct
329
  $this->paymentMode = 'CPT';
330
  $this->paymentAction = Mage::getStoreConfig($xmlConfigPath.'/payline_payment_action');
339
  $this->customPaymentPageCode = Mage::getStoreConfig($xmlConfigPath.'/custom_payment_page_code');
340
 
341
  require_once($paylineFolder.'lib/paylineSDK.php');
 
342
  return new paylineSDK();
343
  }
344
 
app/code/community/Monext/Payline/Model/Datasource/Billingcycles.php CHANGED
@@ -7,10 +7,10 @@ class Monext_Payline_Model_Datasource_Billingcycles
7
  public function toOptionArray()
8
  {
9
  return array(
10
- array('value' => 10, 'label'=>Mage::helper('adminhtml')->__('daily')),
11
- array('value' => 20, 'label'=>Mage::helper('adminhtml')->__('weekly')),
12
- array('value' => 30, 'label'=>Mage::helper('adminhtml')->__('twice a month')),
13
- array('value' => 40, 'label'=>Mage::helper('adminhtml')->__('monthly'))
14
  );
15
  }
16
  }
7
  public function toOptionArray()
8
  {
9
  return array(
10
+ array('value' => 10, 'label'=>Mage::helper('payline')->__('daily')),
11
+ array('value' => 20, 'label'=>Mage::helper('payline')->__('weekly')),
12
+ array('value' => 30, 'label'=>Mage::helper('payline')->__('twice a month')),
13
+ array('value' => 40, 'label'=>Mage::helper('payline')->__('monthly'))
14
  );
15
  }
16
  }
app/code/community/Monext/Payline/Model/Datasource/Shippingmethods.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class used as a datasource to display available shipping methods
4
+ * Only the 3 basic (no user configuration during checkout process) Magento methods are available
5
+ */
6
+ class Monext_Payline_Model_Datasource_Shippingmethods
7
+ {
8
+ public function toOptionArray(){
9
+ $availableMethods=array();
10
+ $availableMethods[]=array('value'=>'', 'label'=>Mage::helper('payline')->__('- none -'));
11
+ if (Mage::getStoreConfig('carriers/flatrate/active')){
12
+ $availableMethods[]=array('value'=>'flatrate_flatrate', 'label'=>Mage::helper('payline')->__('Flat Rate'));
13
+ }
14
+ if (Mage::getStoreConfig('carriers/tablerate/active')){
15
+ $availableMethods[]=array('value'=>'tablerate_bestway', 'label'=>Mage::helper('payline')->__('Table Rate'));
16
+ }
17
+ if (Mage::getStoreConfig('carriers/freeshipping/active')){
18
+ $availableMethods[]=array('value'=>'freeshipping_freeshipping', 'label'=>Mage::helper('payline')->__('Free Shipping'));
19
+ }
20
+ return $availableMethods;
21
+ }
22
+ }
app/code/community/Monext/Payline/Model/Resource/Eav/Mysql4/Setup.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Monext_Payline_Model_Resource_Eav_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
3
+ {
4
+ /**
5
+ * @return array
6
+ */
7
+ public function getDefaultEntities(){
8
+ return array(
9
+ 'customer'=>array(
10
+ 'entity_model' => 'customer/customer',
11
+ 'table' => 'customer/entity',
12
+ 'increment_model' => 'eav/entity_increment_numeric',
13
+ 'increment_per_store' => false,
14
+ 'additional_attribute_table' => 'customer/eav_attribute',
15
+ 'entity_attribute_collection' => 'customer/eav_attribute',
16
+ 'attributes' => array(
17
+ 'wallet_id'=>array(
18
+ 'label' => 'Wallet ID',
19
+ 'type' => 'varchar',
20
+ 'visible' => false,
21
+ 'required' => false,
22
+ )
23
+ )
24
+ )
25
+ );
26
+ }
27
+ }
app/code/community/Monext/Payline/Model/Wallet.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Payline Wallet payment method, or pay in 1 click
4
+ */
5
+ class Monext_Payline_Model_Wallet extends Mage_Payment_Model_Method_Abstract
6
+ {
7
+ protected $_code = 'PaylineWALLET';
8
+ protected $_formBlockType = 'payline/wallet';
9
+ protected $_infoBlockType = 'payline/wallet_infos';
10
+ protected $_isInitializeNeeded = true;
11
+ protected $_canUseInternal = false;
12
+ protected $_canUseForMultishipping = false;
13
+ protected $_canRefund = true;
14
+ protected $_canRefundInvoicePartial = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = true;
17
+ protected $_canVoid = true;
18
+
19
+ protected $_walletData;
20
+
21
+ /**
22
+ * Return Order place redirect url
23
+ *
24
+ * @return string
25
+ */
26
+ public function getOrderPlaceRedirectUrl()
27
+ {
28
+ return Mage::getUrl('payline/index/wallet');
29
+ }
30
+
31
+ /**
32
+ * Retrieve the expiration date of the saved credit card
33
+ * @return string
34
+ */
35
+ public function getExpirationDate(){
36
+ $wallet=$this->getWalletData();
37
+ if (isset($wallet['card']) && isset($wallet['card']['expirationDate'])){
38
+ $exp=$wallet['card']['expirationDate'];
39
+ return $exp;
40
+ }else{
41
+ Mage::helper('payline/logger')->log('Error while retrieving wallet for expiration date');
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Check if the saved credit card expiration date is OK
47
+ * @return bool
48
+ */
49
+ public function checkExpirationDate(){
50
+ $exp = $this->getExpirationDate();
51
+ $date_exp=substr($exp, 2).substr($exp,0,2);
52
+ if (date('ym')<=$date_exp){
53
+ return true;
54
+ }else{
55
+ return false;
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Check whether payment method can be used
61
+ * Rewrited from Abstract class
62
+ * TODO: payment method instance is not supposed to know about quote
63
+ * @param Mage_Sales_Model_Quote
64
+ * @return bool
65
+ */
66
+ public function isAvailable($quote = null){
67
+ $checkResult = new StdClass;
68
+ $checkResult->isAvailable=false;
69
+ $customer=Mage::getSingleton('customer/session');
70
+ if ($customer->isLoggedIn()){
71
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
72
+ if ($customer->getWalletId()){
73
+ $checkResult->isAvailable=true;
74
+ }
75
+ }
76
+ $checkResult->isAvailable=$this->checkExpirationDate();
77
+ $checkResult->isAvailable = (
78
+ $checkResult->isAvailable &&
79
+ $this->getConfigData('active', ($quote ? $quote->getStoreId() : null))
80
+ );
81
+
82
+ // On Magento Pro 1.8, reward module is broken without quote. Let's provide it...
83
+ if (!$quote)
84
+ $quote=Mage::getSingleton('checkout/type_onepage')->getQuote();
85
+ Mage::dispatchEvent('payment_method_is_active', array(
86
+ 'result' => $checkResult,
87
+ 'method_instance' => $this,
88
+ 'quote' => $quote,
89
+ ));
90
+
91
+ // disable method if it cannot implement recurring profiles management and there are recurring items in quote
92
+ if ($checkResult->isAvailable) {
93
+ //This is not implemented on Magenot 1.3
94
+ if (method_exists($this,'canManageRecurringProfiles')){
95
+ $implementsRecurring = $this->canManageRecurringProfiles();
96
+ // the $quote->hasRecurringItems() causes big performance impact, thus it has to be called last
97
+ if ($quote && (!$implementsRecurring) && $quote->hasRecurringItems()) {
98
+ $checkResult->isAvailable = false;
99
+ }
100
+ }
101
+ }
102
+ return $checkResult->isAvailable;
103
+ }
104
+
105
+ public function getWalletData(){
106
+ if (!empty($this->_walletData))
107
+ return $this->_walletData;
108
+
109
+ $customer=Mage::getSingleton('customer/session');
110
+ if ($customer->isLoggedIn()){
111
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
112
+ $walletId=$customer->getWalletId();
113
+ }
114
+ if (!isset($walletId) || empty($walletId)){
115
+ return false;
116
+ }
117
+ /* @var $paylineSDK PaylineSDK */
118
+ $paylineSDK = Mage::helper('payline')->initPayline('WALLET');
119
+ $array=array('walletId'=>$walletId);
120
+ try{
121
+ $res=$paylineSDK->get_Wallet($array);
122
+ }catch(Exception $e){
123
+ $msgLog='Unknown PAYLINE ERROR on getWallet for wallet '.$walletId.' (Payline unreachable?)';
124
+ $msg=Mage::helper('payline')->__('Error while retrieving wallet information');
125
+ Mage::helper('payline/logger')->log($msgLog);
126
+ Mage::getSingleton('customer/session')->addError($msg);
127
+ }
128
+
129
+ if (!isset($res['result']) || $res['result']['code']!='02500'){
130
+ if(isset($res['result'])){
131
+ $msgLog='PAYLINE ERROR on getWallet: '.$res['result']['code']. ' '.$res['result']['longMessage'].' (wallet '.$walletId.')';
132
+ }else{
133
+ $msgLog='Unknown PAYLINE ERROR on getWallet for wallet '.$walletId;
134
+ }
135
+ $msg=Mage::helper('payline')->__('Error while retrieving wallet information');
136
+ Mage::helper('payline/logger')->log($msgLog);
137
+ Mage::getSingleton('customer/session')->addError($msg);
138
+ return false;
139
+ }else{
140
+ $this->_walletData=$res['wallet'];
141
+ //$this->getInfoInstance()->setAdditionalInformation('owner','qsdf');
142
+ return $res['wallet'];
143
+ }
144
+ }
145
+
146
+
147
+ /**
148
+ * Generate a random wallet_id
149
+ * @param int $length
150
+ * @return string
151
+ */
152
+ public function generateWalletId($length=32){
153
+ $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZ";
154
+ $string = '';
155
+ for ($p = 0; $p < $length; $p++) {
156
+ $string .= $characters[mt_rand(0, strlen($characters)-1)];
157
+ }
158
+ return $string;
159
+ }
160
+
161
+ /**
162
+ * Capture payment
163
+ *
164
+ * @param Varien_Object $orderPayment
165
+ * @return Monext_Payline_Model_Cpt
166
+ */
167
+ public function capture(Varien_Object $payment, $amount)
168
+ {
169
+ Mage::getModel('payline/cpt')->capture($payment,$amount);
170
+ return $this;
171
+ }
172
+
173
+ /**
174
+ * Refund money
175
+ *
176
+ * @param Varien_Object $invoicePayment
177
+ * @return Monext_Payline_Model_Cpt
178
+ */
179
+ public function refund(Varien_Object $payment, $amount)
180
+ {
181
+ Mage::getModel('payline/cpt')->refund($payment,$amount);
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * Cancel payment
187
+ *
188
+ * @param Varien_Object $payment
189
+ * @return Monext_Payline_Model_Cpt
190
+ */
191
+ public function void(Varien_Object $payment)
192
+ {
193
+ Mage::getModel('payline/cpt')->void($payment);
194
+ return $this;
195
+ }
196
+ }
app/code/community/Monext/Payline/PaylinePHPKit/lib/paylineSDK.php CHANGED
@@ -1,1283 +1,1309 @@
1
- <?php
2
- //
3
- // Payline Class
4
- // Copyright Monext
5
- //
6
-
7
- //
8
- // OBJECTS DEFINITIONS
9
- //
10
-
11
- class util{
12
-
13
- /**
14
- * make an array from a payline server response object.
15
- * @params : $response : Objet response from experian
16
- * @return : Object convert in an array
17
- **/
18
- static function responseToArray($response){
19
-
20
- $array = array();
21
- foreach($response as $k=>$v){
22
- if (is_object($v)) { $array[$k] = util::responseToArray($v); }
23
- else { $array[$k] = $v; }
24
- // elseif(is_array($v)){ $array[$k] = util::responseToArray($v); }
25
-
26
- }
27
- return $array;
28
-
29
- return $response;
30
- }
31
- }
32
-
33
- //
34
- // PL_PAYMENT OBJECT DEFINITION
35
- //
36
- class pl_payment{
37
-
38
- // ATTRIBUTES LISTING
39
- public $amount;
40
- public $currency;
41
- public $action;
42
- public $mode;
43
- public $contractNumber;
44
- public $differedActionDate;
45
-
46
- function __construct() {
47
- $this->currency = Mage::helper('payline')->paymentCurrency;
48
- $this->action = Mage::helper('payline')->paymentAction;
49
- $this->mode = Mage::helper('payline')->paymentMode;
50
- $this->contractNumber = Mage::helper('payline')->contractNumber;
51
- }
52
- }
53
-
54
- //
55
- // PL_ORDER OBJECT DEFINITION
56
- //
57
- class pl_order{
58
-
59
- // ATTRIBUTES LISTING
60
- public $ref;
61
- public $origin;
62
- public $country;
63
- public $taxes;
64
- public $amount;
65
- public $currency;
66
- public $date;
67
- public $quantity;
68
- public $comment;
69
- public $details;
70
-
71
- function __construct() {
72
- $this->date = date('d/m/Y H:i', time());
73
- $this->currency = Mage::helper('payline')->orderCurrency;
74
- $this->details = array();
75
- }
76
- }
77
-
78
- //
79
- // PL_PRIVATEDATA OBJECT DEFINITION
80
- //
81
- class pl_privateData{
82
-
83
- // ATTRIBUTES LISTING
84
- public $key ;
85
- public $value;
86
- }
87
-
88
- //
89
- // PL_AUTHORIZATION OBJECT DEFINITION
90
- //
91
- class pl_authorization{
92
-
93
- // ATTRIBUTES LISTING
94
- public $number;
95
- public $date;
96
- }
97
-
98
- //
99
- // PL_ADDRESS OBJECT DEFINITION
100
- //
101
- class pl_address{
102
-
103
- // ATTRIBUTES LISTING
104
- public $name;
105
- public $street1;
106
- public $street2;
107
- public $cityName;
108
- public $zipCode;
109
- public $country;
110
- public $phone;
111
- }
112
-
113
- //
114
- // PL_BUYER OBJECT DEFINITION
115
- //
116
- class pl_buyer{
117
-
118
- // ATTRIBUTES LISTING
119
- public $lastName;
120
- public $firstName;
121
- public $email;
122
- public $walletId;
123
- public $shippingAdress;
124
- public $accountCreateDate;
125
- public $accountAverageAmount;
126
- public $accountOrderCount;
127
-
128
- function __construct() {
129
- $this->accountCreateDate = date('d/m/y', time());
130
- }
131
- }
132
-
133
- //
134
- // PL_ORDERDETAIL OBJECT DEFINITION
135
- //
136
- class pl_orderDetail{
137
-
138
- // ATTRIBUTES LISTING
139
- public $ref;
140
- public $price;
141
- public $quantity;
142
- public $comment;
143
- }
144
-
145
- //
146
- // PL_CARD OBJECT DEFINITION
147
- //
148
- class pl_card{
149
-
150
- // ATTRIBUTES LISTING
151
- public $number;
152
- public $type;
153
- public $expirationDate;
154
- public $cvx;
155
- public $ownerBirthdayDate;
156
- public $password;
157
-
158
- function __construct($type) {
159
- $this->accountCreateDate = date('d/m/y', time());
160
- }
161
- }
162
-
163
- //
164
- // PL_TRANSACTION OBJECT DEFINITION
165
- //
166
- class pl_transaction{
167
-
168
- // ATTRIBUTES LISTING
169
- public $id;
170
- public $isPossibleFraud;
171
- public $isDuplicated;
172
- public $date;
173
- }
174
-
175
-
176
- //
177
- // PL_RESULT OBJECT DEFINITION
178
- //
179
- class pl_result{
180
-
181
- // ATTRIBUTES LISTING
182
- public $code;
183
- public $shortMessage;
184
- public $longMessage;
185
- }
186
-
187
- //
188
- // PL_CAPTURE OBJECT DEFINITION
189
- //
190
- class pl_capture{
191
-
192
- // ATTRIBUTES LISTING
193
- public $transactionID;
194
- public $payment;
195
- public $sequenceNumber;
196
-
197
- function __construct() {
198
- $this->payment = new pl_payment();
199
- }
200
- }
201
-
202
- //
203
- // PL_REFUND OBJECT DEFINITION
204
- //
205
- class pl_refund extends pl_capture {
206
- function __construct() {
207
- parent::__construct();
208
- }
209
- }
210
-
211
- //
212
- // PL_WALLET OBJECT DEFINITION
213
- //
214
- class pl_wallet{
215
-
216
- // ATTRIBUTES LISTING
217
- public $walletId;
218
- public $lastName;
219
- public $firstName;
220
- public $email;
221
- public $shippingAddress;
222
- public $card;
223
- public $comment;
224
-
225
- function __construct() {
226
- }
227
- }
228
-
229
- //
230
- // PL_RECURRING OBJECT DEFINITION
231
- //
232
- class pl_recurring{
233
-
234
- // ATTRIBUTES LISTING
235
- public $firstAmount;
236
- public $amount;
237
- public $billingCycle;
238
- public $billingLeft;
239
- public $billingDay;
240
- public $startDate;
241
-
242
- function __construct() {
243
- }
244
- }
245
-
246
- //
247
- // PL_AUTHENTIFICATION 3D SECURE
248
- //
249
- class pl_authentication3DSecure{
250
-
251
- // ATTRIBUTES LISTING
252
- public $md ;
253
- public $pares ;
254
- public $xid ;
255
- public $eci ;
256
- public $cavv ;
257
- public $cavvAlgorithm ;
258
- public $vadsResult ;
259
-
260
- function __construct() {
261
- }
262
- }
263
-
264
- //
265
- // PAYLINESDK CLASS
266
- //
267
- class paylineSDK{
268
-
269
- // SOAP URL's
270
- const URL_SOAP = "http://obj.ws.payline.experian.com";
271
-
272
- public $WSDL_SOAP;
273
- public $WSDL_DIRECT_SOAP;
274
- public $WSDL_EXTENDED_SOAP;
275
-
276
- // SOAP ACTIONS CONSTANTS
277
- const soap_result = 'result';
278
- const soap_authorization = 'authorization';
279
- const soap_card = 'card';
280
- const soap_order = 'order';
281
- const soap_orderDetail = 'orderDetail';
282
- const soap_payment = 'payment';
283
- const soap_transaction = 'transaction';
284
- const soap_privateData = 'privateData';
285
- const soap_buyer = 'buyer';
286
- const soap_address = 'address';
287
- const soap_capture = 'capture';
288
- const soap_refund = 'refund';
289
- const soap_refund_auth = 'refundAuthorization';
290
- const soap_authentication3DSecure = 'authentication3DSecure';
291
-
292
- // ARRAY
293
- public $header_soap;
294
- public $items;
295
- public $privates;
296
-
297
- // OPTIONS
298
- public $cancelURL;
299
- public $securityMode;
300
- public $notificationURL;
301
- public $returnURL;
302
- public $customPaymentTemplateURL;
303
- public $customPaymentPageCode;
304
- public $languageCode;
305
-
306
- // WALLET
307
- public $walletIdList;
308
-
309
- /**
310
- * contructor of PAYLINESDK CLASS
311
- **/
312
- function __construct() {
313
-
314
-
315
- $this->cancelURL = Mage::helper('payline')->cancelUrl;
316
- $this->securityMode = Mage::helper('payline')->securityMode;
317
- $this->notificationURL = Mage::helper('payline')->notificationUrl;
318
- $this->returnURL = Mage::helper('payline')->returnUrl;
319
- $this->customPaymentTemplateURL = Mage::helper('payline')->customPaymentTemplateUrl;
320
- $this->customPaymentPageCode = Mage::helper('payline')->customPaymentPageCode;
321
- if (isset(Mage::helper('payline')->languageCode) && !empty(Mage::helper('payline')->languageCode)){
322
- $this->languageCode = Mage::helper('payline')->languageCode;
323
- }
324
- $this->header_soap = array();
325
- $this->header_soap['version'] = "kit version 1.1";
326
- $this->header_soap['proxy_host'] = $this->proxy_host = Mage::helper('payline')->proxyHost;
327
- $this->header_soap['proxy_port'] = $this->proxy_port = Mage::helper('payline')->proxyPort;
328
- $this->header_soap['proxy_login'] = $this->proxy_login = Mage::helper('payline')->proxyLogin;
329
- $this->header_soap['proxy_password'] = $this->proxy_password = Mage::helper('payline')->proxyPassword;
330
- $this->header_soap['login'] = $this->login = Mage::helper('payline')->merchantId;
331
- $this->header_soap['password'] = $this->password = Mage::helper('payline')->accessKey;
332
- $this->header_soap['style'] = SOAP_DOCUMENT;
333
- $this->header_soap['use'] = SOAP_LITERAL;
334
- $this->items = array();
335
- $this->privates = array();
336
- $this->walletIdList = array();// WALLET
337
-
338
- if((string)Mage::helper('payline')->production ) {
339
- $WsdlProductionPath = (string)Mage::getBaseDir().'/app/code/community/Monext/Payline/PaylinePHPKit/wsdl/production/';
340
- $this->WSDL_SOAP = $WsdlProductionPath."WebPaymentAPI.wsdl";
341
- $this->WSDL_DIRECT_SOAP = $WsdlProductionPath."DirectPaymentAPI.wsdl";
342
- $this->WSDL_EXTENDED_SOAP = $WsdlProductionPath."ExtendedAPI.wsdl";
343
- }else{
344
- $WsdlHomologationPath = (string)Mage::getBaseDir().'/app/code/community/Monext/Payline/PaylinePHPKit/wsdl/homologation/';
345
- $this->WSDL_SOAP = $WsdlHomologationPath."WebPaymentAPI.wsdl";
346
- $this->WSDL_DIRECT_SOAP = $WsdlHomologationPath."DirectPaymentAPI.wsdl";
347
- $this->WSDL_EXTENDED_SOAP = $WsdlHomologationPath."ExtendedAPI.wsdl";
348
- }
349
- }
350
-
351
- /**
352
- * function payment
353
- * @params : $array : array. the array keys are listed in pl_payment CLASS.
354
- * @return : SoapVar : object
355
- * @description : build pl_payment instance from $array and make SoapVar object for payment.
356
- **/
357
- protected function payment($array) {
358
- $payment = new pl_payment();
359
- if($array && is_array($array)){
360
- foreach($array as $k=>$v){
361
- if(array_key_exists($k, $payment)&&(strlen($v))){
362
- $payment->$k = $v;
363
- }
364
- }
365
- }
366
- return new SoapVar($payment, SOAP_ENC_OBJECT, paylineSDK::soap_payment, paylineSDK::URL_SOAP);
367
- }
368
-
369
- /**
370
- * function order
371
- * @params : $array : array. the array keys are listed in pl_order CLASS.
372
- * @return : SoapVar : object
373
- * @description : build pl_order instance from $array and make SoapVar object for order.
374
- **/
375
- protected function order($array) {
376
- $order = new pl_order();
377
- if($array && is_array($array)){
378
- foreach($array as $k=>$v){
379
- if(array_key_exists($k, $order)&&(strlen($v))){
380
- $order->$k = $v;
381
- }
382
- }
383
- }
384
- $allDetails = array();
385
- // insert orderDetails
386
- $order->details = $this->items;
387
- return new SoapVar($order, SOAP_ENC_OBJECT, paylineSDK::soap_order, paylineSDK::URL_SOAP);
388
- }
389
-
390
- /**
391
- * function address
392
- * @params : $address : array. the array keys are listed in pl_address CLASS.
393
- * @return : SoapVar : object
394
- * @description : build pl_address instance from $array and make SoapVar object for address.
395
- **/
396
- protected function address($array) {
397
- $address = new pl_address();
398
- if($array && is_array($array)){
399
- foreach($array as $k=>$v){
400
- if(array_key_exists($k, $address)&&(strlen($v)))$address->$k = $v;
401
- }
402
- }
403
- return new SoapVar($address, SOAP_ENC_OBJECT, paylineSDK::soap_address, paylineSDK::URL_SOAP);
404
- }
405
-
406
- /**
407
- * function buyer
408
- * @params : $array : array. the array keys are listed in pl_buyer CLASS.
409
- * @params : $address : array. the array keys are listed in pl_address CLASS.
410
- * @return : SoapVar : object
411
- * @description : build pl_buyer instance from $array and $address and make SoapVar object for buyer.
412
- **/
413
- protected function buyer($array,$address) {
414
- $buyer = new pl_buyer();
415
- if($array && is_array($array)){
416
- foreach($array as $k=>$v){
417
- if(array_key_exists($k, $buyer)&&(strlen($v)))$buyer->$k = $v;
418
- }
419
- }
420
- $buyer->shippingAdress = $this->address($address);
421
- return new SoapVar($buyer, SOAP_ENC_OBJECT, paylineSDK::soap_buyer, paylineSDK::URL_SOAP);
422
- }
423
-
424
- /**
425
- * function contracts
426
- * @params : $contracts : array. array of contracts
427
- * @return : $contracts : array. the same as params if exist, or an array with default contract defined in
428
- * configuration
429
- * @description : Add datas to contract array
430
- **/
431
- protected function contracts($contracts) {
432
- if($contracts && is_array($contracts)){
433
- return $contracts;
434
- }
435
- return array((string)Mage::helper('payline')->contractNumber);
436
- }
437
-
438
- /**
439
- * function getHeader
440
- * @return : header_soap : array. see class contructor for array keys listing.
441
- * @description : Return soap header
442
- **/
443
- public function getHeader() {
444
- return $this->header_soap;
445
- }
446
-
447
- /**
448
- * function authentification 3Dsecure
449
- * @params : $array : array. the array keys are listed in pl_card CLASS.
450
- * @return : SoapVar : object
451
- * @description : build pl_authentication3DSecure instance from $array and make SoapVar object for authentication3DSecure.
452
- **/
453
- protected function authentication3DSecure($array) {
454
- $authentication3DSecure = new pl_authentication3DSecure($array);
455
- if($array && is_array($array)){
456
- foreach($array as $k=>$v){
457
- if(array_key_exists($k, $authentication3DSecure)&&(strlen($v))){
458
- $authentication3DSecure->$k = $v;
459
- }
460
- }
461
- }
462
- return new SoapVar($authentication3DSecure, SOAP_ENC_OBJECT, paylineSDK::soap_authentication3DSecure, paylineSDK::URL_SOAP);
463
- }
464
-
465
- /**
466
- * function authorization
467
- * @params : $array : array. the array keys are listed in pl_card CLASS.
468
- * @return : SoapVar : object
469
- * @description : build pl_authentication3DSecure instance from $array and make SoapVar object for authentication3DSecure.
470
- **/
471
- protected function authorization($array) {
472
- $authorization = new pl_authorization($array);
473
- if($array && is_array($array)){
474
- foreach($array as $k=>$v){
475
- if(array_key_exists($k, $authorization)&&(strlen($v))){
476
- $authorization->$k = $v;
477
- }
478
- }
479
- }
480
- return new SoapVar($authorization, SOAP_ENC_OBJECT, paylineSDK::soap_authorization, paylineSDK::URL_SOAP);
481
- }
482
-
483
- /**
484
- * function card
485
- * @params : $array : array. the array keys are listed in pl_card CLASS.
486
- * @return : SoapVar : object
487
- * @description : build pl_card instance from $array and make SoapVar object for card.
488
- **/
489
- protected function card($array) {
490
- $card = new pl_card($array['type']);
491
- if($array && is_array($array)){
492
- foreach($array as $k=>$v){
493
- if(array_key_exists($k, $card)&&(strlen($v))){
494
- $card->$k = $v;
495
- }
496
- }
497
- }
498
- return new SoapVar($card, SOAP_ENC_OBJECT, paylineSDK::soap_card, paylineSDK::URL_SOAP);
499
- }
500
-
501
- /**
502
- * function setItem
503
- * @params : $item : array. the array keys are listed in PL_ORDERDETAIL CLASS.
504
- * @description : Make $item SoapVar object and insert in items array
505
- **/
506
- public function setItem($item) {
507
- $orderDetail = new pl_orderDetail();
508
- if($item && is_array($item)){
509
- foreach($item as $k=>$v){
510
- if(array_key_exists($k, $orderDetail)&&(strlen($v)))$orderDetail->$k = $v;
511
- }
512
- }
513
- $this->items[] = new SoapVar($orderDetail, SOAP_ENC_OBJECT, paylineSDK::soap_orderDetail, paylineSDK::URL_SOAP);
514
- }
515
-
516
- /**
517
- * function setPrivate
518
- * @params : $private : array. the array keys are listed in PRIVATE CLASS.
519
- * @description : Make $setPrivate SoapVar object and insert in privates array
520
- **/
521
- public function setPrivate($array) {
522
- $private = new pl_privateData();
523
- if($array && is_array($array)){
524
- foreach($array as $k=>$v){
525
- if(array_key_exists($k, $private)&&(strlen($v)))$private->$k = $v;
526
- }
527
- }
528
- $this->privates[] = new SoapVar($private, SOAP_ENC_OBJECT, paylineSDK::soap_privateData, paylineSDK::URL_SOAP);
529
- }
530
-
531
- /****************************************************/
532
- // WEB //
533
- /****************************************************/
534
-
535
- /**
536
- * function do_webpayment
537
- * @params : $array : array. the array keys are :
538
- * payment, returnURL, cancelURL, order, notificationURL,customPaymentTemplateURL, contracts,
539
- * customPaymentPageCode, languageCode, securityMode, buyer, address, recurring
540
- * @params : $debug : boolean . TRUE/FALSE or 0/1
541
- * @return : Array. Array from a payline server response object.
542
- * @description : Do a payment request
543
- **/
544
- public function do_webpayment($array,$debug=0) {
545
- try{
546
- if($array && is_array($array)){
547
- if(isset($array['cancelURL'])&& strlen($array['cancelURL'])) $this->cancelURL = $array['cancelURL'];
548
- if(isset($array['notificationURL']) && strlen($array['notificationURL'])) $this->notificationURL = $array['notificationURL'];
549
- if(isset($array['returnURL'])&& strlen($array['returnURL'])) $this->returnURL = $array['returnURL'];
550
- if(isset($array['customPaymentTemplateURL'])&& strlen($array['customPaymentTemplateURL'])) $this->customPaymentTemplateURL = $array['customPaymentTemplateURL'];
551
- if(isset($array['customPaymentPageCode'])&& strlen($array['customPaymentPageCode'])) $this->customPaymentPageCode = $array['customPaymentPageCode'];
552
- if(isset($array['languageCode'])&& strlen($array['languageCode'])) $this->languageCode = $array['languageCode'];
553
- if(isset($array['securityMode'])&& strlen($array['securityMode'])) $this->securityMode = $array['securityMode'];
554
- if(!isset($array['payment']))$array['payment'] = null;
555
- if(!isset($array['contracts'])||!strlen($array['contracts'][0]))$array['contracts'] = explode(";", Mage::helper('payline')->contractNumberList);
556
- if(!isset($array['buyer']))$array['buyer'] = null;
557
- if(!isset($array['address']))$array['address'] = null;
558
- if(!isset($array['recurring']))$array['recurring'] = null;
559
- $doWebPaymentRequest = array (
560
- 'payment' => $this->payment($array['payment']),
561
- 'returnURL' => $this->returnURL,
562
- 'cancelURL' => $this->cancelURL,
563
- 'order' => $this->order($array['order']),
564
- 'notificationURL' => $this->notificationURL,
565
- 'customPaymentTemplateURL' => $this->customPaymentTemplateURL,
566
- 'selectedContractList' => $this->contracts($array['contracts']),
567
- 'privateDataList' => $this->privates,
568
- 'customPaymentPageCode' => $this->customPaymentPageCode,
569
- 'buyer' => $this->buyer($array['buyer'],$array['address']),
570
- 'securityMode' => $this->securityMode);
571
-
572
- if (isset($this->languageCode) && !empty($this->languageCode)){
573
- $doWebPaymentRequest['languageCode'] = $this->languageCode;
574
- }
575
- //ajout des recurring dans les cas de paiement REC ou NX
576
- if(isset($array['payment']['mode'])){
577
- if(($array['payment']['mode'] == "REC") || ($array['payment']['mode'] == "NX")) {
578
- $doWebPaymentRequest['recurring'] = $this->recurring($array['recurring']);
579
- }
580
- }
581
-
582
- if($debug) {
583
- return util::responseToArray($doWebPaymentRequest);
584
- } else {
585
- $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
586
- $doWebPaymentResponse = $client->doWebPayment($doWebPaymentRequest);
587
- return util::responseToArray($doWebPaymentResponse);
588
- }
589
- }
590
- }
591
- catch ( Exception $e ) {
592
- $msg='ERROR : ' . $e->getMessage() ."\n";
593
- $msg.="WSDL : ".$this->WSDL_SOAP ."\n";
594
- $msg.=print_r($e,true);
595
- Mage::helper('payline/Logger')->log($msg);
596
- Mage::throwException($msg);
597
- }
598
- }
599
-
600
- /**
601
- * function get_webPaymentDetails
602
- * @params : $token : string
603
- * @return : Array. Array from a payline server response object.
604
- * @description : Get payment details
605
- **/
606
- public function get_webPaymentDetails($token) {
607
- try{
608
- $getWebPaymentDetailsRequest = array ('token' => $token);
609
- $client = new SoapClient($this->WSDL_SOAP, $this->header_soap);
610
- $getWebPaymentDetailsResponse = $client->getWebPaymentDetails($getWebPaymentDetailsRequest);
611
- return util::responseToArray($getWebPaymentDetailsResponse);
612
- }
613
- catch ( Exception $e ) {
614
- $msg='ERROR : ' . $e->getMessage();
615
- Mage::helper('payline/Logger')->log($msg);
616
- Mage::throwException($msg);
617
- }
618
-
619
- }
620
-
621
-
622
- /****************************************************/
623
- // DIRECT //
624
- /****************************************************/
625
-
626
- /**
627
- * function do_authorization
628
- * @params : $array : array. the array keys are :
629
- * payment, card, order, privateDataList, buyer
630
- * @return : Array. Array from a payline server response object.
631
- * @description : Do a payment authorization
632
- **/
633
- public function do_authorization($array) {
634
- try{
635
- if (!isset($array['3DSecure'])) $array['3DSecure']=null;
636
- $doAuthorizationRequest = array (
637
- 'payment' => $this->payment($array['payment']),
638
- 'card' => $this->card($array['card']),
639
- 'order' => $this->order($array['order']),
640
- 'privateDataList' => $this->privates,
641
- 'buyer' => $this->buyer($array['buyer'],$array['address']),
642
- 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']));
643
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
644
- $doAuthorizationResponse = $client->doAuthorization($doAuthorizationRequest);
645
- return util::responseToArray($doAuthorizationResponse);
646
- }
647
- catch ( Exception $e ) {
648
- $msg=$e->getMessage();
649
- Mage::helper('payline/Logger')->log($msg);
650
- Mage::throwException($msg);
651
- }
652
- }
653
-
654
- /**
655
- * function do_capture
656
- * @params : $array : array. the array keys are: transactionID, payment
657
- * @return : Array. Array from a payline server response object.
658
- * @description : Do a payment capture
659
- **/
660
- public function do_capture($array) {
661
- try{
662
- $doCaptureRequest = array (
663
- 'transactionID' =>$array['transactionID'],
664
- 'payment' => $this->payment($array['payment']),
665
- 'privateDataList' => $this->privates,
666
- 'sequenceNumber'=>isset($array['sequenceNumber'])?$array['sequenceNumber']:'');
667
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
668
- $doCaptureResponse = $client->doCapture($doCaptureRequest);
669
- return util::responseToArray($doCaptureResponse);
670
- }
671
- catch ( Exception $e ) {
672
- $msg='ERROR : ' . $e->getMessage() . "\n";
673
- Mage::helper('payline/Logger')->log($msg);
674
- Mage::throwException($msg);
675
- }
676
- }
677
-
678
- /**
679
- * function do_refund
680
- * @params : $array : array. the array keys are :
681
- * transactionID, payment, comment
682
- * @return : Array. Array from a payline server response object.
683
- * @description : Do a payment refund
684
- **/
685
- public function do_refund($array) {
686
- try{
687
- $doRefundRequest = array (
688
- 'transactionID' =>$array['transactionID'],
689
- 'payment' =>$this->payment($array['payment']),
690
- 'comment' =>$array['comment'],
691
- 'privateDataList' => $this->privates,
692
- 'sequenceNumber'=>isset($array['sequenceNumber'])?$array['sequenceNumber']:'');
693
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
694
- $doRefundResponse = $client->doRefund($doRefundRequest);
695
- return util::responseToArray($doRefundResponse);
696
- }
697
- catch ( Exception $e ) {
698
- $msg='ERROR : ' . $e->getMessage() . "\n";
699
- Mage::helper('payline/Logger')->log($msg);
700
- Mage::throwException($msg);
701
- }
702
- }
703
-
704
- /**
705
- * function do_credit
706
- * @params : $array : array. the array keys are :
707
- * transactionID, payment, card, comment
708
- * @return : Array. Array from a payline server response object.
709
- * @description : Do a payment credit
710
- **/
711
- public function do_credit($array) {
712
- try{
713
- $doCreditRequest = array (
714
- 'payment' => $this->payment($array['payment']),
715
- 'card' => $this->card($array['card']),
716
- 'buyer' => $this->buyer($array['buyer'],$array['address']),
717
- 'privateDataList' => $this->privates,
718
- 'order' => $this->order($array['order']),
719
- 'comment' =>$array['comment']);
720
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
721
- $doCreditResponse = $client->doCredit($doCreditRequest);
722
- return util::responseToArray($doCreditResponse);
723
- }
724
- catch ( Exception $e ) {
725
- $msg='ERROR : ' . $e->getMessage() . "\n";
726
- Mage::helper('payline/Logger')->log($msg);
727
- Mage::throwException($msg);
728
- }
729
- }
730
-
731
- /**
732
- * function verify_Enrollment
733
- * @params : $array : array. the array keys are :
734
- * card, payment, orderRef
735
- * @return : Array. Array from a payline server response object.
736
- * @description : verify enrollment
737
- **/
738
- public function verify_Enrollment($array) {
739
- try{
740
- $verifyEnrollmentRequest = array (
741
- 'payment' => $this->payment($array['payment']),
742
- 'card' => $this->card($array['card']),
743
- 'orderRef' => $array['orderRef']
744
- );
745
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
746
- $verifyEnrollmentResponse = $client->verifyEnrollment($verifyEnrollmentRequest);
747
- return util::responseToArray($verifyEnrollmentResponse);
748
- }
749
- catch ( Exception $e ) {
750
- $msg='ERROR : ' . $e->getMessage() . "\n";
751
- Mage::helper('payline/Logger')->log($msg);
752
- Mage::throwException($msg);
753
- }
754
- }
755
-
756
- /**
757
- * function do_debit
758
- * @params : $array : array. the array keys are :
759
- * contractNumber, pares, md
760
- * @return : Array. Array from a payline server response object.
761
- * @description : verify an authentication
762
- **/
763
- public function do_debit($array) {
764
- try{
765
- $doDebitRequest = array (
766
- 'payment' => $this->payment($array['payment']),
767
- 'card' => $this->card($array['card']),
768
- 'order' => $this->order($array['order']),
769
- 'privateDataList' => $this->privates,
770
- 'buyer' => $this->buyer($array['buyer'],$array['address']),
771
- 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
772
- 'authorization' =>$this->authorization($array['authorization']));
773
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
774
- $doDebitResponse = $client->doDebit($doDebitRequest);
775
- return util::responseToArray($doDebitResponse);
776
- }
777
- catch ( Exception $e ) {
778
- $msg='ERROR : ' . $e->getMessage() . "\n";
779
- Mage::helper('payline/Logger')->log($msg);
780
- Mage::throwException($msg);
781
- }
782
- }
783
-
784
- /**
785
- * function do_reset
786
- * @params : $array : array. the array keys are :
787
- * transactionID, comment
788
- * @return : Array. Array from a payline server response object.
789
- * @description : Do a payment refund
790
- **/
791
- public function do_reset($array) {
792
- try{
793
- $doResetRequest = array (
794
- 'transactionID' =>$array['transactionID'],
795
- 'comment' =>$array['comment']);
796
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
797
- $doResetResponse = $client->doReset($doResetRequest);
798
- return util::responseToArray($doResetResponse);
799
- }
800
- catch ( Exception $e ) {
801
- $msg='ERROR : ' . $e->getMessage() . "\n";
802
- Mage::helper('payline/Logger')->log($msg);
803
- Mage::throwException($msg);
804
- }
805
- }
806
-
807
- /****************************************************/
808
- // WALLET //
809
- /****************************************************/
810
-
811
- /**
812
- * function wallet
813
- * @params : array : array. the array keys are listed in pl_wallet CLASS.
814
- * @params : address : array. the array keys are listed in pl_address CLASS.
815
- * @params : card : array. the array keys are listed in pl_card CLASS.
816
- * @return : wallet: pl_wallet Object.
817
- * @description : build a wallet object.
818
- **/
819
- protected function wallet($array,$address,$card) {
820
- $wallet = new pl_wallet();
821
- if($array && is_array($array)){
822
- foreach($array as $k=>$v){
823
- if(array_key_exists($k, $wallet)&&(strlen($v)))$wallet->$k = $v;
824
- }
825
- }
826
-
827
- $wallet->shippingAddress = $this->address($address);
828
- $wallet->card = $this->card($card);
829
-
830
- return $wallet;
831
- }
832
-
833
- /**
834
- * function create_Wallet
835
- * @params : array : array. the array keys are :
836
- * contractNumber, wallet, address, card
837
- * @return : Array. Array from a payline server response object.
838
- * @description : create a new wallet.
839
- **/
840
- public function create_Wallet($array){
841
- try{
842
- $createWalletRequest = array (
843
- 'contractNumber' => $array['contractNumber'],
844
- 'privateDataList' => $this->privates,
845
- 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
846
- 'wallet' => $this->wallet($array['wallet'],$array['address'],$array['card'])
847
- );
848
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
849
- $createWalletResponse = $client->createWallet($createWalletRequest);
850
- return util::responseToArray($createWalletResponse);
851
- }
852
- catch ( Exception $e ) {
853
- $msg='ERROR : ' . $e->getMessage() . "\n";
854
- Mage::helper('payline/Logger')->log($msg);
855
- Mage::throwException($msg);
856
- }
857
- }
858
-
859
- /**
860
- * function get_Wallet
861
- * @params : array : array. the array keys are :
862
- * contractNumber, walletId
863
- * @return : Array. Array from a payline server response object.
864
- * @description : get an existing wallet from payline server .
865
- **/
866
- public function get_Wallet($array){
867
- try{
868
- $getWalletRequest = array (
869
- 'contractNumber' => $array['contractNumber'],
870
- 'walletId' => $array['walletId']
871
- );
872
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
873
- $getWalletResponse = $client->getWallet($getWalletRequest);
874
- return util::responseToArray($getWalletResponse);
875
- }
876
- catch ( Exception $e ) {
877
- $msg='ERROR : ' . $e->getMessage() . "\n";
878
- Mage::helper('payline/Logger')->log($msg);
879
- Mage::throwException($msg);
880
- }
881
- }
882
-
883
- /**
884
- * function update_Wallet
885
- * @params : array : array. the array keys are :
886
- * contractNumber, walletId
887
- * @return : Array. Array from a payline server response object.
888
- * @description : update an existing wallet from payline server .
889
- **/
890
- public function update_Wallet($array){
891
- try{
892
- $updateWalletRequest = array (
893
- 'contractNumber' => $array['contractNumber'],
894
- 'privateDataList' => $this->privates,
895
- 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
896
- 'wallet' => $this->wallet($array['wallet'],$array['address'],$array['card'])
897
- );
898
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
899
- $updateWalletResponse = $client->updateWallet($updateWalletRequest);
900
- return util::responseToArray($updateWalletResponse);
901
- }
902
- catch ( Exception $e ) {
903
- $msg='ERROR : ' . $e->getMessage();
904
- Mage::helper('payline/Logger')->log($msg);
905
- Mage::throwException($msg);
906
- }
907
- }
908
-
909
- /**
910
- * function create_Web_Wallet
911
- * @params : array : array. the array keys are :
912
- * contractNumber, selected contact list, updatePersonalDetails, buyer,
913
- * returnURL, cancelURL, notificationURL, languageCode, customPaymentPageCode, securityMode
914
- * @return : Array. Array from a payline server response object.
915
- * @description : create a new web wallet.
916
- **/
917
- public function create_WebWallet($array){
918
- try{
919
- $createWebWalletRequest = array (
920
- 'contractNumber' => $array['contractNumber'],
921
- 'selectedContractList' => $this->contracts($array['contracts']),
922
- 'updatePersonalDetails' => $array['updatePersonalDetails'],
923
- 'buyer' => $this->buyer($array['buyer'],$array['address']),
924
- 'returnURL' => $this->returnURL,
925
- 'cancelURL' => $this->cancelURL,
926
- 'notificationURL' => $this->notificationURL,
927
- 'customPaymentPageCode' => $this->customPaymentPageCode,
928
- 'securityMode' => $this->securityMode);
929
- if (isset($this->languageCode) && !empty($this->languageCode)){
930
- $createWebWalletRequest['languageCode'] = $this->languageCode;
931
- }
932
- $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
933
- $createWebWalletResponse = $client->createWebWallet($createWebWalletRequest);
934
- return util::responseToArray($createWebWalletResponse);
935
- }
936
- catch ( Exception $e ) {
937
- $msg='ERROR : ' . $e->getMessage() ;
938
- Mage::helper('payline/Logger')->log($msg);
939
- Mage::throwException($msg);
940
- }
941
- }
942
-
943
- /**
944
- * function get_WebWallet
945
- * @params : $token : string
946
- * @return : Array. Array from a payline server response object.
947
- * @description : get a wallet.
948
- **/
949
- public function get_WebWallet($token){
950
- try{
951
- $getWebWalletRequest = array ('token' => $token);
952
- $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
953
- $getWebWalletResponse = $client->getWebWallet($getWebWalletRequest);
954
- return util::responseToArray($getWebWalletResponse);
955
- }
956
- catch ( Exception $e ) {
957
- $msg='ERROR : ' . $e->getMessage();
958
- Mage::helper('payline/Logger')->log($msg);
959
- Mage::throwException($msg);
960
- }
961
- }
962
-
963
-
964
- /**
965
- * function update_Web_Wallet
966
- * @params : array : array. the array keys are :
967
- * contractNumber, selected contact list, updatePersonalDetails, buyer,
968
- * returnURL, cancelURL, notificationURL, languageCode, customPaymentPageCode, securityMode
969
- * @return : Array. Array from a payline server response object.
970
- * @description : create a new wallet.
971
- **/
972
- public function update_WebWallet($array){
973
- try{
974
- $updateWebWalletRequest = array (
975
- 'contractNumber' => $array['contractNumber'],
976
- 'walletId' => $array['walletId'],
977
- 'updatePersonalDetails' => $array['updatePersonalDetails'],
978
- 'updatePaymentDetails' => $array['updatePaymentDetails'],
979
- 'customPaymentPageCode' => $this->customPaymentPageCode,
980
- 'securityMode' => $this->securityMode,
981
- 'returnURL' => $this->returnURL,
982
- 'cancelURL' => $this->cancelURL,
983
- 'notificationURL' => $this->notificationURL,
984
- 'privateDataList' => $this->privates,
985
- 'customPaymentTemplateURL' => $this->customPaymentTemplateUrl,
986
- );
987
- if (isset($this->languageCode) && !empty($this->languageCode)){
988
- $updateWebWalletRequest['languageCode'] = $this->languageCode;
989
- }
990
-
991
- $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
992
- $updateWebWalletResponse = $client->updateWebWallet($updateWebWalletRequest);
993
- return util::responseToArray($updateWebWalletResponse);
994
- }
995
- catch ( Exception $e ) {
996
- $msg='ERROR : ' . $e->getMessage() ;
997
- Mage::helper('payline/Logger')->log($msg);
998
- Mage::throwException($msg);
999
- }
1000
- }
1001
-
1002
-
1003
- /**
1004
- * function setWalletIdList
1005
- * @params : sting : string if wallet id separated by ';'.
1006
- * @return :
1007
- * @description : make an array of wallet id .
1008
- **/
1009
- public function setWalletIdList($walletIdList) {
1010
- if ($walletIdList) $this->walletIdList = explode(";", $walletIdList);
1011
- if(empty($walletIdList))$this->walletIdList = array(0) ;
1012
- }
1013
-
1014
- /**
1015
- * function disable_Wallet
1016
- * @params : array : array. the array keys are :
1017
- * contractNumber, walletId
1018
- * @return : Array. Array from a payline server response object.
1019
- * @description : disable an existing wallet from payline server .
1020
- **/
1021
- public function disable_Wallet($array){
1022
- try{
1023
- $disableWalletRequest = array (
1024
- 'contractNumber' => $array['contractNumber'],
1025
- 'walletIdList' => $this->walletIdList
1026
- );
1027
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1028
- $disableWalletResponse = $client->disableWallet($disableWalletRequest);
1029
- return util::responseToArray($disableWalletResponse);
1030
- }
1031
- catch ( Exception $e ) {
1032
- $msg='ERROR : ' . $e->getMessage();
1033
- Mage::helper('payline/Logger')->log($msg);
1034
- Mage::throwException($msg);
1035
- }
1036
- }
1037
-
1038
- /**
1039
- * function enable_Wallet
1040
- * @params : array : array. the array keys are :
1041
- * contractNumber, walletId
1042
- * @return : Array. Array from a payline server response object.
1043
- * @description : enable an existing wallet from payline server .
1044
- **/
1045
- public function enable_Wallet($array){
1046
- try{
1047
- $enableWalletRequest = array (
1048
- 'contractNumber' => $array['contractNumber'],
1049
- 'walletId' => $array['walletId']
1050
- );
1051
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1052
- $enableWalletResponse = $client->enableWallet($enableWalletRequest);
1053
- return util::responseToArray($enableWalletResponse);
1054
- }
1055
- catch ( Exception $e ) {
1056
- $msg='ERROR : ' . $e->getMessage() ;
1057
- Mage::helper('payline/Logger')->log($msg);
1058
- Mage::throwException($msg);
1059
- }
1060
- }
1061
-
1062
- /**
1063
- * function do_immediate_wallet_payment
1064
- * @params : array : array. the array keys are :
1065
- * payment, order, walletId
1066
- * @return : Array. Array from a payline server response object.
1067
- * @description : do an immediate payment from a wallet
1068
- **/
1069
- public function do_immediate_wallet_payment($array){
1070
- try{
1071
- $immediateWalletRequest = array (
1072
- 'payment' => $this->payment($array['payment']),
1073
- 'order' => $this->order($array['order']),
1074
- 'walletId' => $array['walletId'],
1075
- 'privateDataList' => $this->privates
1076
- );
1077
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1078
- $immediateWalletResponse = $client->doImmediateWalletPayment($immediateWalletRequest);
1079
- return util::responseToArray($immediateWalletResponse);
1080
- }
1081
- catch ( Exception $e ) {
1082
- $msg='ERROR : ' . $e->getMessage();
1083
- Mage::helper('payline/Logger')->log($msg);
1084
- Mage::throwException($msg);
1085
- }
1086
- }
1087
-
1088
- /**
1089
- * function do_sheduled_wallet_payment
1090
- * @params : array : array. the array keys are :
1091
- * payment, orderRef, orderDate, walletId, scheduledDate
1092
- * @return : Array. Array from a payline server response object.
1093
- * @description : do a scheduled payment from a wallet
1094
- **/
1095
- public function do_sheduled_wallet_payment($array){
1096
- try{
1097
- $sheduledWalletRequest = array (
1098
- 'payment' => $this->payment($array['payment']),
1099
- 'orderRef' => $array['orderRef'],
1100
- 'orderDate' => $array['orderDate'],
1101
- 'order' => $this->order($array['order']),
1102
- 'walletId' => $array['walletId'],
1103
- 'scheduledDate' => $array['scheduled']
1104
- );
1105
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1106
- $sheduledWalletResponse = $client->doScheduledWalletPayment($sheduledWalletRequest);
1107
- return util::responseToArray($sheduledWalletResponse);
1108
- }
1109
- catch ( Exception $e ) {
1110
- $msg='ERROR : ' . $e->getMessage();
1111
- Mage::helper('payline/Logger')->log($msg);
1112
- Mage::throwException($msg);
1113
- }
1114
- }
1115
-
1116
- /**
1117
- * function recurring
1118
- * @params : array : array. the array keys are listed in pl_recurring CLASS.
1119
- * @return : recurring object.
1120
- * @description : build a recurring object.
1121
- **/
1122
- protected function recurring($array) {
1123
- if($array){
1124
- $recurring = new pl_recurring();
1125
- if($array && is_array($array)){
1126
- foreach($array as $k=>$v){
1127
- if(array_key_exists($k, $recurring)&&(strlen($v)))$recurring->$k = $v;
1128
- }
1129
- }
1130
- //return new SoapVar($recurring, SOAP_ENC_OBJECT, 'recurring', paylineSDK::URL_SOAP);
1131
- return $recurring;
1132
- }
1133
- else return null;
1134
- }
1135
-
1136
- /**
1137
- * function do_recurrent_wallet_payment
1138
- * @params : array : array. the array keys are :
1139
- * payment, orderRef, orderDate, walletId, recurring
1140
- * @return : Array. Array from a payline server response object.
1141
- * @description : do a recurrent payment from a wallet
1142
- **/
1143
- public function do_recurrent_wallet_payment($array){
1144
- try{
1145
- $recurrentWalletRequest = array (
1146
- 'payment' => $this->payment($array['payment']),
1147
- 'orderRef' => $array['orderRef'],
1148
- 'orderDate' => $array['orderDate'],
1149
- 'order' => $this->order($array['order']),
1150
- 'privateDataList' => $this->privates,
1151
- 'walletId' => $array['walletId'],
1152
- 'scheduledDate' => $array['scheduled'],
1153
- 'recurring' => $this->recurring($array['recurring'])
1154
- );
1155
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1156
- $recurrentWalletResponse = $client->doRecurrentWalletPayment($recurrentWalletRequest);
1157
- return util::responseToArray($recurrentWalletResponse);
1158
- }
1159
- catch ( Exception $e ) {
1160
- $msg='ERROR : ' . $e->getMessage() ;
1161
- Mage::helper('payline/Logger')->log($msg);
1162
- Mage::throwException($msg);
1163
- }
1164
- }
1165
-
1166
- /**
1167
- * function get_payment_record
1168
- * @params : array : array. the array keys are :
1169
- * contractNumber, paymentRecordId
1170
- * @return : Array. Array from a payline server response object.
1171
- * @description : get a payment record
1172
- **/
1173
- public function get_payment_record($array){
1174
- try{
1175
- $paymentRecordRequest = array (
1176
- 'contractNumber' => $array['contractNumber'],
1177
- 'paymentRecordId' => $array['paymentRecordId']
1178
- );
1179
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1180
- $paymentRecordResponse = $client->getPaymentRecord($paymentRecordRequest);
1181
- return util::responseToArray($paymentRecordResponse);
1182
- }
1183
- catch ( Exception $e ) {
1184
- $msg='ERROR : ' . $e->getMessage();
1185
- Mage::helper('payline/Logger')->log($msg);
1186
- Mage::throwException($msg);
1187
- }
1188
- }
1189
-
1190
- /**
1191
- * function disable_payment_record
1192
- * @params : array : array. the array keys are :
1193
- * contractNumber, paymentRecordId
1194
- * @return : Array. Array from a payline server response object.
1195
- * @description : disable a payment record
1196
- **/
1197
- public function disable_payment_record($array){
1198
- try{
1199
- $disablePaymentRecordRequest = array (
1200
- 'contractNumber' => $array['contractNumber'],
1201
- 'paymentRecordId' => $array['paymentRecordId']
1202
- );
1203
- $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1204
- $disablePaymentRecordResponse = $client->disablePaymentRecord($disablePaymentRecordRequest);
1205
- return util::responseToArray($disablePaymentRecordResponse);
1206
- }
1207
- catch ( Exception $e ) {
1208
- $msg='ERROR : ' . $e->getMessage();
1209
- Mage::helper('payline/Logger')->log($msg);
1210
- Mage::throwException($msg);
1211
- }
1212
- }
1213
-
1214
- /****************************************************/
1215
- // EXTENDED //
1216
- /****************************************************/
1217
-
1218
- /**
1219
- * function getTransactionDetails
1220
- * @params : array : array. the array keys are :
1221
- * transactionId, orderRef
1222
- * @return : Array. Array from a payline server response object.
1223
- * @description : disable a payment record
1224
- **/
1225
- public function get_TransactionDetails($array){
1226
- try{
1227
- $getTransactionDetailsRequest = array (
1228
- 'transactionId' => $array['transactionId'],
1229
- 'orderRef' => $array['orderRef']
1230
- );
1231
- $client = new SoapClient($this->WSDL_EXTENDED_SOAP, $this->header_soap);
1232
- $getTransactionDetailsResponse = $client->getTransactionDetails($getTransactionDetailsRequest);
1233
- return util::responseToArray($getTransactionDetailsResponse);
1234
- }
1235
- catch ( Exception $e ) {
1236
- $msg='ERROR : ' . $e->getMessage() ;
1237
- Mage::helper('payline/Logger')->log($msg);
1238
- Mage::throwException($msg);
1239
- }
1240
- }
1241
-
1242
- /**
1243
- * function transactionsSearch
1244
- * @params : array : array. the array keys are :
1245
- * transactionId, orderRef, startDate,endDate, authorizationNumber,paymentMean
1246
- * transactionType, name, firstName, email, cardNumber, currency,
1247
- * minAmount, maxAmount, walletId
1248
- * @return : Array. Array from a payline server response object.
1249
- * @description : search transactions
1250
- **/
1251
- public function transactionsSearch($array){
1252
- try{
1253
- $transactionSearchRequest = array (
1254
- 'transactionId' => $array['transactionId'],
1255
- 'orderRef' => $array['orderRef'],
1256
- 'startDate' => $array['startDate'],
1257
- 'endDate' => $array['endDate'],
1258
- 'authorizationNumber' => $array['authorizationNumber'],
1259
- 'paymentMean' => $array['paymentMean'],
1260
- 'transactionType' => $array['transactionType'],
1261
- 'name' => $array['name'],
1262
- 'firstName' => $array['firstName'],
1263
- 'email' => $array['email'],
1264
- 'cardNumber' => $array['cardNumber'],
1265
- 'currency' => $array['currency'],
1266
- 'minAmount' => $array['minAmount'],
1267
- 'maxAmount' => $array['maxAmount'],
1268
- 'walletId' => $array['walletId'],
1269
- 'contractNumber' => $array['contractNumber'],
1270
- 'returnCode' => $array['returnCode']
1271
- );
1272
- $client = new SoapClient($this->WSDL_EXTENDED_SOAP, $this->header_soap);
1273
- $transactionSearchResponse = $client->transactionsSearch($transactionSearchRequest);
1274
- return util::responseToArray($transactionSearchResponse);
1275
- }
1276
- catch ( Exception $e ) {
1277
- $msg='ERROR : ' . $e->getMessage() ;
1278
- Mage::helper('payline/Logger')->log($msg);
1279
- Mage::throwException($msg);
1280
- }
1281
- }
1282
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1283
  ?>
1
+ <?php
2
+ //
3
+ // Payline Class
4
+ // Copyright Monext
5
+ //
6
+
7
+ //
8
+ // OBJECTS DEFINITIONS
9
+ //
10
+
11
+ class util{
12
+
13
+ /**
14
+ * make an array from a payline server response object.
15
+ * @params : $response : Objet response from experian
16
+ * @return : Object convert in an array
17
+ **/
18
+ static function responseToArray($response){
19
+
20
+ $array = array();
21
+ foreach($response as $k=>$v){
22
+ if (is_object($v)) { $array[$k] = util::responseToArray($v); }
23
+ else { $array[$k] = $v; }
24
+ // elseif(is_array($v)){ $array[$k] = util::responseToArray($v); }
25
+
26
+ }
27
+ return $array;
28
+
29
+ return $response;
30
+ }
31
+ }
32
+
33
+ //
34
+ // PL_PAYMENT OBJECT DEFINITION
35
+ //
36
+ class pl_payment{
37
+
38
+ // ATTRIBUTES LISTING
39
+ public $amount;
40
+ public $currency;
41
+ public $action;
42
+ public $mode;
43
+ public $contractNumber;
44
+ public $differedActionDate;
45
+
46
+ function __construct() {
47
+ $this->currency = Mage::helper('payline')->paymentCurrency;
48
+ $this->action = Mage::helper('payline')->paymentAction;
49
+ $this->mode = Mage::helper('payline')->paymentMode;
50
+ $this->contractNumber = Mage::helper('payline')->contractNumber;
51
+ }
52
+ }
53
+
54
+ //
55
+ // PL_ORDER OBJECT DEFINITION
56
+ //
57
+ class pl_order{
58
+
59
+ // ATTRIBUTES LISTING
60
+ public $ref;
61
+ public $origin;
62
+ public $country;
63
+ public $taxes;
64
+ public $amount;
65
+ public $currency;
66
+ public $date;
67
+ public $quantity;
68
+ public $comment;
69
+ public $details;
70
+
71
+ function __construct() {
72
+ $this->date = date('d/m/Y H:i', time());
73
+ $this->currency = Mage::helper('payline')->orderCurrency;
74
+ $this->details = array();
75
+ }
76
+ }
77
+
78
+ //
79
+ // PL_PRIVATEDATA OBJECT DEFINITION
80
+ //
81
+ class pl_privateData{
82
+
83
+ // ATTRIBUTES LISTING
84
+ public $key ;
85
+ public $value;
86
+ }
87
+
88
+ //
89
+ // PL_AUTHORIZATION OBJECT DEFINITION
90
+ //
91
+ class pl_authorization{
92
+
93
+ // ATTRIBUTES LISTING
94
+ public $number;
95
+ public $date;
96
+ }
97
+
98
+ //
99
+ // PL_ADDRESS OBJECT DEFINITION
100
+ //
101
+ class pl_address{
102
+
103
+ // ATTRIBUTES LISTING
104
+ public $name;
105
+ public $street1;
106
+ public $street2;
107
+ public $cityName;
108
+ public $zipCode;
109
+ public $country;
110
+ public $phone;
111
+ }
112
+
113
+ //
114
+ // PL_BUYER OBJECT DEFINITION
115
+ //
116
+ class pl_buyer{
117
+
118
+ // ATTRIBUTES LISTING
119
+ public $lastName;
120
+ public $firstName;
121
+ public $email;
122
+ public $walletId;
123
+ public $shippingAdress;
124
+ public $accountCreateDate;
125
+ public $accountAverageAmount;
126
+ public $accountOrderCount;
127
+
128
+ function __construct() {
129
+ $this->accountCreateDate = date('d/m/y', time());
130
+ }
131
+ }
132
+
133
+ //
134
+ // PL_ORDERDETAIL OBJECT DEFINITION
135
+ //
136
+ class pl_orderDetail{
137
+
138
+ // ATTRIBUTES LISTING
139
+ public $ref;
140
+ public $price;
141
+ public $quantity;
142
+ public $comment;
143
+ }
144
+
145
+ //
146
+ // PL_CARD OBJECT DEFINITION
147
+ //
148
+ class pl_card{
149
+
150
+ // ATTRIBUTES LISTING
151
+ public $number;
152
+ public $type;
153
+ public $expirationDate;
154
+ public $cvx;
155
+ public $ownerBirthdayDate;
156
+ public $password;
157
+
158
+ function __construct($type) {
159
+ $this->accountCreateDate = date('d/m/y', time());
160
+ }
161
+ }
162
+
163
+ //
164
+ // PL_TRANSACTION OBJECT DEFINITION
165
+ //
166
+ class pl_transaction{
167
+
168
+ // ATTRIBUTES LISTING
169
+ public $id;
170
+ public $isPossibleFraud;
171
+ public $isDuplicated;
172
+ public $date;
173
+ }
174
+
175
+
176
+ //
177
+ // PL_RESULT OBJECT DEFINITION
178
+ //
179
+ class pl_result{
180
+
181
+ // ATTRIBUTES LISTING
182
+ public $code;
183
+ public $shortMessage;
184
+ public $longMessage;
185
+ }
186
+
187
+ //
188
+ // PL_CAPTURE OBJECT DEFINITION
189
+ //
190
+ class pl_capture{
191
+
192
+ // ATTRIBUTES LISTING
193
+ public $transactionID;
194
+ public $payment;
195
+ public $sequenceNumber;
196
+
197
+ function __construct() {
198
+ $this->payment = new pl_payment();
199
+ }
200
+ }
201
+
202
+ //
203
+ // PL_REFUND OBJECT DEFINITION
204
+ //
205
+ class pl_refund extends pl_capture {
206
+ function __construct() {
207
+ parent::__construct();
208
+ }
209
+ }
210
+
211
+ //
212
+ // PL_WALLET OBJECT DEFINITION
213
+ //
214
+ class pl_wallet{
215
+
216
+ // ATTRIBUTES LISTING
217
+ public $walletId;
218
+ public $lastName;
219
+ public $firstName;
220
+ public $email;
221
+ public $shippingAddress;
222
+ public $card;
223
+ public $comment;
224
+
225
+ function __construct() {
226
+ }
227
+ }
228
+
229
+ //
230
+ // PL_RECURRING OBJECT DEFINITION
231
+ //
232
+ class pl_recurring{
233
+
234
+ // ATTRIBUTES LISTING
235
+ public $firstAmount;
236
+ public $amount;
237
+ public $billingCycle;
238
+ public $billingLeft;
239
+ public $billingDay;
240
+ public $startDate;
241
+
242
+ function __construct() {
243
+ }
244
+ }
245
+
246
+ //
247
+ // PL_AUTHENTIFICATION 3D SECURE
248
+ //
249
+ class pl_authentication3DSecure{
250
+
251
+ // ATTRIBUTES LISTING
252
+ public $md ;
253
+ public $pares ;
254
+ public $xid ;
255
+ public $eci ;
256
+ public $cavv ;
257
+ public $cavvAlgorithm ;
258
+ public $vadsResult ;
259
+
260
+ function __construct() {
261
+ }
262
+ }
263
+
264
+ //
265
+ // PAYLINESDK CLASS
266
+ //
267
+ class paylineSDK{
268
+
269
+ // SOAP URL's
270
+ const URL_SOAP = "http://obj.ws.payline.experian.com";
271
+
272
+ public $WSDL_SOAP;
273
+ public $WSDL_DIRECT_SOAP;
274
+ public $WSDL_EXTENDED_SOAP;
275
+
276
+ // SOAP ACTIONS CONSTANTS
277
+ const soap_result = 'result';
278
+ const soap_authorization = 'authorization';
279
+ const soap_card = 'card';
280
+ const soap_order = 'order';
281
+ const soap_orderDetail = 'orderDetail';
282
+ const soap_payment = 'payment';
283
+ const soap_transaction = 'transaction';
284
+ const soap_privateData = 'privateData';
285
+ const soap_buyer = 'buyer';
286
+ const soap_address = 'address';
287
+ const soap_capture = 'capture';
288
+ const soap_refund = 'refund';
289
+ const soap_refund_auth = 'refundAuthorization';
290
+ const soap_authentication3DSecure = 'authentication3DSecure';
291
+
292
+ // ARRAY
293
+ public $header_soap;
294
+ public $items;
295
+ public $privates;
296
+
297
+ // OPTIONS
298
+ public $cancelURL;
299
+ public $securityMode;
300
+ public $notificationURL;
301
+ public $returnURL;
302
+ public $customPaymentTemplateURL;
303
+ public $customPaymentPageCode;
304
+ public $languageCode;
305
+
306
+ // WALLET
307
+ public $walletIdList;
308
+ public $walletId;
309
+
310
+ /**
311
+ * contructor of PAYLINESDK CLASS
312
+ **/
313
+ function __construct() {
314
+
315
+
316
+ $this->cancelURL = Mage::helper('payline')->cancelUrl;
317
+ $this->securityMode = Mage::helper('payline')->securityMode;
318
+ $this->notificationURL = Mage::helper('payline')->notificationUrl;
319
+ $this->returnURL = Mage::helper('payline')->returnUrl;
320
+ $this->customPaymentTemplateURL = Mage::helper('payline')->customPaymentTemplateUrl;
321
+ $this->customPaymentPageCode = Mage::helper('payline')->customPaymentPageCode;
322
+ if (isset(Mage::helper('payline')->languageCode) && !empty(Mage::helper('payline')->languageCode)){
323
+ $this->languageCode = Mage::helper('payline')->languageCode;
324
+ }
325
+ $this->header_soap = array();
326
+ $this->header_soap['version'] = "kit version 1.1";
327
+ $this->header_soap['proxy_host'] = $this->proxy_host = Mage::helper('payline')->proxyHost;
328
+ $this->header_soap['proxy_port'] = $this->proxy_port = Mage::helper('payline')->proxyPort;
329
+ $this->header_soap['proxy_login'] = $this->proxy_login = Mage::helper('payline')->proxyLogin;
330
+ $this->header_soap['proxy_password'] = $this->proxy_password = Mage::helper('payline')->proxyPassword;
331
+ $this->header_soap['login'] = $this->login = Mage::helper('payline')->merchantId;
332
+ $this->header_soap['password'] = $this->password = Mage::helper('payline')->accessKey;
333
+ $this->header_soap['style'] = SOAP_DOCUMENT;
334
+ $this->header_soap['use'] = SOAP_LITERAL;
335
+ $this->items = array();
336
+ $this->privates = array();
337
+ $this->walletIdList = array();// WALLET
338
+ $this->walletId='';
339
+
340
+ if((string)Mage::helper('payline')->production ) {
341
+ $WsdlProductionPath = (string)Mage::getBaseDir().'/app/code/community/Monext/Payline/PaylinePHPKit/wsdl/production/';
342
+ $this->WSDL_SOAP = $WsdlProductionPath."WebPaymentAPI.wsdl";
343
+ $this->WSDL_DIRECT_SOAP = $WsdlProductionPath."DirectPaymentAPI.wsdl";
344
+ $this->WSDL_EXTENDED_SOAP = $WsdlProductionPath."ExtendedAPI.wsdl";
345
+ }else{
346
+ $WsdlHomologationPath = (string)Mage::getBaseDir().'/app/code/community/Monext/Payline/PaylinePHPKit/wsdl/homologation/';
347
+ $this->WSDL_SOAP = $WsdlHomologationPath."WebPaymentAPI.wsdl";
348
+ $this->WSDL_DIRECT_SOAP = $WsdlHomologationPath."DirectPaymentAPI.wsdl";
349
+ $this->WSDL_EXTENDED_SOAP = $WsdlHomologationPath."ExtendedAPI.wsdl";
350
+ }
351
+ }
352
+
353
+ /**
354
+ * function payment
355
+ * @params : $array : array. the array keys are listed in pl_payment CLASS.
356
+ * @return : SoapVar : object
357
+ * @description : build pl_payment instance from $array and make SoapVar object for payment.
358
+ **/
359
+ protected function payment($array) {
360
+ $payment = new pl_payment();
361
+ if($array && is_array($array)){
362
+ foreach($array as $k=>$v){
363
+ if(array_key_exists($k, $payment)&&(strlen($v))){
364
+ $payment->$k = $v;
365
+ }
366
+ }
367
+ }
368
+ return new SoapVar($payment, SOAP_ENC_OBJECT, paylineSDK::soap_payment, paylineSDK::URL_SOAP);
369
+ }
370
+
371
+ /**
372
+ * function order
373
+ * @params : $array : array. the array keys are listed in pl_order CLASS.
374
+ * @return : SoapVar : object
375
+ * @description : build pl_order instance from $array and make SoapVar object for order.
376
+ **/
377
+ protected function order($array) {
378
+ $order = new pl_order();
379
+ if($array && is_array($array)){
380
+ foreach($array as $k=>$v){
381
+ if(array_key_exists($k, $order)&&(strlen($v))){
382
+ $order->$k = $v;
383
+ }
384
+ }
385
+ }
386
+ $allDetails = array();
387
+ // insert orderDetails
388
+ $order->details = $this->items;
389
+ return new SoapVar($order, SOAP_ENC_OBJECT, paylineSDK::soap_order, paylineSDK::URL_SOAP);
390
+ }
391
+
392
+ /**
393
+ * function address
394
+ * @params : $address : array. the array keys are listed in pl_address CLASS.
395
+ * @return : SoapVar : object
396
+ * @description : build pl_address instance from $array and make SoapVar object for address.
397
+ **/
398
+ protected function address($array) {
399
+ $address = new pl_address();
400
+ if($array && is_array($array)){
401
+ foreach($array as $k=>$v){
402
+ if(array_key_exists($k, $address)&&(strlen($v)))$address->$k = $v;
403
+ }
404
+ }
405
+ return new SoapVar($address, SOAP_ENC_OBJECT, paylineSDK::soap_address, paylineSDK::URL_SOAP);
406
+ }
407
+
408
+ /**
409
+ * function buyer
410
+ * @params : $array : array. the array keys are listed in pl_buyer CLASS.
411
+ * @params : $address : array. the array keys are listed in pl_address CLASS.
412
+ * @return : SoapVar : object
413
+ * @description : build pl_buyer instance from $array and $address and make SoapVar object for buyer.
414
+ **/
415
+ protected function buyer($array,$address) {
416
+ $buyer = new pl_buyer();
417
+ if($array && is_array($array)){
418
+ foreach($array as $k=>$v){
419
+ if(array_key_exists($k, $buyer)&&(strlen($v)))$buyer->$k = $v;
420
+ }
421
+ }
422
+ $buyer->shippingAdress = $this->address($address);
423
+ return new SoapVar($buyer, SOAP_ENC_OBJECT, paylineSDK::soap_buyer, paylineSDK::URL_SOAP);
424
+ }
425
+
426
+ /**
427
+ * function contracts
428
+ * @params : $contracts : array. array of contracts
429
+ * @return : $contracts : array. the same as params if exist, or an array with default contract defined in
430
+ * configuration
431
+ * @description : Add datas to contract array
432
+ **/
433
+ protected function contracts($contracts) {
434
+ if($contracts && is_array($contracts)){
435
+ return $contracts;
436
+ }
437
+ return array((string)Mage::helper('payline')->contractNumber);
438
+ }
439
+
440
+ /**
441
+ * function getHeader
442
+ * @return : header_soap : array. see class contructor for array keys listing.
443
+ * @description : Return soap header
444
+ **/
445
+ public function getHeader() {
446
+ return $this->header_soap;
447
+ }
448
+
449
+ /**
450
+ * function authentification 3Dsecure
451
+ * @params : $array : array. the array keys are listed in pl_card CLASS.
452
+ * @return : SoapVar : object
453
+ * @description : build pl_authentication3DSecure instance from $array and make SoapVar object for authentication3DSecure.
454
+ **/
455
+ protected function authentication3DSecure($array) {
456
+ $authentication3DSecure = new pl_authentication3DSecure($array);
457
+ if($array && is_array($array)){
458
+ foreach($array as $k=>$v){
459
+ if(array_key_exists($k, $authentication3DSecure)&&(strlen($v))){
460
+ $authentication3DSecure->$k = $v;
461
+ }
462
+ }
463
+ }
464
+ return new SoapVar($authentication3DSecure, SOAP_ENC_OBJECT, paylineSDK::soap_authentication3DSecure, paylineSDK::URL_SOAP);
465
+ }
466
+
467
+ /**
468
+ * function authorization
469
+ * @params : $array : array. the array keys are listed in pl_card CLASS.
470
+ * @return : SoapVar : object
471
+ * @description : build pl_authentication3DSecure instance from $array and make SoapVar object for authentication3DSecure.
472
+ **/
473
+ protected function authorization($array) {
474
+ $authorization = new pl_authorization($array);
475
+ if($array && is_array($array)){
476
+ foreach($array as $k=>$v){
477
+ if(array_key_exists($k, $authorization)&&(strlen($v))){
478
+ $authorization->$k = $v;
479
+ }
480
+ }
481
+ }
482
+ return new SoapVar($authorization, SOAP_ENC_OBJECT, paylineSDK::soap_authorization, paylineSDK::URL_SOAP);
483
+ }
484
+
485
+ /**
486
+ * function card
487
+ * @params : $array : array. the array keys are listed in pl_card CLASS.
488
+ * @return : SoapVar : object
489
+ * @description : build pl_card instance from $array and make SoapVar object for card.
490
+ **/
491
+ protected function card($array) {
492
+ $card = new pl_card($array['type']);
493
+ if($array && is_array($array)){
494
+ foreach($array as $k=>$v){
495
+ if(array_key_exists($k, $card)&&(strlen($v))){
496
+ $card->$k = $v;
497
+ }
498
+ }
499
+ }
500
+ return new SoapVar($card, SOAP_ENC_OBJECT, paylineSDK::soap_card, paylineSDK::URL_SOAP);
501
+ }
502
+
503
+ /**
504
+ * function setItem
505
+ * @params : $item : array. the array keys are listed in PL_ORDERDETAIL CLASS.
506
+ * @description : Make $item SoapVar object and insert in items array
507
+ **/
508
+ public function setItem($item) {
509
+ $orderDetail = new pl_orderDetail();
510
+ if($item && is_array($item)){
511
+ foreach($item as $k=>$v){
512
+ if(array_key_exists($k, $orderDetail)&&(strlen($v)))$orderDetail->$k = $v;
513
+ }
514
+ }
515
+ $this->items[] = new SoapVar($orderDetail, SOAP_ENC_OBJECT, paylineSDK::soap_orderDetail, paylineSDK::URL_SOAP);
516
+ }
517
+
518
+ /**
519
+ * function setPrivate
520
+ * @params : $private : array. the array keys are listed in PRIVATE CLASS.
521
+ * @description : Make $setPrivate SoapVar object and insert in privates array
522
+ **/
523
+ public function setPrivate($array) {
524
+ $private = new pl_privateData();
525
+ if($array && is_array($array)){
526
+ foreach($array as $k=>$v){
527
+ if(array_key_exists($k, $private)&&(strlen($v)))$private->$k = $v;
528
+ }
529
+ }
530
+ $this->privates[] = new SoapVar($private, SOAP_ENC_OBJECT, paylineSDK::soap_privateData, paylineSDK::URL_SOAP);
531
+ }
532
+
533
+ /****************************************************/
534
+ // WEB //
535
+ /****************************************************/
536
+
537
+ /**
538
+ * function do_webpayment
539
+ * @params : $array : array. the array keys are :
540
+ * payment, returnURL, cancelURL, order, notificationURL,customPaymentTemplateURL, contracts,
541
+ * customPaymentPageCode, languageCode, securityMode, buyer, address, recurring
542
+ * @params : $debug : boolean . TRUE/FALSE or 0/1
543
+ * @return : Array. Array from a payline server response object.
544
+ * @description : Do a payment request
545
+ **/
546
+ public function do_webpayment($array,$debug=0) {
547
+ try{
548
+ if($array && is_array($array)){
549
+ if(isset($array['cancelURL'])&& strlen($array['cancelURL'])) $this->cancelURL = $array['cancelURL'];
550
+ if(isset($array['notificationURL']) && strlen($array['notificationURL'])) $this->notificationURL = $array['notificationURL'];
551
+ if(isset($array['returnURL'])&& strlen($array['returnURL'])) $this->returnURL = $array['returnURL'];
552
+ if(isset($array['customPaymentTemplateURL'])&& strlen($array['customPaymentTemplateURL'])) $this->customPaymentTemplateURL = $array['customPaymentTemplateURL'];
553
+ if(isset($array['customPaymentPageCode'])&& strlen($array['customPaymentPageCode'])) $this->customPaymentPageCode = $array['customPaymentPageCode'];
554
+ if(isset($array['languageCode'])&& strlen($array['languageCode'])) $this->languageCode = $array['languageCode'];
555
+ if(isset($array['securityMode'])&& strlen($array['securityMode'])) $this->securityMode = $array['securityMode'];
556
+ if(!isset($array['payment']))$array['payment'] = null;
557
+ if(!isset($array['contracts'])||!strlen($array['contracts'][0]))$array['contracts'] = explode(";", Mage::helper('payline')->contractNumberList);
558
+ if(!isset($array['buyer']))$array['buyer'] = null;
559
+ if(!isset($array['address']))$array['address'] = null;
560
+ if(!isset($array['recurring']))$array['recurring'] = null;
561
+ //WALLET
562
+ if (!isset($array['buyer']['walletId'])) $array['buyer']['walletId']=Mage::helper('payline')->walletId;
563
+ //If the wallet is new (registered during payment), we must save it in the private data since it's not sent back by default
564
+ if (Mage::helper('payline')->isNewWallet){
565
+ if ($array['buyer']['walletId']) $this->setPrivate(array('key'=>'newWalletId','value'=>$array['buyer']['walletId']));
566
+ }
567
+ $doWebPaymentRequest = array (
568
+ 'payment' => $this->payment($array['payment']),
569
+ 'returnURL' => $this->returnURL,
570
+ 'cancelURL' => $this->cancelURL,
571
+ 'order' => $this->order($array['order']),
572
+ 'notificationURL' => $this->notificationURL,
573
+ 'customPaymentTemplateURL' => $this->customPaymentTemplateURL,
574
+ 'selectedContractList' => $this->contracts($array['contracts']),
575
+ 'privateDataList' => $this->privates,
576
+ 'customPaymentPageCode' => $this->customPaymentPageCode,
577
+ 'buyer' => $this->buyer($array['buyer'],$array['address']),
578
+ 'securityMode' => $this->securityMode);
579
+
580
+ if (isset($this->languageCode) && !empty($this->languageCode)){
581
+ $doWebPaymentRequest['languageCode'] = $this->languageCode;
582
+ }
583
+
584
+ //ajout des recurring dans les cas de paiement REC ou NX
585
+ if(isset($array['payment']['mode'])){
586
+ if(($array['payment']['mode'] == "REC") || ($array['payment']['mode'] == "NX")) {
587
+ $doWebPaymentRequest['recurring'] = $this->recurring($array['recurring']);
588
+ }
589
+ }
590
+ if($debug) {
591
+ return util::responseToArray($doWebPaymentRequest);
592
+ } else {
593
+ $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
594
+ $doWebPaymentResponse = $client->doWebPayment($doWebPaymentRequest);
595
+ return util::responseToArray($doWebPaymentResponse);
596
+ }
597
+ }
598
+ }
599
+ catch ( Exception $e ) {
600
+ $msg='ERROR : ' . $e->getMessage() ."\n";
601
+ $msg.="WSDL : ".$this->WSDL_SOAP ."\n";
602
+ $msg.=print_r($e,true);
603
+ Mage::helper('payline/logger')->log($msg);
604
+ Mage::throwException($msg);
605
+ }
606
+ }
607
+
608
+ /**
609
+ * function get_webPaymentDetails
610
+ * @params : $token : string
611
+ * @return : Array. Array from a payline server response object.
612
+ * @description : Get payment details
613
+ **/
614
+ public function get_webPaymentDetails($token) {
615
+ try{
616
+ $getWebPaymentDetailsRequest = array ('token' => $token);
617
+ $client = new SoapClient($this->WSDL_SOAP, $this->header_soap);
618
+ $getWebPaymentDetailsResponse = $client->getWebPaymentDetails($getWebPaymentDetailsRequest);
619
+ return util::responseToArray($getWebPaymentDetailsResponse);
620
+ }
621
+ catch ( Exception $e ) {
622
+ $msg='ERROR : ' . $e->getMessage();
623
+ Mage::helper('payline/logger')->log($msg);
624
+ Mage::throwException($msg);
625
+ }
626
+
627
+ }
628
+
629
+
630
+ /****************************************************/
631
+ // DIRECT //
632
+ /****************************************************/
633
+
634
+ /**
635
+ * function do_authorization
636
+ * @params : $array : array. the array keys are :
637
+ * payment, card, order, privateDataList, buyer
638
+ * @return : Array. Array from a payline server response object.
639
+ * @description : Do a payment authorization
640
+ **/
641
+ public function do_authorization($array) {
642
+ try{
643
+ if (!isset($array['3DSecure'])) $array['3DSecure']=null;
644
+ //WALLET
645
+ if (!isset($array['buyer']['walletId'])) $array['buyer']['walletId']=Mage::helper('payline')->walletId;
646
+ //If the wallet is new (registered during payment), we must save it in the private data since it's not sent back by default
647
+ if (Mage::helper('payline')->isNewWallet){
648
+ if ($array['buyer']['walletId']) $this->setPrivate(array('key'=>'newWalletId','value'=>$array['buyer']['walletId']));
649
+ }
650
+ $doAuthorizationRequest = array (
651
+ 'payment' => $this->payment($array['payment']),
652
+ 'card' => $this->card($array['card']),
653
+ 'order' => $this->order($array['order']),
654
+ 'privateDataList' => $this->privates,
655
+ 'buyer' => $this->buyer($array['buyer'],$array['address']),
656
+ 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']));
657
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
658
+ $doAuthorizationResponse = $client->doAuthorization($doAuthorizationRequest);
659
+ return util::responseToArray($doAuthorizationResponse);
660
+ }
661
+ catch ( Exception $e ) {
662
+ $msg=$e->getMessage();
663
+ Mage::helper('payline/logger')->log($msg);
664
+ Mage::throwException($msg);
665
+ }
666
+ }
667
+
668
+ /**
669
+ * function do_capture
670
+ * @params : $array : array. the array keys are: transactionID, payment
671
+ * @return : Array. Array from a payline server response object.
672
+ * @description : Do a payment capture
673
+ **/
674
+ public function do_capture($array) {
675
+ try{
676
+ $doCaptureRequest = array (
677
+ 'transactionID' =>$array['transactionID'],
678
+ 'payment' => $this->payment($array['payment']),
679
+ 'privateDataList' => $this->privates,
680
+ 'sequenceNumber'=>isset($array['sequenceNumber'])?$array['sequenceNumber']:'');
681
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
682
+ $doCaptureResponse = $client->doCapture($doCaptureRequest);
683
+ return util::responseToArray($doCaptureResponse);
684
+ }
685
+ catch ( Exception $e ) {
686
+ $msg='ERROR : ' . $e->getMessage() . "\n";
687
+ Mage::helper('payline/logger')->log($msg);
688
+ Mage::throwException($msg);
689
+ }
690
+ }
691
+
692
+ /**
693
+ * function do_refund
694
+ * @params : $array : array. the array keys are :
695
+ * transactionID, payment, comment
696
+ * @return : Array. Array from a payline server response object.
697
+ * @description : Do a payment refund
698
+ **/
699
+ public function do_refund($array) {
700
+ try{
701
+ $doRefundRequest = array (
702
+ 'transactionID' =>$array['transactionID'],
703
+ 'payment' =>$this->payment($array['payment']),
704
+ 'comment' =>$array['comment'],
705
+ 'privateDataList' => $this->privates,
706
+ 'sequenceNumber'=>isset($array['sequenceNumber'])?$array['sequenceNumber']:'');
707
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
708
+ $doRefundResponse = $client->doRefund($doRefundRequest);
709
+ return util::responseToArray($doRefundResponse);
710
+ }
711
+ catch ( Exception $e ) {
712
+ $msg='ERROR : ' . $e->getMessage() . "\n";
713
+ Mage::helper('payline/logger')->log($msg);
714
+ Mage::throwException($msg);
715
+ }
716
+ }
717
+
718
+ /**
719
+ * function do_credit
720
+ * @params : $array : array. the array keys are :
721
+ * transactionID, payment, card, comment
722
+ * @return : Array. Array from a payline server response object.
723
+ * @description : Do a payment credit
724
+ **/
725
+ public function do_credit($array) {
726
+ try{
727
+ $doCreditRequest = array (
728
+ 'payment' => $this->payment($array['payment']),
729
+ 'card' => $this->card($array['card']),
730
+ 'buyer' => $this->buyer($array['buyer'],$array['address']),
731
+ 'privateDataList' => $this->privates,
732
+ 'order' => $this->order($array['order']),
733
+ 'comment' =>$array['comment']);
734
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
735
+ $doCreditResponse = $client->doCredit($doCreditRequest);
736
+ return util::responseToArray($doCreditResponse);
737
+ }
738
+ catch ( Exception $e ) {
739
+ $msg='ERROR : ' . $e->getMessage() . "\n";
740
+ Mage::helper('payline/logger')->log($msg);
741
+ Mage::throwException($msg);
742
+ }
743
+ }
744
+
745
+ /**
746
+ * function verify_Enrollment
747
+ * @params : $array : array. the array keys are :
748
+ * card, payment, orderRef
749
+ * @return : Array. Array from a payline server response object.
750
+ * @description : verify enrollment
751
+ **/
752
+ public function verify_Enrollment($array) {
753
+ try{
754
+ $verifyEnrollmentRequest = array (
755
+ 'payment' => $this->payment($array['payment']),
756
+ 'card' => $this->card($array['card']),
757
+ 'orderRef' => $array['orderRef']
758
+ );
759
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
760
+ $verifyEnrollmentResponse = $client->verifyEnrollment($verifyEnrollmentRequest);
761
+ return util::responseToArray($verifyEnrollmentResponse);
762
+ }
763
+ catch ( Exception $e ) {
764
+ $msg='ERROR : ' . $e->getMessage() . "\n";
765
+ Mage::helper('payline/logger')->log($msg);
766
+ Mage::throwException($msg);
767
+ }
768
+ }
769
+
770
+ /**
771
+ * function do_debit
772
+ * @params : $array : array. the array keys are :
773
+ * contractNumber, pares, md
774
+ * @return : Array. Array from a payline server response object.
775
+ * @description : verify an authentication
776
+ **/
777
+ public function do_debit($array) {
778
+ try{
779
+ $doDebitRequest = array (
780
+ 'payment' => $this->payment($array['payment']),
781
+ 'card' => $this->card($array['card']),
782
+ 'order' => $this->order($array['order']),
783
+ 'privateDataList' => $this->privates,
784
+ 'buyer' => $this->buyer($array['buyer'],$array['address']),
785
+ 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
786
+ 'authorization' =>$this->authorization($array['authorization']));
787
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
788
+ $doDebitResponse = $client->doDebit($doDebitRequest);
789
+ return util::responseToArray($doDebitResponse);
790
+ }
791
+ catch ( Exception $e ) {
792
+ $msg='ERROR : ' . $e->getMessage() . "\n";
793
+ Mage::helper('payline/logger')->log($msg);
794
+ Mage::throwException($msg);
795
+ }
796
+ }
797
+
798
+ /**
799
+ * function do_reset
800
+ * @params : $array : array. the array keys are :
801
+ * transactionID, comment
802
+ * @return : Array. Array from a payline server response object.
803
+ * @description : Do a payment refund
804
+ **/
805
+ public function do_reset($array) {
806
+ try{
807
+ $doResetRequest = array (
808
+ 'transactionID' =>$array['transactionID'],
809
+ 'comment' =>$array['comment']);
810
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
811
+ $doResetResponse = $client->doReset($doResetRequest);
812
+ return util::responseToArray($doResetResponse);
813
+ }
814
+ catch ( Exception $e ) {
815
+ $msg='ERROR : ' . $e->getMessage() . "\n";
816
+ Mage::helper('payline/logger')->log($msg);
817
+ Mage::throwException($msg);
818
+ }
819
+ }
820
+
821
+ /****************************************************/
822
+ // WALLET //
823
+ /****************************************************/
824
+
825
+ /**
826
+ * function wallet
827
+ * @params : array : array. the array keys are listed in pl_wallet CLASS.
828
+ * @params : address : array. the array keys are listed in pl_address CLASS.
829
+ * @params : card : array. the array keys are listed in pl_card CLASS.
830
+ * @return : wallet: pl_wallet Object.
831
+ * @description : build a wallet object.
832
+ **/
833
+ protected function wallet($array,$address,$card) {
834
+ $wallet = new pl_wallet();
835
+ if($array && is_array($array)){
836
+ foreach($array as $k=>$v){
837
+ if(array_key_exists($k, $wallet)&&(strlen($v)))$wallet->$k = $v;
838
+ }
839
+ }
840
+
841
+ $wallet->shippingAddress = $this->address($address);
842
+ $wallet->card = $this->card($card);
843
+
844
+ return $wallet;
845
+ }
846
+
847
+ /**
848
+ * function create_Wallet
849
+ * @params : array : array. the array keys are :
850
+ * contractNumber, wallet, address, card
851
+ * @return : Array. Array from a payline server response object.
852
+ * @description : create a new wallet.
853
+ **/
854
+ public function create_Wallet($array){
855
+ try{
856
+ $createWalletRequest = array (
857
+ 'contractNumber' => $array['contractNumber'],
858
+ 'privateDataList' => $this->privates,
859
+ 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
860
+ 'wallet' => $this->wallet($array['wallet'],$array['address'],$array['card'])
861
+ );
862
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
863
+ $createWalletResponse = $client->createWallet($createWalletRequest);
864
+ return util::responseToArray($createWalletResponse);
865
+ }
866
+ catch ( Exception $e ) {
867
+ $msg='ERROR : ' . $e->getMessage() . "\n";
868
+ Mage::helper('payline/logger')->log($msg);
869
+ Mage::throwException($msg);
870
+ }
871
+ }
872
+
873
+ /**
874
+ * function get_Wallet
875
+ * @params : array : array. the array keys are :
876
+ * contractNumber, walletId
877
+ * @return : Array. Array from a payline server response object.
878
+ * @description : get an existing wallet from payline server .
879
+ **/
880
+ public function get_Wallet($array){
881
+ try{
882
+ if(!isset($array['contractNumber'])||!strlen($array['contractNumber'])) $array['contractNumber'] = Mage::helper('payline')->contractNumber;
883
+ $getWalletRequest = array (
884
+ 'contractNumber' => $array['contractNumber'],
885
+ 'walletId' => $array['walletId']
886
+ );
887
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
888
+ $getWalletResponse = $client->getWallet($getWalletRequest);
889
+ return util::responseToArray($getWalletResponse);
890
+ }
891
+ catch ( Exception $e ) {
892
+ $msg='ERROR : ' . $e->getMessage() . "\n";
893
+ Mage::helper('payline/logger')->log($msg);
894
+ Mage::throwException($msg);
895
+ }
896
+ }
897
+
898
+ /**
899
+ * function update_Wallet
900
+ * @params : array : array. the array keys are :
901
+ * contractNumber, walletId
902
+ * @return : Array. Array from a payline server response object.
903
+ * @description : update an existing wallet from payline server .
904
+ **/
905
+ public function update_Wallet($array){
906
+ try{
907
+ $updateWalletRequest = array (
908
+ 'contractNumber' => $array['contractNumber'],
909
+ 'privateDataList' => $this->privates,
910
+ 'authentication3DSecure' =>$this->authentication3DSecure($array['3DSecure']),
911
+ 'wallet' => $this->wallet($array['wallet'],$array['address'],$array['card'])
912
+ );
913
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
914
+ $updateWalletResponse = $client->updateWallet($updateWalletRequest);
915
+ return util::responseToArray($updateWalletResponse);
916
+ }
917
+ catch ( Exception $e ) {
918
+ $msg='ERROR : ' . $e->getMessage();
919
+ Mage::helper('payline/logger')->log($msg);
920
+ Mage::throwException($msg);
921
+ }
922
+ }
923
+
924
+ /**
925
+ * function create_Web_Wallet
926
+ * @params : array : array. the array keys are :
927
+ * contractNumber, selected contact list, updatePersonalDetails, buyer,
928
+ * returnURL, cancelURL, notificationURL, languageCode, customPaymentPageCode, securityMode
929
+ * @return : Array. Array from a payline server response object.
930
+ * @description : create a new web wallet.
931
+ **/
932
+ public function create_WebWallet($array){
933
+ try{
934
+ if(!isset($array['contracts'])||!strlen($array['contracts'][0]))$array['contracts'] = explode(";", Mage::helper('payline')->contractNumberList);
935
+ if(!isset($array['updatePersonalDetails'])||!strlen($array['updatePersonalDetails']))$array['updatePersonalDetails'] = Mage::helper('payline')->updatePersonalDetails;
936
+ if(!isset($array['contractNumber'])||!strlen($array['contractNumber'])) $array['contractNumber'] = Mage::helper('payline')->contractNumber;
937
+ $createWebWalletRequest = array (
938
+ 'contractNumber' => $array['contractNumber'],
939
+ 'selectedContractList' => '',//$this->contracts($array['contracts']),
940
+ 'updatePersonalDetails' => $array['updatePersonalDetails'],
941
+ 'buyer' => $this->buyer($array['buyer'],$array['address']),
942
+ 'returnURL' => $this->returnURL,
943
+ 'cancelURL' => $this->cancelURL,
944
+ 'notificationURL' => $this->notificationURL,
945
+ 'customPaymentPageCode' => $this->customPaymentPageCode,
946
+ 'securityMode' => $this->securityMode,
947
+ );
948
+ if (isset($this->languageCode) && !empty($this->languageCode)){
949
+ $createWebWalletRequest['languageCode'] = $this->languageCode;
950
+ }
951
+
952
+ $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
953
+ $createWebWalletResponse = $client->createWebWallet($createWebWalletRequest);
954
+ return util::responseToArray($createWebWalletResponse);
955
+ }
956
+ catch ( Exception $e ) {
957
+ $msg='ERROR : ' . $e->getMessage() ;
958
+ Mage::helper('payline/logger')->log($msg);
959
+ Mage::throwException($msg);
960
+ }
961
+ }
962
+
963
+ /**
964
+ * function get_WebWallet
965
+ * @params : $token : string
966
+ * @return : Array. Array from a payline server response object.
967
+ * @description : get a wallet.
968
+ **/
969
+ public function get_WebWallet($token){
970
+ try{
971
+ $getWebWalletRequest = array ('token' => $token);
972
+ $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
973
+ $getWebWalletResponse = $client->getWebWallet($getWebWalletRequest);
974
+ return util::responseToArray($getWebWalletResponse);
975
+ }
976
+ catch ( Exception $e ) {
977
+ $msg='ERROR : ' . $e->getMessage();
978
+ Mage::helper('payline/logger')->log($msg);
979
+ Mage::throwException($msg);
980
+ }
981
+ }
982
+
983
+
984
+ /**
985
+ * function update_Web_Wallet
986
+ * @params : array : array. the array keys are :
987
+ * contractNumber, selected contact list, updatePersonalDetails, buyer,
988
+ * returnURL, cancelURL, notificationURL, languageCode, customPaymentPageCode, securityMode
989
+ * @return : Array. Array from a payline server response object.
990
+ * @description : create a new wallet.
991
+ **/
992
+ public function update_WebWallet($array){
993
+ try{
994
+ if(!isset($array['contracts'])||!strlen($array['contracts'][0]))$array['contracts'] = explode(";", Mage::helper('payline')->contractNumberList);
995
+ if(!isset($array['updatePersonalDetails'])||!strlen($array['updatePersonalDetails']))$array['updatePersonalDetails'] = Mage::helper('payline')->updatePersonalDetails;
996
+ if(!isset($array['updatePaymentDetails'])||!strlen($array['updatePaymentDetails']))$array['updatePaymentDetails'] = Mage::helper('payline')->updatePaymentDetails;
997
+ if(!isset($array['contractNumber'])||!strlen($array['contractNumber'])) $array['contractNumber'] = Mage::helper('payline')->contractNumber;
998
+ $updateWebWalletRequest = array (
999
+ 'contractNumber' => $array['contractNumber'],
1000
+ 'walletId' => $array['walletId'],
1001
+ 'updatePersonalDetails' => $array['updatePersonalDetails'],
1002
+ 'updatePaymentDetails' => $array['updatePaymentDetails'],
1003
+ 'customPaymentPageCode' => $this->customPaymentPageCode,
1004
+ 'securityMode' => $this->securityMode,
1005
+ 'returnURL' => $this->returnURL,
1006
+ 'cancelURL' => $this->cancelURL,
1007
+ 'notificationURL' => $this->notificationURL,
1008
+ 'privateDataList' => $this->privates,
1009
+ 'customPaymentTemplateURL' => $this->customPaymentTemplateURL,
1010
+ );
1011
+ if (isset($this->languageCode) && !empty($this->languageCode)){
1012
+ $updateWebWalletRequest['languageCode'] = $this->languageCode;
1013
+ }
1014
+
1015
+ $client = new SoapClient( $this->WSDL_SOAP, $this->header_soap);
1016
+ $updateWebWalletResponse = $client->updateWebWallet($updateWebWalletRequest);
1017
+ return util::responseToArray($updateWebWalletResponse);
1018
+ }
1019
+ catch ( Exception $e ) {
1020
+ $msg='ERROR : ' . $e->getMessage() ;
1021
+ Mage::helper('payline/logger')->log($msg);
1022
+ Mage::throwException($msg);
1023
+ }
1024
+ }
1025
+
1026
+
1027
+ /**
1028
+ * function setWalletIdList
1029
+ * @params : sting : string if wallet id separated by ';'.
1030
+ * @return :
1031
+ * @description : make an array of wallet id .
1032
+ **/
1033
+ public function setWalletIdList($walletIdList) {
1034
+ if ($walletIdList) $this->walletIdList = explode(";", $walletIdList);
1035
+ if(empty($walletIdList))$this->walletIdList = array(0) ;
1036
+ }
1037
+
1038
+ /**
1039
+ * function disable_Wallet
1040
+ * @params : array : array. the array keys are :
1041
+ * contractNumber, walletId
1042
+ * @return : Array. Array from a payline server response object.
1043
+ * @description : disable an existing wallet from payline server .
1044
+ **/
1045
+ public function disable_Wallet($array){
1046
+ try{
1047
+ //if (!isset($array['walletIdList']) $array['walletIdList']=$this->walletIdList;
1048
+ if(!isset($array['contractNumber'])||!strlen($array['contractNumber'])) $array['contractNumber'] = Mage::helper('payline')->contractNumber;
1049
+ $disableWalletRequest = array (
1050
+ 'contractNumber' => $array['contractNumber'],
1051
+ 'walletIdList' => $this->walletIdList
1052
+ );
1053
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1054
+ $disableWalletResponse = $client->disableWallet($disableWalletRequest);
1055
+ return util::responseToArray($disableWalletResponse);
1056
+ }
1057
+ catch ( Exception $e ) {
1058
+ $msg='ERROR : ' . $e->getMessage();
1059
+ Mage::helper('payline/logger')->log($msg);
1060
+ Mage::throwException($msg);
1061
+ }
1062
+ }
1063
+
1064
+ /**
1065
+ * function enable_Wallet
1066
+ * @params : array : array. the array keys are :
1067
+ * contractNumber, walletId
1068
+ * @return : Array. Array from a payline server response object.
1069
+ * @description : enable an existing wallet from payline server .
1070
+ **/
1071
+ public function enable_Wallet($array){
1072
+ try{
1073
+ $enableWalletRequest = array (
1074
+ 'contractNumber' => $array['contractNumber'],
1075
+ 'walletId' => $array['walletId']
1076
+ );
1077
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1078
+ $enableWalletResponse = $client->enableWallet($enableWalletRequest);
1079
+ return util::responseToArray($enableWalletResponse);
1080
+ }
1081
+ catch ( Exception $e ) {
1082
+ $msg='ERROR : ' . $e->getMessage() ;
1083
+ Mage::helper('payline/logger')->log($msg);
1084
+ Mage::throwException($msg);
1085
+ }
1086
+ }
1087
+
1088
+ /**
1089
+ * function do_immediate_wallet_payment
1090
+ * @params : array : array. the array keys are :
1091
+ * payment, order, walletId
1092
+ * @return : Array. Array from a payline server response object.
1093
+ * @description : do an immediate payment from a wallet
1094
+ **/
1095
+ public function do_immediate_wallet_payment($array){
1096
+ try{
1097
+ $immediateWalletRequest = array (
1098
+ 'payment' => $this->payment($array['payment']),
1099
+ 'order' => $this->order($array['order']),
1100
+ 'walletId' => $array['walletId'],
1101
+ 'privateDataList' => $this->privates
1102
+ );
1103
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1104
+ $immediateWalletResponse = $client->doImmediateWalletPayment($immediateWalletRequest);
1105
+ return util::responseToArray($immediateWalletResponse);
1106
+ }
1107
+ catch ( Exception $e ) {
1108
+ $msg='ERROR : ' . $e->getMessage();
1109
+ Mage::helper('payline/logger')->log($msg);
1110
+ Mage::throwException($msg);
1111
+ }
1112
+ }
1113
+
1114
+ /**
1115
+ * function do_sheduled_wallet_payment
1116
+ * @params : array : array. the array keys are :
1117
+ * payment, orderRef, orderDate, walletId, scheduledDate
1118
+ * @return : Array. Array from a payline server response object.
1119
+ * @description : do a scheduled payment from a wallet
1120
+ **/
1121
+ public function do_sheduled_wallet_payment($array){
1122
+ try{
1123
+ $sheduledWalletRequest = array (
1124
+ 'payment' => $this->payment($array['payment']),
1125
+ 'orderRef' => $array['orderRef'],
1126
+ 'orderDate' => $array['orderDate'],
1127
+ 'order' => $this->order($array['order']),
1128
+ 'walletId' => $array['walletId'],
1129
+ 'scheduledDate' => $array['scheduled']
1130
+ );
1131
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1132
+ $sheduledWalletResponse = $client->doScheduledWalletPayment($sheduledWalletRequest);
1133
+ return util::responseToArray($sheduledWalletResponse);
1134
+ }
1135
+ catch ( Exception $e ) {
1136
+ $msg='ERROR : ' . $e->getMessage();
1137
+ Mage::helper('payline/logger')->log($msg);
1138
+ Mage::throwException($msg);
1139
+ }
1140
+ }
1141
+
1142
+ /**
1143
+ * function recurring
1144
+ * @params : array : array. the array keys are listed in pl_recurring CLASS.
1145
+ * @return : recurring object.
1146
+ * @description : build a recurring object.
1147
+ **/
1148
+ protected function recurring($array) {
1149
+ if($array){
1150
+ $recurring = new pl_recurring();
1151
+ if($array && is_array($array)){
1152
+ foreach($array as $k=>$v){
1153
+ if(array_key_exists($k, $recurring)&&(strlen($v)))$recurring->$k = $v;
1154
+ }
1155
+ }
1156
+ //return new SoapVar($recurring, SOAP_ENC_OBJECT, 'recurring', paylineSDK::URL_SOAP);
1157
+ return $recurring;
1158
+ }
1159
+ else return null;
1160
+ }
1161
+
1162
+ /**
1163
+ * function do_recurrent_wallet_payment
1164
+ * @params : array : array. the array keys are :
1165
+ * payment, orderRef, orderDate, walletId, recurring
1166
+ * @return : Array. Array from a payline server response object.
1167
+ * @description : do a recurrent payment from a wallet
1168
+ **/
1169
+ public function do_recurrent_wallet_payment($array){
1170
+ try{
1171
+ $recurrentWalletRequest = array (
1172
+ 'payment' => $this->payment($array['payment']),
1173
+ 'orderRef' => $array['orderRef'],
1174
+ 'orderDate' => $array['orderDate'],
1175
+ 'order' => $this->order($array['order']),
1176
+ 'privateDataList' => $this->privates,
1177
+ 'walletId' => $array['walletId'],
1178
+ 'scheduledDate' => $array['scheduled'],
1179
+ 'recurring' => $this->recurring($array['recurring'])
1180
+ );
1181
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1182
+ $recurrentWalletResponse = $client->doRecurrentWalletPayment($recurrentWalletRequest);
1183
+ return util::responseToArray($recurrentWalletResponse);
1184
+ }
1185
+ catch ( Exception $e ) {
1186
+ $msg='ERROR : ' . $e->getMessage() ;
1187
+ Mage::helper('payline/logger')->log($msg);
1188
+ Mage::throwException($msg);
1189
+ }
1190
+ }
1191
+
1192
+ /**
1193
+ * function get_payment_record
1194
+ * @params : array : array. the array keys are :
1195
+ * contractNumber, paymentRecordId
1196
+ * @return : Array. Array from a payline server response object.
1197
+ * @description : get a payment record
1198
+ **/
1199
+ public function get_payment_record($array){
1200
+ try{
1201
+ $paymentRecordRequest = array (
1202
+ 'contractNumber' => $array['contractNumber'],
1203
+ 'paymentRecordId' => $array['paymentRecordId']
1204
+ );
1205
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1206
+ $paymentRecordResponse = $client->getPaymentRecord($paymentRecordRequest);
1207
+ return util::responseToArray($paymentRecordResponse);
1208
+ }
1209
+ catch ( Exception $e ) {
1210
+ $msg='ERROR : ' . $e->getMessage();
1211
+ Mage::helper('payline/logger')->log($msg);
1212
+ Mage::throwException($msg);
1213
+ }
1214
+ }
1215
+
1216
+ /**
1217
+ * function disable_payment_record
1218
+ * @params : array : array. the array keys are :
1219
+ * contractNumber, paymentRecordId
1220
+ * @return : Array. Array from a payline server response object.
1221
+ * @description : disable a payment record
1222
+ **/
1223
+ public function disable_payment_record($array){
1224
+ try{
1225
+ $disablePaymentRecordRequest = array (
1226
+ 'contractNumber' => $array['contractNumber'],
1227
+ 'paymentRecordId' => $array['paymentRecordId']
1228
+ );
1229
+ $client = new SoapClient($this->WSDL_DIRECT_SOAP, $this->header_soap);
1230
+ $disablePaymentRecordResponse = $client->disablePaymentRecord($disablePaymentRecordRequest);
1231
+ return util::responseToArray($disablePaymentRecordResponse);
1232
+ }
1233
+ catch ( Exception $e ) {
1234
+ $msg='ERROR : ' . $e->getMessage();
1235
+ Mage::helper('payline/logger')->log($msg);
1236
+ Mage::throwException($msg);
1237
+ }
1238
+ }
1239
+
1240
+ /****************************************************/
1241
+ // EXTENDED //
1242
+ /****************************************************/
1243
+
1244
+ /**
1245
+ * function getTransactionDetails
1246
+ * @params : array : array. the array keys are :
1247
+ * transactionId, orderRef
1248
+ * @return : Array. Array from a payline server response object.
1249
+ * @description : disable a payment record
1250
+ **/
1251
+ public function get_TransactionDetails($array){
1252
+ try{
1253
+ $getTransactionDetailsRequest = array (
1254
+ 'transactionId' => $array['transactionId'],
1255
+ 'orderRef' => $array['orderRef']
1256
+ );
1257
+ $client = new SoapClient($this->WSDL_EXTENDED_SOAP, $this->header_soap);
1258
+ $getTransactionDetailsResponse = $client->getTransactionDetails($getTransactionDetailsRequest);
1259
+ return util::responseToArray($getTransactionDetailsResponse);
1260
+ }
1261
+ catch ( Exception $e ) {
1262
+ $msg='ERROR : ' . $e->getMessage() ;
1263
+ Mage::helper('payline/logger')->log($msg);
1264
+ Mage::throwException($msg);
1265
+ }
1266
+ }
1267
+
1268
+ /**
1269
+ * function transactionsSearch
1270
+ * @params : array : array. the array keys are :
1271
+ * transactionId, orderRef, startDate,endDate, authorizationNumber,paymentMean
1272
+ * transactionType, name, firstName, email, cardNumber, currency,
1273
+ * minAmount, maxAmount, walletId
1274
+ * @return : Array. Array from a payline server response object.
1275
+ * @description : search transactions
1276
+ **/
1277
+ public function transactionsSearch($array){
1278
+ try{
1279
+ $transactionSearchRequest = array (
1280
+ 'transactionId' => $array['transactionId'],
1281
+ 'orderRef' => $array['orderRef'],
1282
+ 'startDate' => $array['startDate'],
1283
+ 'endDate' => $array['endDate'],
1284
+ 'authorizationNumber' => $array['authorizationNumber'],
1285
+ 'paymentMean' => $array['paymentMean'],
1286
+ 'transactionType' => $array['transactionType'],
1287
+ 'name' => $array['name'],
1288
+ 'firstName' => $array['firstName'],
1289
+ 'email' => $array['email'],
1290
+ 'cardNumber' => $array['cardNumber'],
1291
+ 'currency' => $array['currency'],
1292
+ 'minAmount' => $array['minAmount'],
1293
+ 'maxAmount' => $array['maxAmount'],
1294
+ 'walletId' => $array['walletId'],
1295
+ 'contractNumber' => $array['contractNumber'],
1296
+ 'returnCode' => $array['returnCode']
1297
+ );
1298
+ $client = new SoapClient($this->WSDL_EXTENDED_SOAP, $this->header_soap);
1299
+ $transactionSearchResponse = $client->transactionsSearch($transactionSearchRequest);
1300
+ return util::responseToArray($transactionSearchResponse);
1301
+ }
1302
+ catch ( Exception $e ) {
1303
+ $msg='ERROR : ' . $e->getMessage() ;
1304
+ Mage::helper('payline/logger')->log($msg);
1305
+ Mage::throwException($msg);
1306
+ }
1307
+ }
1308
+ }
1309
  ?>
app/code/community/Monext/Payline/controllers/CheckoutonepageController.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This controller initialize the checkout for the oneclick payment
4
+ */
5
+ class Monext_Payline_CheckoutonepageController extends Mage_Core_Controller_Front_Action {
6
+
7
+ /**
8
+ * Initialize the onepage checkout by 1 click
9
+ */
10
+ public function indexAction(){
11
+ if (!Mage::getStoreConfig('payment/PaylineWALLET/active')){
12
+ $this->_redirect('checkout/onepage');
13
+ return;
14
+ }
15
+ //INIT
16
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
17
+
18
+ //Customer has wallet?
19
+ if (!(Mage::getSingleton('customer/session')->isLoggedIn())){
20
+ $this->_redirect('customer/account/login');
21
+ return;
22
+ }
23
+
24
+ if (!($walletId=$customer->getWalletId())){
25
+ $this->_redirect('checkout/onepage');
26
+ return;
27
+ }
28
+
29
+ if (!Mage::helper('checkout')->canOnepageCheckout()) {
30
+ Mage::getSingleton('checkout/session')->addError($this->__('The onepage checkout is disabled.'));
31
+ $this->_redirect('checkout/cart');
32
+ return;
33
+ }
34
+ /* @var $onepage Mage_Checkout_Model_Type_Onepage */
35
+ $onepage = Mage::getSingleton('checkout/type_onepage');
36
+ $quote=$onepage->getQuote();
37
+ if (!$quote->hasItems() || $quote->getHasError()) {
38
+ $this->_redirect('checkout/cart');
39
+ return;
40
+ }
41
+ if (!$quote->validateMinimumAmount()) {
42
+ $error = Mage::getStoreConfig('sales/minimum_order/error_message');
43
+ Mage::getSingleton('checkout/session')->addError($error);
44
+ $this->_redirect('checkout/cart');
45
+ return;
46
+ }
47
+
48
+ //Check if the wallet payment is available
49
+ /* @var $walletPaymentMethod Monext_Payline_Model_Wallet */
50
+ $walletPaymentMethod=Mage::getModel('payline/wallet');
51
+ $error='';
52
+ if(!$walletPaymentMethod->checkExpirationDate()){
53
+ $error=$this->__('The credit card of your wallet has expired.');
54
+ $error.='<a href="'.Mage::getUrl('payline/wallet/manage').'">'.
55
+ $this->__('Update your wallet information').'</a>'.
56
+ $this->__(' or process your order below.');
57
+ Mage::getSingleton('checkout/session')->addError($error);
58
+ $this->_redirect('checkout/cart');
59
+ return;
60
+ }elseif(!$walletPaymentMethod->isAvailable()){
61
+ $error=$this->__('The wallet payment method is disabled. You can process your order below.');
62
+ Mage::getSingleton('checkout/session')->addError($error);
63
+ $this->_redirect('checkout/cart');
64
+ return;
65
+ }
66
+
67
+ Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
68
+ Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure'=>true)));
69
+ //Init customer quote, isMultiShipping false
70
+ $onepage->initCheckout();
71
+
72
+ //Checkout enabled?
73
+ if (!Mage::helper('checkout')->canOnepageCheckout()) {
74
+ Mage::getSingleton('checkout/session')->addError($this->__('The onepage checkout is disabled.'));
75
+ $this->_redirect('checkout/cart');
76
+ return;
77
+ }
78
+
79
+ if (version_compare(Mage::getVersion(), '1.4', 'ge')){
80
+ $onepage->saveCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER);
81
+ }
82
+
83
+
84
+ //Get rid of a few problems if order not completed
85
+ $onepage->getQuote()->removeAllAddresses();
86
+ $shippingAddressId = $this->getRequest()->getPost('shipping_address_id', false);
87
+ $billingAddressId = $this->getRequest()->getPost('billing_address_id', false);
88
+ /* PATCH for 1clic btn on checkout/cart */
89
+ if (empty($shippingAddressId)){
90
+ $shippingAddressId = $customer->getPrimaryShippingAddress()->getId();
91
+ }
92
+ if (empty($billingAddressId)){
93
+ $billingAddressId = $customer->getPrimaryBillingAddress()->getId();
94
+ }
95
+ /* PATCH end */
96
+ $billingAddress=Mage::getModel('customer/address')->load($billingAddressId)->getData();
97
+ $shippingAddress=Mage::getModel('customer/address')->load($shippingAddressId)->getData();
98
+ $billingAddressForCheckout=array(
99
+ 'address_id' => $billingAddress['entity_id'],
100
+ );
101
+ $shippingAddressForCheckout=array(
102
+ 'address_id' => $shippingAddress['entity_id'],
103
+ );
104
+
105
+ $onepage->saveBilling($billingAddressForCheckout, $billingAddressId);
106
+
107
+ $onepage->saveShipping($shippingAddressForCheckout, $shippingAddressId);
108
+
109
+ // Get available shipping rates; if one is available by default then use it, otherwise ask customer
110
+ if ($methodCode=Mage::getStoreConfig('payment/PaylineWALLET/default_shipping_method')){
111
+ //Needed to get shipping methods
112
+ $onepage->getQuote()->getShippingAddress()->collectShippingRates()->save();
113
+ $array=$onepage->saveShippingMethod($methodCode);
114
+
115
+ $shippingMethod=$onepage->getQuote()->getShippingAddress()->getShippingMethod();
116
+ Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method', array('request'=>$this->getRequest(), 'quote'=>$quote));
117
+ }
118
+
119
+
120
+ $data=array('method'=>'PaylineWALLET');
121
+ $array=$onepage->savePayment($data);
122
+ $this->loadLayout();
123
+ $this->_initLayoutMessages('customer/session');
124
+
125
+ //If the shipping method is not configured, or the shipping address doesn't fit,
126
+ //the shipping method template is different : when the form is validated, the payment method will be validated as well
127
+ if (!isset($shippingMethod) || empty($shippingMethod)){
128
+ $this->getLayout()->getBlock('checkout.onepage.shipping_method')->setTemplate('payline/checkout/onepage/shipping-method.phtml');
129
+ }
130
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
131
+ $this->renderLayout();
132
+ }
133
+
134
+ }
app/code/community/Monext/Payline/controllers/IndexController.php CHANGED
@@ -1,5 +1,13 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
3
  class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
4
  {
5
  /* @var $order Mage_Sales_Model_Order */
@@ -20,22 +28,9 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
20
  $transaction->setTxnId($transactionId);
21
  $transaction->setOrderPaymentObject($this->order->getPayment());
22
  if($paymentAction == '100'){
23
- //$transaction->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
24
  }else if ($paymentAction == '101'){
25
  $transaction->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
26
- // $payment->setParentTransactionId($transactionId);
27
- // $invoiceId = Mage::getModel('sales/order_invoice_api')
28
- // ->create($this->order->getIncrementId(), array());
29
- /* @var $invoice Mage_Sales_Model_Order_Invoice */
30
- // $invoice = Mage::getModel('sales/order_invoice')
31
- // ->loadByIncrementId($invoiceId);
32
- // $invoice->setTransactionId($transactionId);
33
- // $invoice->pay();
34
- // $invoice->save();
35
- // $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_SUCCESS);
36
- // $payment->setTransactionId($transactionId);
37
- // $payment->setIsTransactionClosed(0);
38
- // $payment->save();
39
  }
40
  $transaction->save();
41
  $this->order->sendNewOrderEmail();
@@ -59,6 +54,24 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
59
  Mage_Core_Controller_Varien_Action::_redirectUrl(Mage::getBaseUrl()."checkout/onepage/");
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  /**
63
  *
64
  * Initialise the requests param array
@@ -77,7 +90,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
77
  $array['payment']['currency'] = $_numericCurrencyCode;
78
 
79
  // ORDER
80
- //Strip strlen to Payline requirements
81
  $array['order']['ref'] = substr($this->order->getRealOrderId(),0,50);
82
  $array['order']['amount'] = $array['payment']['amount'];
83
  $array['order']['currency'] = $_numericCurrencyCode;
@@ -85,25 +98,21 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
85
  $billingAddress = $this->order->getBillingAddress();
86
 
87
  // BUYER
88
- $buyerLastName = $this->order->getCustomerLastname();
89
  if($buyerLastName == null || $buyerLastName == ''){
90
- $buyerLastName = $billingAddress->getLastname();
91
  }
92
- $buyerFirstName = $this->order->getCustomerFirstname();
93
  if($buyerFirstName == null || $buyerFirstName == ''){
94
- $buyerFirstName = $billingAddress->getFirstname();
95
  }
96
-
97
-
98
- $buyerFirstName=substr($buyerFirstName,0,50);
99
- $buyerLastName=substr($buyerLastName,0,50);
100
-
101
-
102
  $array['buyer']['lastName'] = $buyerLastName;
103
  $array['buyer']['firstName'] = $buyerFirstName;
104
 
105
- if (strlen($this->order->getCustomerEmail())<=50){
106
- $array['buyer']['email']=$this->order->getCustomerEmail();
 
 
107
  }else{
108
  $array['buyer']['email'] = '';
109
  }
@@ -113,7 +122,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
113
  $array['address']['street1'] = substr($billingAddress->getStreet1(),0,100);
114
  $array['address']['street2'] = substr($billingAddress->getStreet2(),0,100);
115
  $array['address']['cityName'] = substr($billingAddress->getCity(),0,40);
116
- $array['address']['zipCode'] = substr($billingAddress->getPostcode(),0,12);
117
  //The $billing->getCountry() returns a 2 letter ISO2, should be fine
118
  $array['address']['country'] = $billingAddress->getCountry();
119
  $forbidenCars = array(' ','.','(',')','-');
@@ -124,7 +133,6 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
124
  }else{
125
  $array['address']['phone']='';
126
  }
127
-
128
  return $array;
129
  }
130
 
@@ -162,7 +170,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
162
  if ($items) {
163
  foreach($items as $item) {
164
  $quantity = $item->getQtyOrdered(); // get Qty ordered
165
- $product_id = $item->getProductId(); // get it's ID
166
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id); // Load the stock for this product
167
  $stock->setQty($stock->getQty()+$quantity); // Set to new Qty
168
  $stock->save(); // Save
@@ -176,10 +184,27 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
176
  * Initialize the cpt payment request
177
  */
178
  public function cptAction(){
 
 
 
 
 
 
 
 
 
 
 
 
179
  $array = $this->init();
180
  /* @var $paylineSDK PaylineSDK */
181
  $paylineSDK = Mage::helper('payline')->initPayline('CPT',$array['payment']['currency']);
182
 
 
 
 
 
 
183
  // PRIVATE DATA
184
  $privateData = array();
185
  $privateData['key'] = "orderRef";
@@ -189,6 +214,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
189
  //ORDER DETAILS (optional)
190
  $items = $this->order->getAllItems();
191
  if ($items) {
 
192
  foreach($items as $item) {
193
  $itemPrice = round($item->getPrice()*100);
194
  if($itemPrice > 0){
@@ -204,7 +230,17 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
204
  }
205
 
206
  // EXECUTE
207
- $result = $paylineSDK->do_webpayment($array);
 
 
 
 
 
 
 
 
 
 
208
  // RESPONSE
209
  if(isset($result) && $result['result']['code'] == '00000'){
210
  $initStatus = Mage::getStoreConfig('payment/PaylineCPT/init_order_status');
@@ -221,8 +257,9 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
221
  }else{
222
  $msgLog='Unknown PAYLINE ERROR';
223
  }
224
- Mage::helper('payline/Logger')->log($msgLog);
225
  $this->_redirect('checkout/onepage');
 
226
  }
227
  }
228
 
@@ -251,6 +288,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
251
  //ORDER DETAILS (optional)
252
  $items = $this->order->getAllItems();
253
  if ($items) {
 
254
  foreach($items as $item) {
255
  $itemPrice = round($item->getPrice()*100);
256
  if($itemPrice > 0){
@@ -271,7 +309,17 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
271
  $array['card']['expirationDate'] = $_SESSION['payline_ccdata']->cc_exp_month.$_SESSION['payline_ccdata']->cc_exp_year;
272
  $array['card']['cvx'] = '000';
273
 
274
- $author_result = $paylineSDK->do_authorization($array);
 
 
 
 
 
 
 
 
 
 
275
  // RESPONSE
276
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineDIRECT/failed_order_status');
277
  if(isset($author_result) && $author_result['result']['code'] == '00000'){
@@ -286,14 +334,14 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
286
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
287
  }else{
288
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
289
- //$this->updateStock();
290
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
291
 
292
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
293
  $msg=Mage::helper('payline')->__('Error during payment');
294
  Mage::getSingleton('core/session')->addError($msg);
295
- Mage::helper('payline/Logger')->log($msgLog);
296
  $this->_redirect('checkout/onepage');
 
297
  }
298
  $this->order->save();
299
  Mage_Core_Controller_Varien_Action::_redirectSuccess($redirectUrl);
@@ -307,18 +355,142 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
307
  }
308
  $msg=Mage::helper('payline')->__('Error during payment');
309
  Mage::getSingleton('core/session')->addError($msg);
310
- Mage::helper('payline/Logger')->log($msgLog);
311
  $this->_redirect('checkout/onepage');
 
312
  }
313
  }
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  /**
316
  * Initialize the NX payment request
317
  */
318
  public function nxAction(){
 
 
 
 
 
 
 
 
 
 
 
 
319
  $array = $this->init();
320
  $paylineSDK = Mage::helper('payline')->initPayline('NX',$array['payment']['currency']);
321
 
 
 
 
 
 
322
  $nx = Mage::getStoreConfig('payment/PaylineNX/billing_occurrences');
323
  $array['payment']['mode'] = 'NX';
324
  $array['recurring']['amount'] = round($array['payment']['amount']/$nx);
@@ -337,6 +509,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
337
  //ORDER DETAILS (optional)
338
  $items = $this->order->getAllItems();
339
  if ($items) {
 
340
  foreach($items as $item) {
341
  $itemPrice = round($item->getPrice()*100);
342
  if($itemPrice > 0){
@@ -351,8 +524,21 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
351
  }
352
  }
353
 
 
 
 
354
  // EXECUTE
355
- $result = $paylineSDK->do_webpayment($array);
 
 
 
 
 
 
 
 
 
 
356
  // RESPONSE
357
  if(isset($result) && $result['result']['code'] == '00000'){
358
  $initStatus = Mage::getStoreConfig('payment/PaylineNX/init_order_status');
@@ -368,9 +554,10 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
368
  $msgLog='Unknown PAYLINE ERROR';
369
  }
370
  $msg=Mage::helper('payline')->__('Error during payment');
371
- Mage::helper('payline/Logger')->log($msg);
372
  Mage::getSingleton('core/session')->addError($msg);
373
  $this->_redirect('checkout/onepage');
 
374
 
375
  }
376
  }
@@ -379,17 +566,24 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
379
  * Action called on the customer's return form the Payline website.
380
  */
381
  public function cptReturnAction(){
382
- //Mage_Core_Controller_Varien_Action::_redirectSuccess($this->cptNotifAction());
383
  $res = Mage::helper('payline')->initPayline('CPT')->get_webPaymentDetails($_GET['token']);
384
- $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
 
 
 
 
 
 
385
  //If order is still new, notifAction haven't been called yet
386
  if ($this->order->getState()==Mage_Sales_Model_Order::STATE_NEW){
387
  Mage_Core_Controller_Varien_Action::_redirectSuccess($this->cptNotifAction());
388
  }
389
  if ($this->order->getState()==Mage_Sales_Model_Order::STATE_PROCESSING){
390
  $this->_redirect('checkout/onepage/success');
 
391
  }else{
392
  $this->_redirect('checkout/onepage');
 
393
  }
394
  }
395
 
@@ -397,23 +591,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
397
  * Action called on the customer's return form the Payline website.
398
  */
399
  public function nxReturnAction(){
400
- // $res = Mage::helper('payline')->initPayline('CPT')->get_webPaymentDetails($_GET['token']);
401
- // $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
402
-
403
-
404
  Mage_Core_Controller_Varien_Action::_redirectSuccess($this->nxNotifAction());
405
-
406
- //We can't use the following since the method will be called N times
407
- //If order is still new, notifyAction haven't been called
408
- // if ($this->order->getState()==Mage_Sales_Model_Order::STATE_NEW){
409
- // Mage_Core_Controller_Varien_Action::_redirectSuccess($this->nxNotifAction());
410
- // }
411
- // if ($this->order->getState()==Mage_Sales_Model_Order::STATE_PROCESSING){
412
- // Mage_Core_Controller_Varien_Action::_redirectSuccess($this->nxNotifAction());
413
- // $this->_redirect('checkout/onepage/success');
414
- // }else{
415
- // $this->_redirect('checkout/onepage');
416
- // }
417
  }
418
 
419
  /**
@@ -421,13 +599,21 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
421
  */
422
  public function cptNotifAction(){
423
  $res = Mage::helper('payline')->initPayline('CPT')->get_webPaymentDetails($_GET['token']);
424
- $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
 
 
 
 
 
425
 
426
  $newOrderStatus = Mage::getStoreConfig('payment/PaylineCPT/new_order_status');
427
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineCPT/failed_order_status');
428
  if($this->updateOrder($res,$res['transaction']['id'])){
429
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/success/";
430
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
 
 
 
431
  }else{
432
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
433
  if(isset($res)){
@@ -435,7 +621,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
435
  }else{
436
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
437
  }
438
- Mage::helper('payline/Logger')->log($msgLog);
439
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
440
  }
441
  $this->order->save();
@@ -448,8 +634,13 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
448
  public function nxNotifAction(){
449
 
450
  $res = Mage::helper('payline')->initPayline('NX')->get_webPaymentDetails($_GET['token']);
451
- $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
452
- Mage::helper('payline/Logger')->log('Entrée NX notif pou rla commande '.$res['privateDataList']['privateData']['value']);
 
 
 
 
 
453
  $newOrderStatus = Mage::getStoreConfig('payment/PaylineNX/new_order_status');
454
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineNX/failed_order_status');
455
 
@@ -466,6 +657,9 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
466
  if($this->updateOrder($res,$billingRecord->transaction->id)){
467
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/success/";
468
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
 
 
 
469
  }else{
470
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
471
  if(isset($res)){
@@ -473,7 +667,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
473
  }else{
474
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
475
  }
476
- Mage::helper('payline/Logger')->log($msgLog);
477
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
478
  }
479
  $this->order->save();
@@ -491,8 +685,8 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
491
  //Invalid transaction or error during the process on Payline side
492
  //No error display, the customer is already told on the Payline side
493
  $msg='PAYLINE ERROR : '.$res['result']['code']. ' '.$res['result']['longMessage'];
494
- Mage::helper('payline/Logger')->log($msg);
495
- $cancelStatus= Mage::getStoreConfig('payment/PaylineCPT/failed_order_status');
496
  }else{
497
  //Transaction cancelled by customer
498
  $cancelStatus = Mage::getStoreConfig('payment/PaylineCPT/canceled_order_status');
@@ -511,7 +705,7 @@ class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
511
  //Invalid transaction or error during the process on Payline side
512
  //No error display, the customer is already told on the Payline side
513
  $msg='PAYLINE ERROR : '.$res['result']['code']. ' '.$res['result']['longMessage'];
514
- Mage::helper('payline/Logger')->log($msg);
515
  $cancelStatus=Mage::getStoreConfig('payment/PaylineNX/failed_order_status');
516
  }else{
517
  //Transaction cancelled by customer
1
  <?php
2
 
3
+ /**
4
+ * This controller manage all payline payment
5
+ * cptAction, directAction, nxAction & walletAction are called just after the checkout validation
6
+ * the return/notify/cancel are the urls called by Payline
7
+ * An exception for notifyAction : it's not directly called by Payline, since it couldn't work in a local environment; it's then called by the returnAction.
8
+ * @author fague
9
+ *
10
+ */
11
  class Monext_Payline_IndexController extends Mage_Core_Controller_Front_Action
12
  {
13
  /* @var $order Mage_Sales_Model_Order */
28
  $transaction->setTxnId($transactionId);
29
  $transaction->setOrderPaymentObject($this->order->getPayment());
30
  if($paymentAction == '100'){
31
+
32
  }else if ($paymentAction == '101'){
33
  $transaction->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT);
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
  $transaction->save();
36
  $this->order->sendNewOrderEmail();
54
  Mage_Core_Controller_Varien_Action::_redirectUrl(Mage::getBaseUrl()."checkout/onepage/");
55
  }
56
 
57
+ /**
58
+ * Check if the customer is logged, and if it has a wallet
59
+ * If not & if there is a walletId in the result from Payline, we save it
60
+ */
61
+ public function saveWallet($walletId){
62
+ if (!Mage::getStoreConfig('payment/PaylineWALLET/automate_subscription')){
63
+ return;
64
+ }
65
+ $customer=Mage::getSingleton('customer/session');
66
+ if ($customer->isLoggedIn()){
67
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
68
+ if (!$customer->getWalletId()){
69
+ $customer->setWalletId($walletId);
70
+ $customer->save();
71
+ }
72
+ }
73
+ }
74
+
75
  /**
76
  *
77
  * Initialise the requests param array
90
  $array['payment']['currency'] = $_numericCurrencyCode;
91
 
92
  // ORDER
93
+ //
94
  $array['order']['ref'] = substr($this->order->getRealOrderId(),0,50);
95
  $array['order']['amount'] = $array['payment']['amount'];
96
  $array['order']['currency'] = $_numericCurrencyCode;
98
  $billingAddress = $this->order->getBillingAddress();
99
 
100
  // BUYER
101
+ $buyerLastName = substr($this->order->getCustomerLastname(),0,50);
102
  if($buyerLastName == null || $buyerLastName == ''){
103
+ $buyerLastName = substr($billingAddress->getLastname(),0,50);
104
  }
105
+ $buyerFirstName = substr($this->order->getCustomerFirstname(),0,50);
106
  if($buyerFirstName == null || $buyerFirstName == ''){
107
+ $buyerFirstName = substr($billingAddress->getFirstname(),0,50);
108
  }
 
 
 
 
 
 
109
  $array['buyer']['lastName'] = $buyerLastName;
110
  $array['buyer']['firstName'] = $buyerFirstName;
111
 
112
+
113
+ $email=$this->order->getCustomerEmail();
114
+ if (strlen($email)<=50 && Zend_Validate::is($email, 'EmailAddress')) {
115
+ $array['buyer']['email']=$email;
116
  }else{
117
  $array['buyer']['email'] = '';
118
  }
122
  $array['address']['street1'] = substr($billingAddress->getStreet1(),0,100);
123
  $array['address']['street2'] = substr($billingAddress->getStreet2(),0,100);
124
  $array['address']['cityName'] = substr($billingAddress->getCity(),0,40);
125
+ $array['address']['zipCode'] = substr($billingAddress->getPostcode(),0,20);
126
  //The $billing->getCountry() returns a 2 letter ISO2, should be fine
127
  $array['address']['country'] = $billingAddress->getCountry();
128
  $forbidenCars = array(' ','.','(',')','-');
133
  }else{
134
  $array['address']['phone']='';
135
  }
 
136
  return $array;
137
  }
138
 
170
  if ($items) {
171
  foreach($items as $item) {
172
  $quantity = $item->getQtyOrdered(); // get Qty ordered
173
+ $product_id = $item->getProductId(); // get its ID
174
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id); // Load the stock for this product
175
  $stock->setQty($stock->getQty()+$quantity); // Set to new Qty
176
  $stock->save(); // Save
184
  * Initialize the cpt payment request
185
  */
186
  public function cptAction(){
187
+
188
+ //Check if wallet is sendable
189
+ //Must be done before call to Payline helper initialisation
190
+ $expiredWalletId=false;
191
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
192
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
193
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
194
+ if ($customer->getWalletId() && !Mage::getModel('payline/wallet')->checkExpirationDate()){
195
+ $expiredWalletId=true;
196
+ }
197
+ }
198
+
199
  $array = $this->init();
200
  /* @var $paylineSDK PaylineSDK */
201
  $paylineSDK = Mage::helper('payline')->initPayline('CPT',$array['payment']['currency']);
202
 
203
+ //If wallet isn't sendable...
204
+ if ($expiredWalletId){
205
+ Mage::helper('payline')->walletId=null;
206
+ }
207
+
208
  // PRIVATE DATA
209
  $privateData = array();
210
  $privateData['key'] = "orderRef";
214
  //ORDER DETAILS (optional)
215
  $items = $this->order->getAllItems();
216
  if ($items) {
217
+ if(count($items)>100) $items=array_slice($items,0,100);
218
  foreach($items as $item) {
219
  $itemPrice = round($item->getPrice()*100);
220
  if($itemPrice > 0){
230
  }
231
 
232
  // EXECUTE
233
+ try{
234
+ $result = $paylineSDK->do_webpayment($array);
235
+ }catch(Exception $e){
236
+ $this->updateStock();
237
+ $msg=Mage::helper('payline')->__('Error during payment');
238
+ Mage::getSingleton('core/session')->addError($msg);
239
+ $msgLog='Unknown PAYLINE ERROR (payline unreachable?)';
240
+ Mage::helper('payline/logger')->log($msgLog);
241
+ $this->_redirect('checkout/onepage');
242
+ return;
243
+ }
244
  // RESPONSE
245
  if(isset($result) && $result['result']['code'] == '00000'){
246
  $initStatus = Mage::getStoreConfig('payment/PaylineCPT/init_order_status');
257
  }else{
258
  $msgLog='Unknown PAYLINE ERROR';
259
  }
260
+ Mage::helper('payline/logger')->log($msgLog);
261
  $this->_redirect('checkout/onepage');
262
+ return;
263
  }
264
  }
265
 
288
  //ORDER DETAILS (optional)
289
  $items = $this->order->getAllItems();
290
  if ($items) {
291
+ if(count($items)>100) $items=array_slice($items,0,100);
292
  foreach($items as $item) {
293
  $itemPrice = round($item->getPrice()*100);
294
  if($itemPrice > 0){
309
  $array['card']['expirationDate'] = $_SESSION['payline_ccdata']->cc_exp_month.$_SESSION['payline_ccdata']->cc_exp_year;
310
  $array['card']['cvx'] = '000';
311
 
312
+ try{
313
+ $author_result = $paylineSDK->do_authorization($array);
314
+ }catch(Exception $e){
315
+ $this->updateStock();
316
+ $msg=Mage::helper('payline')->__('Error during payment');
317
+ Mage::getSingleton('core/session')->addError($msg);
318
+ $msgLog='Unknown PAYLINE ERROR (payline unreachable?)';
319
+ Mage::helper('payline/logger')->log($msgLog);
320
+ $this->_redirect('checkout/onepage');
321
+ return;
322
+ }
323
  // RESPONSE
324
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineDIRECT/failed_order_status');
325
  if(isset($author_result) && $author_result['result']['code'] == '00000'){
334
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
335
  }else{
336
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
 
337
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
338
 
339
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
340
  $msg=Mage::helper('payline')->__('Error during payment');
341
  Mage::getSingleton('core/session')->addError($msg);
342
+ Mage::helper('payline/logger')->log($msgLog);
343
  $this->_redirect('checkout/onepage');
344
+ return;
345
  }
346
  $this->order->save();
347
  Mage_Core_Controller_Varien_Action::_redirectSuccess($redirectUrl);
355
  }
356
  $msg=Mage::helper('payline')->__('Error during payment');
357
  Mage::getSingleton('core/session')->addError($msg);
358
+ Mage::helper('payline/logger')->log($msgLog);
359
  $this->_redirect('checkout/onepage');
360
+ return;
361
  }
362
  }
363
 
364
+
365
+ /** Initialisize a WALLET payment request
366
+ *
367
+ */
368
+ /**
369
+ * Initialize & process a wallet direct payment request
370
+ */
371
+ public function walletAction(){
372
+ $array = $this->init();
373
+ $paylineSDK = Mage::helper('payline')->initPayline('WALLET',$array['payment']['currency']);
374
+
375
+ //PAYMENT
376
+ $array['payment']['action'] = Mage::getStoreConfig('payment/PaylineWALLET/payline_payment_action');
377
+ $array['payment']['mode'] = 'CPT';
378
+
379
+ //Get the wallet contract number from card type
380
+ $wallet=Mage::getModel('payline/wallet')->getWalletData();
381
+ if ($wallet['card']['type']=='AMEX'){
382
+ $array['payment']['contractNumber']=Mage::getStoreConfig('payment/PaylineWALLET/contract_number_AMEX');
383
+ }else{
384
+ $array['payment']['contractNumber']=Mage::getStoreConfig('payment/PaylineWALLET/contract_number_CB');
385
+ }
386
+
387
+ //ORDER
388
+ $array['order']['date'] = date("d/m/Y H:i");
389
+
390
+ //PRIVATE DATA
391
+ $privateData1 = array();
392
+ $privateData1['key'] = 'orderRef';
393
+ $privateData1['value'] = substr(str_replace(array("\r","\n","\t"), array('','',''),$array['order']['ref']), 0,255);
394
+ $paylineSDK->setPrivate($privateData1);
395
+
396
+ //ORDER DETAILS (optional)
397
+ $items = $this->order->getAllItems();
398
+ if ($items) {
399
+ if(count($items)>100) $items=array_slice($items,0,100);
400
+ foreach($items as $item) {
401
+ $itemPrice = round($item->getPrice()*100);
402
+ if($itemPrice > 0){
403
+ $product = array();
404
+ $product['ref'] = substr(str_replace(array("\r","\n","\t"), array('','',''),$item->getName()),0,50);
405
+ $product['price'] = $item->getPrice()*100;
406
+ $product['quantity'] = round($item->getQtyOrdered());
407
+ $product['comment'] = substr(str_replace(array("\r","\n","\t"), array('','',''),$item->getDescription()), 0,255);
408
+ $paylineSDK->setItem($product);
409
+ }
410
+ continue;
411
+ }
412
+ }
413
+
414
+ $customerId=Mage::getSingleton('customer/session')->getId();
415
+ $customer=Mage::getModel('customer/customer')->load($customerId);
416
+ $walletId=$customer->getWalletId();
417
+ $array['walletId']=$walletId;
418
+
419
+ try{
420
+ $author_result = $paylineSDK->do_immediate_wallet_payment($array);
421
+ }catch(Exception $e){
422
+ $this->updateStock();
423
+ $msg=Mage::helper('payline')->__('Error during payment');
424
+ Mage::getSingleton('core/session')->addError($msg);
425
+ $msgLog='Unknown PAYLINE ERROR (payline unreachable?) during wallet payment';
426
+ Mage::helper('payline/logger')->log($msgLog);
427
+ $this->_redirect('checkout/onepage');
428
+ return;
429
+ }
430
+ // RESPONSE
431
+ $failedOrderStatus = Mage::getStoreConfig('payment/PaylineWALLET/failed_order_status');
432
+ if(isset($author_result) && $author_result['result']['code'] == '00000'){
433
+ $array_details = array();
434
+ $array_details['orderRef'] = $this->order->getRealOrderId();
435
+ $array_details['transactionId'] = $author_result['transaction']['id'];
436
+ $detail_result = $paylineSDK->get_TransactionDetails($array_details);
437
+
438
+ if($this->updateOrder($detail_result,$detail_result['transaction']['id'])){
439
+ $redirectUrl = Mage::getBaseUrl()."checkout/onepage/success/";
440
+ $newOrderStatus = Mage::getStoreConfig('payment/PaylineWALLET/new_order_status');
441
+ $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
442
+ }else{
443
+ $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
444
+ $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
445
+
446
+ $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
447
+ $msg=Mage::helper('payline')->__('Error during payment');
448
+ Mage::getSingleton('core/session')->addError($msg);
449
+ Mage::helper('payline/logger')->log($msgLog);
450
+ $this->_redirect('checkout/onepage');
451
+ return;
452
+ }
453
+ $this->order->save();
454
+ Mage_Core_Controller_Varien_Action::_redirectSuccess($redirectUrl);
455
+ }else {
456
+ $this->updateStock();
457
+ $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
458
+ if(isset($author_result)){
459
+ $msgLog='PAYLINE ERROR during doImmediateWalletPayment: '.$author_result['result']['code']. ' '.$author_result['result']['longMessage'];
460
+ }else{
461
+ $msgLog='Unknown PAYLINE ERROR during doImmediateWalletPayment';
462
+ }
463
+ $msg=Mage::helper('payline')->__('Error during payment');
464
+ Mage::getSingleton('core/session')->addError($msg);
465
+ Mage::helper('payline/logger')->log($msgLog);
466
+ $this->_redirect('checkout/onepage');
467
+ return;
468
+ }
469
+ }
470
  /**
471
  * Initialize the NX payment request
472
  */
473
  public function nxAction(){
474
+
475
+ //Check if wallet is sendable
476
+ //Must be done before call to Payline helper initialisation
477
+ $expiredWalletId=false;
478
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
479
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
480
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
481
+ if ($customer->getWalletId() && !Mage::getModel('payline/wallet')->checkExpirationDate()){
482
+ $expiredWalletId=true;
483
+ }
484
+ }
485
+
486
  $array = $this->init();
487
  $paylineSDK = Mage::helper('payline')->initPayline('NX',$array['payment']['currency']);
488
 
489
+ //If wallet isn't sendable...
490
+ if ($expiredWalletId){
491
+ Mage::helper('payline')->walletId=null;
492
+ }
493
+
494
  $nx = Mage::getStoreConfig('payment/PaylineNX/billing_occurrences');
495
  $array['payment']['mode'] = 'NX';
496
  $array['recurring']['amount'] = round($array['payment']['amount']/$nx);
509
  //ORDER DETAILS (optional)
510
  $items = $this->order->getAllItems();
511
  if ($items) {
512
+ if(count($items)>100) $items=array_slice($items,0,100);
513
  foreach($items as $item) {
514
  $itemPrice = round($item->getPrice()*100);
515
  if($itemPrice > 0){
524
  }
525
  }
526
 
527
+
528
+
529
+
530
  // EXECUTE
531
+ try{
532
+ $result = $paylineSDK->do_webpayment($array);
533
+ }catch(Exception $e){
534
+ $this->updateStock();
535
+ $msg=Mage::helper('payline')->__('Error during payment');
536
+ Mage::getSingleton('core/session')->addError($msg);
537
+ $msgLog='Unknown PAYLINE ERROR (payline unreachable?)';
538
+ Mage::helper('payline/logger')->log($msgLog);
539
+ $this->_redirect('checkout/onepage');
540
+ return;
541
+ }
542
  // RESPONSE
543
  if(isset($result) && $result['result']['code'] == '00000'){
544
  $initStatus = Mage::getStoreConfig('payment/PaylineNX/init_order_status');
554
  $msgLog='Unknown PAYLINE ERROR';
555
  }
556
  $msg=Mage::helper('payline')->__('Error during payment');
557
+ Mage::helper('payline/logger')->log($msg);
558
  Mage::getSingleton('core/session')->addError($msg);
559
  $this->_redirect('checkout/onepage');
560
+ return;
561
 
562
  }
563
  }
566
  * Action called on the customer's return form the Payline website.
567
  */
568
  public function cptReturnAction(){
 
569
  $res = Mage::helper('payline')->initPayline('CPT')->get_webPaymentDetails($_GET['token']);
570
+
571
+ if (isset($res['privateDataList']['privateData'][0])){
572
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData'][0]->value);
573
+ }else{
574
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
575
+ }
576
+
577
  //If order is still new, notifAction haven't been called yet
578
  if ($this->order->getState()==Mage_Sales_Model_Order::STATE_NEW){
579
  Mage_Core_Controller_Varien_Action::_redirectSuccess($this->cptNotifAction());
580
  }
581
  if ($this->order->getState()==Mage_Sales_Model_Order::STATE_PROCESSING){
582
  $this->_redirect('checkout/onepage/success');
583
+ return;
584
  }else{
585
  $this->_redirect('checkout/onepage');
586
+ return;
587
  }
588
  }
589
 
591
  * Action called on the customer's return form the Payline website.
592
  */
593
  public function nxReturnAction(){
 
 
 
 
594
  Mage_Core_Controller_Varien_Action::_redirectSuccess($this->nxNotifAction());
 
 
 
 
 
 
 
 
 
 
 
 
595
  }
596
 
597
  /**
599
  */
600
  public function cptNotifAction(){
601
  $res = Mage::helper('payline')->initPayline('CPT')->get_webPaymentDetails($_GET['token']);
602
+
603
+ if (isset($res['privateDataList']['privateData'][0])){
604
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData'][0]->value);
605
+ }else{
606
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
607
+ }
608
 
609
  $newOrderStatus = Mage::getStoreConfig('payment/PaylineCPT/new_order_status');
610
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineCPT/failed_order_status');
611
  if($this->updateOrder($res,$res['transaction']['id'])){
612
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/success/";
613
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
614
+ if (isset($res['privateDataList']['privateData'][1]) && $res['privateDataList']['privateData'][1]->value!=''){
615
+ $this->saveWallet($res['privateDataList']['privateData'][1]->value);
616
+ }
617
  }else{
618
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
619
  if(isset($res)){
621
  }else{
622
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
623
  }
624
+ Mage::helper('payline/logger')->log($msgLog);
625
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
626
  }
627
  $this->order->save();
634
  public function nxNotifAction(){
635
 
636
  $res = Mage::helper('payline')->initPayline('NX')->get_webPaymentDetails($_GET['token']);
637
+
638
+ if (isset($res['privateDataList']['privateData'][0])){
639
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData'][0]->value);
640
+ }else{
641
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($res['privateDataList']['privateData']['value']);
642
+ }
643
+
644
  $newOrderStatus = Mage::getStoreConfig('payment/PaylineNX/new_order_status');
645
  $failedOrderStatus = Mage::getStoreConfig('payment/PaylineNX/failed_order_status');
646
 
657
  if($this->updateOrder($res,$billingRecord->transaction->id)){
658
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/success/";
659
  $this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING,$newOrderStatus,'',false);
660
+ if (isset($res['privateDataList']['privateData'][1]) && $res['privateDataList']['privateData'][1]->value!=''){
661
+ $this->saveWallet($res['privateDataList']['privateData'][1]->value);
662
+ }
663
  }else{
664
  $this->order->setState(Mage_Sales_Model_Order::STATE_CANCELED,$failedOrderStatus,'',false);
665
  if(isset($res)){
667
  }else{
668
  $msgLog='Error during order update (#'.$this->order->getIncrementId().')';
669
  }
670
+ Mage::helper('payline/logger')->log($msgLog);
671
  $redirectUrl = Mage::getBaseUrl()."checkout/onepage/";
672
  }
673
  $this->order->save();
685
  //Invalid transaction or error during the process on Payline side
686
  //No error display, the customer is already told on the Payline side
687
  $msg='PAYLINE ERROR : '.$res['result']['code']. ' '.$res['result']['longMessage'];
688
+ Mage::helper('payline/logger')->log($msg);
689
+ $cancelStatus=Mage::getStoreConfig('payment/PaylineCPT/failed_order_status');
690
  }else{
691
  //Transaction cancelled by customer
692
  $cancelStatus = Mage::getStoreConfig('payment/PaylineCPT/canceled_order_status');
705
  //Invalid transaction or error during the process on Payline side
706
  //No error display, the customer is already told on the Payline side
707
  $msg='PAYLINE ERROR : '.$res['result']['code']. ' '.$res['result']['longMessage'];
708
+ Mage::helper('payline/logger')->log($msg);
709
  $cancelStatus=Mage::getStoreConfig('payment/PaylineNX/failed_order_status');
710
  }else{
711
  //Transaction cancelled by customer
app/code/community/Monext/Payline/controllers/UnloggedwalletController.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * On IE, seems like cookies are not sent when in an iframe
4
+ * We don't have to be logged since the customer email is transmitted in the order - we can retrieve the customer object from it
5
+ * @todo Only move the customer out of the iframe here, and do the getWallet in the WalletController
6
+ *
7
+ */
8
+ class Monext_Payline_UnloggedwalletController extends Mage_Core_Controller_Front_Action
9
+ {
10
+ /**
11
+ * New subscription notification
12
+ */
13
+ public function subscribeNotifyAction(){
14
+ $token=$_GET['token'];
15
+ $res = Mage::helper('payline')->initPayline('WALLET')->get_webWallet($token);
16
+ $redirectUrl="payline/wallet/manage";
17
+ if (!isset($res['result']) || $res['result']['code']!='02500'){
18
+ if(isset($res['result'])){
19
+ $msgLog='PAYLINE ERROR on getWebWallet: '.$res['result']['code']. ' '.$res['result']['longMessage'];
20
+ }else{
21
+ $msgLog='Unknown PAYLINE ERROR on getWebWallet';
22
+ }
23
+ $msg=Mage::helper('payline')->__('Error during subscription');
24
+ Mage::helper('payline/Logger')->log($msgLog);
25
+ Mage::getSingleton('core/session')->addError($msg);
26
+ $redirectUrl="payline/wallet/subscribe";
27
+ return $redirectUrl;
28
+ }
29
+
30
+ $customer = Mage::getModel('customer/customer');
31
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
32
+ $customer->loadByEmail($res['wallet']['email']);
33
+ $customer->setWalletId($res['wallet']['walletId']);
34
+ $customer->save();
35
+ $msg=Mage::helper('payline')->__('Wallet subscription succeed');
36
+ Mage::getSingleton('core/session')->addSuccess($msg);
37
+ return $redirectUrl;
38
+ }
39
+
40
+ /**
41
+ * Return from the iframe
42
+ * Show a page in the iframe which only redirect the user to the manage wallet page (or the subscription page if error)
43
+ */
44
+ public function subscribeReturnAction(){
45
+ $this->loadLayout();
46
+ $redirectUrl=$this->subscribeNotifyAction();
47
+ $this->getLayout()->getBlock('payline-iframe-leaver')->setRedirectUrl($redirectUrl);
48
+ $this->renderLayout();
49
+ }
50
+
51
+ /**
52
+ * Return from the iframe
53
+ * Show a page in the iframe which only redirect the user to the subscription page
54
+ */
55
+ public function subscribeCancelAction(){
56
+ $msg=Mage::helper('payline')->__('Error during subscription');
57
+ $msgLog=$msg." (cancelAction)";
58
+ Mage::helper('payline/Logger')->log($msgLog);
59
+ Mage::getSingleton('core/session')->addError($msg);
60
+
61
+ $this->loadLayout();
62
+ $redirectUrl='payline/wallet/subscribe';
63
+ $this->getLayout()->getBlock('payline-iframe-leaver')->setRedirectUrl($redirectUrl);
64
+ $this->renderLayout();
65
+ }
66
+
67
+ /**
68
+ * New subscription notification
69
+ */
70
+ public function updateNotifyAction(){
71
+ $token=$_GET['token'];
72
+ $res = Mage::helper('payline')->initPayline('WALLET')->get_webWallet($token);
73
+ $redirectUrl="payline/wallet/manage";
74
+ if (!isset($res['result']) || $res['result']['code']!='02500'){
75
+ if(isset($res['result'])){
76
+ $msgLog='PAYLINE ERROR on getWebWallet after update: '.$res['result']['code']. ' '.$res['result']['longMessage'];
77
+ }else{
78
+ $msgLog='Unknown PAYLINE ERROR on getWebWallet after update';
79
+ }
80
+ $msg=Mage::helper('payline')->__('Error during update');
81
+ Mage::helper('payline/Logger')->log($msgLog);
82
+ Mage::getSingleton('core/session')->addError($msg);
83
+ $redirectUrl="payline/wallet/udpate";
84
+ return $redirectUrl;
85
+ }
86
+
87
+ $msg=Mage::helper('payline')->__('Wallet update succeed');
88
+ Mage::getSingleton('core/session')->addSuccess($msg);
89
+ return $redirectUrl;
90
+ }
91
+
92
+ /**
93
+ * Return from the iframe
94
+ * Show a page in the iframe which only redirect the user to the manage wallet page
95
+ */
96
+ public function updateReturnAction(){
97
+ $this->loadLayout();
98
+ $redirectUrl=$this->updateNotifyAction();
99
+ $this->getLayout()->getBlock('payline-iframe-leaver')->setRedirectUrl($redirectUrl);
100
+ $this->renderLayout();
101
+ }
102
+
103
+ /**
104
+ * Return from the iframe
105
+ * Show a page in the iframe which only redirect the user to the manage page
106
+ */
107
+ public function updateCancelAction(){
108
+ $msg=Mage::helper('payline')->__('Error during update');
109
+ $msgLog=$msg." (cancelAction)";
110
+ Mage::helper('payline/Logger')->log($msgLog);
111
+ Mage::getSingleton('core/session')->addError($msg);
112
+
113
+ $this->loadLayout();
114
+ $redirectUrl='payline/wallet/manage';
115
+ $this->getLayout()->getBlock('payline-iframe-leaver')->setRedirectUrl($redirectUrl);
116
+ $this->renderLayout();
117
+ }
118
+ }
app/code/community/Monext/Payline/controllers/WalletController.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This controller manage wallet in the customer account (subscribe, update, disable, ...)
4
+ * @author fague
5
+ *
6
+ */
7
+ class Monext_Payline_WalletController extends Mage_Core_Controller_Front_Action
8
+ {
9
+ /**
10
+ * Action predispatch
11
+ *
12
+ * Check customer authentication
13
+ */
14
+ public function preDispatch()
15
+ {
16
+ parent::preDispatch();
17
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
18
+ $this->setFlag('', 'no-dispatch', true);
19
+ }
20
+ if (!Mage::getStoreConfig('payment/PaylineWALLET/active')){
21
+ $this->setFlag('', 'no-dispatch', true);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Simply redirect to manageAction
27
+ */
28
+ public function indexAction(){
29
+ $this->_redirect('*/*/manage');
30
+ }
31
+
32
+ /**
33
+ * Display user's wallet informations
34
+ */
35
+ public function manageAction(){
36
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
37
+
38
+ if (!($walletId=$customer->getWalletId())){
39
+ $this->_redirect('payline/wallet/subscribe');
40
+ return;
41
+ }
42
+
43
+ $this->loadLayout();
44
+
45
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Wallet management'));
46
+
47
+ $res=Mage::getModel('payline/wallet')->getWalletData();
48
+ if ($res){
49
+ $this->getLayout()->getBlock('payline-wallet-details')->setWallet($res);
50
+ }
51
+
52
+ $this->_initLayoutMessages('customer/session');
53
+ $this->_initLayoutMessages('core/session');
54
+ $this->renderLayout();
55
+
56
+ }
57
+
58
+ /**
59
+ * Display wallet subscription iframe
60
+ */
61
+ public function subscribeAction(){
62
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
63
+ $customer=Mage::getModel('customer/customer')->load($customer->getId());
64
+ if ($customer->getWalletId()){
65
+ $this->_redirect('payline/wallet/manage');
66
+ return;
67
+ }
68
+ $this->loadLayout();
69
+
70
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Subscribe to wallet'));
71
+
72
+ /* @var $paylineHelper Monext_Payline_Helper_Data */
73
+ $paylineHelper=Mage::helper('payline');
74
+ $paylineHelper->notificationUrl=Mage::getBaseUrl().'payline/unloggedwallet/subscribeNotify';
75
+ $paylineHelper->returnUrl=Mage::getBaseUrl().'payline/unloggedwallet/subscribeReturn';
76
+ $paylineHelper->cancelUrl=Mage::getBaseUrl().'payline/unloggedwallet/subscribeCancel';
77
+ /* @var $paylineSDK PaylineSDK */
78
+ $paylineSDK=$paylineHelper->initPayline('WALLET');
79
+ //TODO add address data
80
+ $array=array(
81
+ 'buyer'=>array(
82
+ 'lastName'=>substr($customer->getLastname(),0,100),
83
+ 'firstName'=>substr($customer->getFirstname(),0,100),
84
+ 'email'=>substr($customer->getEmail(),0,150),
85
+ 'walletId'=>Mage::getModel('payline/wallet')->generateWalletId()
86
+ ),
87
+ 'address'=>array(),
88
+ );
89
+
90
+ try{
91
+ $resultCreateWebWallet=$paylineSDK->create_WebWallet($array);
92
+ }catch (Exception $e){
93
+ $msgLog='Unknown PAYLINE ERROR on createWebWallet (Payline unreachable?)';
94
+ $msg=Mage::helper('payline')->__('Error during subscription');
95
+ Mage::helper('payline/logger')->log($msgLog);
96
+ Mage::getSingleton('customer/session')->addError($msg);
97
+ }
98
+ if (!isset($resultCreateWebWallet['result']) || $resultCreateWebWallet['result']['code']!='00000'){
99
+ if(isset($resultCreateWebWallet['result'])){
100
+ $msgLog='PAYLINE ERROR on createWebWallet: '.$resultCreateWebWallet['result']['code']. ' '.$resultCreateWebWallet['result']['longMessage'];
101
+ }else{
102
+ $msgLog='Unknown PAYLINE ERROR on createWebWallet';
103
+ }
104
+ $msg=Mage::helper('payline')->__('Error during subscription');
105
+ Mage::helper('payline/logger')->log($msg);
106
+ Mage::getSingleton('customer/session')->addError($msg);
107
+ $this->_redirect('customer/account');
108
+ return;
109
+ }
110
+
111
+ $this->getLayout()->getBlock('payline-wallet-subscribe-cmsblock')->setBlockId(Mage::getStoreConfig('payment/PaylineWALLET/payline_register-oneclick_customeraccount'));
112
+ $urlPayline=$resultCreateWebWallet['redirectURL'];
113
+
114
+ if (Mage::getStoreConfig('payment/PaylineWALLET/update_personal_details')){
115
+ $iframeClass='iframe-subscribe-wallet iframe-with-perso-data';
116
+ }else{
117
+ $iframeClass='iframe-subscribe-wallet';
118
+ }
119
+ $this->getLayout()->getBlock('payline-wallet-subscribe-iframe')->setIframeClassName($iframeClass);
120
+ $this->getLayout()->getBlock('payline-wallet-subscribe-iframe')->setIframeSrc($urlPayline);
121
+
122
+ $this->_initLayoutMessages('customer/session');
123
+ $this->_initLayoutMessages('core/session');
124
+ $this->renderLayout();
125
+ }
126
+
127
+ /**
128
+ * Disable customer wallet, delete customer's walletId attribute value
129
+ */
130
+ public function disableAction(){
131
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
132
+
133
+ if (!($walletId=$customer->getWalletId())){
134
+ $this->_redirect('payline/wallet/subscribe');
135
+ return;
136
+ }
137
+
138
+ $paylineSDK = Mage::helper('payline')->initPayline('WALLET');
139
+ $paylineSDK->setWalletIdList($walletId);
140
+ $array=array();
141
+ try{
142
+ $res=$paylineSDK->disable_Wallet($array);
143
+ }catch (Exception $e){
144
+ $msgLog='Unknown PAYLINE ERROR on disableWallet (Payline unreachable?)';
145
+ $msg=Mage::helper('payline')->__('Error while disabling wallet');
146
+ Mage::helper('payline/logger')->log($msgLog);
147
+ Mage::getSingleton('customer/session')->addError($msg);
148
+ }
149
+
150
+ if (!isset($res['result']) || ($res['result']['code']!='02500' && $res['result']['code']!='02501' && $res['result']['code']=='02505')){
151
+ if(isset($res['result'])){
152
+ $msgLog='PAYLINE ERROR on disableWallet: '.$res['result']['code']. ' '.$res['result']['longMessage'];
153
+ }else{
154
+ $msgLog='Unknown PAYLINE ERROR on disableWallet';
155
+ }
156
+ $msg=Mage::helper('payline')->__('Error during disableWallet');
157
+ Mage::helper('payline/logger')->log($msg);
158
+ Mage::getSingleton('customer/session')->addError($msg);
159
+ $this->_redirect('customer/account');
160
+ return;
161
+ }
162
+
163
+ $customer->setWalletId();
164
+ $customer->save();
165
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Your wallet has been disabled.'));
166
+ $this->_redirect('customer/account');
167
+ return;
168
+
169
+ }
170
+
171
+ /**
172
+ *
173
+ * Display wallet update iframe
174
+ * Update payment card, not perso details
175
+ */
176
+ public function updateAction(){
177
+ $customer=Mage::getSingleton('customer/session')->getCustomer();
178
+ if (!($walletId=$customer->getWalletId())){
179
+ $this->_redirect('payline/wallet/subscribe');
180
+ return;
181
+ }
182
+ $this->loadLayout();
183
+
184
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Update wallet'));
185
+
186
+ /* @var $paylineHelper Monext_Payline_Helper_Data */
187
+ $paylineHelper=Mage::helper('payline');
188
+ $paylineHelper->notificationUrl=Mage::getBaseUrl().'payline/unloggedwallet/updateNotify';
189
+ $paylineHelper->returnUrl=Mage::getBaseUrl().'payline/unloggedwallet/updateReturn';
190
+ $paylineHelper->cancelUrl=Mage::getBaseUrl().'payline/unloggedwallet/updateCancel';
191
+ /* @var $paylineSDK PaylineSDK */
192
+ $paylineSDK=$paylineHelper->initPayline('WALLET');
193
+ $array=array(
194
+ 'walletId'=>$walletId,
195
+ );
196
+ $paylineSDK->setPrivate(array('customerId'=>$customer->getId()));
197
+
198
+ try{
199
+ $res=$paylineSDK->update_WebWallet($array);
200
+ }catch (Exception $e){
201
+ $msgLog='Unknown PAYLINE ERROR on updateWebWallet (Payline unreachable?)';
202
+ $msg=Mage::helper('payline')->__('Error during wallet update');
203
+ Mage::helper('payline/logger')->log($msgLog);
204
+ Mage::getSingleton('customer/session')->addError($msg);
205
+ }
206
+ if (!isset($res['result']) || ($res['result']['code']!='00000' && $res['result']['code']!='02502')){
207
+ if(isset($res['result'])){
208
+ $msgLog='PAYLINE ERROR on updateWebWallet: '.$res['result']['code']. ' '.$res['result']['longMessage'];
209
+ }else{
210
+ $msgLog='Unknown PAYLINE ERROR on updateWebWallet';
211
+ }
212
+ $msg=Mage::helper('payline')->__('Error while updating wallet');
213
+ Mage::helper('payline/logger')->log($msgLog);
214
+ Mage::getSingleton('customer/session')->addError($msg);
215
+ $this->_redirect('customer/account');
216
+ return;
217
+ }
218
+ $urlPayline=$res['redirectURL'];
219
+
220
+ $this->_initLayoutMessages('customer/session');
221
+ $this->_initLayoutMessages('core/session');
222
+
223
+ if (Mage::getStoreConfig('payment/PaylineWALLET/update_personal_details')){
224
+ $iframeClass='iframe-update-wallet iframe-with-perso-data';
225
+ }else{
226
+ $iframeClass='iframe-update-wallet';
227
+ }
228
+ $this->getLayout()->getBlock('payline-wallet-update-iframe')->setIframeClassName($iframeClass);
229
+ $this->getLayout()->getBlock('payline-wallet-update-iframe')->setIframeSrc($urlPayline);
230
+
231
+ $this->renderLayout();
232
+ }
233
+ }
app/code/community/Monext/Payline/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Monext_Payline>
5
- <version>1.5.7</version>
6
  </Monext_Payline>
7
  </modules>
8
  <global>
@@ -11,6 +11,7 @@
11
  <class>Monext_Payline_Block</class>
12
  </payline>
13
  <adminhtml>
 
14
  <rewrite>
15
  <sales_order_creditmemo_create_items>Monext_Payline_Block_Adminhtml_Sales_Order_Creditmemo_Create_Items</sales_order_creditmemo_create_items>
16
  </rewrite>
@@ -29,10 +30,10 @@
29
 
30
  <resources>
31
  <payline_setup>
32
- <!-- <setup>
33
  <module>Monext_Payline</module>
34
  <class>Monext_Payline_Model_Resource_Eav_Mysql4_Setup</class>
35
- </setup>-->
36
  <connection>
37
  <use>core_setup</use>
38
  </connection>
@@ -51,13 +52,13 @@
51
  </global>
52
  <frontend>
53
  <routers>
54
- <Monext_Payline_Redirect>
55
  <use>standard</use>
56
  <args>
57
  <module>Monext_Payline</module>
58
  <frontName>payline</frontName>
59
  </args>
60
- </Monext_Payline_Redirect>
61
  </routers>
62
  <translate>
63
  <modules>
@@ -68,13 +69,13 @@
68
  </Monext_Payline>
69
  </modules>
70
  </translate>
71
- <!-- <layout>
72
  <updates>
73
  <payline module="Monext_Payline">
74
  <file>payline.xml</file>
75
  </payline>
76
  </updates>
77
- </layout>-->
78
  </frontend>
79
  <adminhtml>
80
  <translate>
@@ -88,17 +89,51 @@
88
  </translate>
89
  </adminhtml>
90
  <default>
91
- <!-- TODO : adding all default configuration values -->
92
  <payment>
93
  <PaylineCPT>
94
  <model>payline/cpt</model>
 
 
 
 
 
 
 
95
  </PaylineCPT>
96
  <PaylineNX>
97
  <model>payline/nx</model>
 
 
 
 
 
98
  </PaylineNX>
99
  <PaylineDIRECT>
100
  <model>payline/direct</model>
 
 
 
 
 
 
101
  </PaylineDIRECT>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  </payment>
103
  </default>
104
  </config>
2
  <config>
3
  <modules>
4
  <Monext_Payline>
5
+ <version>1.6.0</version>
6
  </Monext_Payline>
7
  </modules>
8
  <global>
11
  <class>Monext_Payline_Block</class>
12
  </payline>
13
  <adminhtml>
14
+ <!-- Needed for Magento Enterprise 1.9 -->
15
  <rewrite>
16
  <sales_order_creditmemo_create_items>Monext_Payline_Block_Adminhtml_Sales_Order_Creditmemo_Create_Items</sales_order_creditmemo_create_items>
17
  </rewrite>
30
 
31
  <resources>
32
  <payline_setup>
33
+ <setup>
34
  <module>Monext_Payline</module>
35
  <class>Monext_Payline_Model_Resource_Eav_Mysql4_Setup</class>
36
+ </setup>
37
  <connection>
38
  <use>core_setup</use>
39
  </connection>
52
  </global>
53
  <frontend>
54
  <routers>
55
+ <payline>
56
  <use>standard</use>
57
  <args>
58
  <module>Monext_Payline</module>
59
  <frontName>payline</frontName>
60
  </args>
61
+ </payline>
62
  </routers>
63
  <translate>
64
  <modules>
69
  </Monext_Payline>
70
  </modules>
71
  </translate>
72
+ <layout>
73
  <updates>
74
  <payline module="Monext_Payline">
75
  <file>payline.xml</file>
76
  </payline>
77
  </updates>
78
+ </layout>
79
  </frontend>
80
  <adminhtml>
81
  <translate>
89
  </translate>
90
  </adminhtml>
91
  <default>
 
92
  <payment>
93
  <PaylineCPT>
94
  <model>payline/cpt</model>
95
+ <security_mode>SSL</security_mode>
96
+ <failed_order_status>holded</failed_order_status>
97
+ <canceled_order_status>canceled</canceled_order_status>
98
+ <new_order_status>processing</new_order_status>
99
+ <init_order_status>pending</init_order_status>
100
+ <!-- Auth+Capture, 100 is capture only -->
101
+ <payline_payment_action>101</payline_payment_action>
102
  </PaylineCPT>
103
  <PaylineNX>
104
  <model>payline/nx</model>
105
+ <security_mode>SSL</security_mode>
106
+ <failed_order_status>holded</failed_order_status>
107
+ <canceled_order_status>canceled</canceled_order_status>
108
+ <new_order_status>processing</new_order_status>
109
+ <init_order_status>pending</init_order_status>
110
  </PaylineNX>
111
  <PaylineDIRECT>
112
  <model>payline/direct</model>
113
+ <failed_order_status>holded</failed_order_status>
114
+ <canceled_order_status>canceled</canceled_order_status>
115
+ <new_order_status>processing</new_order_status>
116
+ <init_order_status>pending</init_order_status>
117
+ <!-- Auth+Capture, 100 is capture only -->
118
+ <payline_payment_action>101</payline_payment_action>
119
  </PaylineDIRECT>
120
+ <PaylineWALLET>
121
+ <model>payline/wallet</model>
122
+ <security_mode>SSL</security_mode>
123
+ <payline_register-oneclick_customeraccount>payline_register-oneclick_customeraccount</payline_register-oneclick_customeraccount>
124
+ <payline_register-oneclick_catalog>payline_register-oneclick_catalog</payline_register-oneclick_catalog>
125
+ <payline_display_register-oneclick_catalog>1</payline_display_register-oneclick_catalog>
126
+ <update_payment_details>1</update_payment_details>
127
+ <update_personal_details>0</update_personal_details>
128
+ <send_wallet_id>1</send_wallet_id>
129
+ <automate_subscription>1</automate_subscription>
130
+ <failed_order_status>holded</failed_order_status>
131
+ <canceled_order_status>canceled</canceled_order_status>
132
+ <new_order_status>processing</new_order_status>
133
+ <init_order_status>pending</init_order_status>
134
+ <!-- Auth+Capture, 100 is capture only -->
135
+ <payline_payment_action>101</payline_payment_action>
136
+ </PaylineWALLET>
137
  </payment>
138
  </default>
139
  </config>
app/code/community/Monext/Payline/etc/system.xml CHANGED
@@ -91,24 +91,27 @@
91
  <show_in_website>1</show_in_website>
92
  <show_in_store>1</show_in_store>
93
  </contract_number>
94
- <contract_number_list translate="label">
95
  <label>Contract number list</label>
 
96
  <frontend_type>text</frontend_type>
97
  <sort_order>13</sort_order>
98
  <show_in_default>1</show_in_default>
99
  <show_in_website>1</show_in_website>
100
  <show_in_store>1</show_in_store>
101
  </contract_number_list>
102
- <template_url translate="label">
103
  <label>Template URL</label>
 
104
  <frontend_type>text</frontend_type>
105
  <sort_order>23</sort_order>
106
  <show_in_default>1</show_in_default>
107
  <show_in_website>1</show_in_website>
108
  <show_in_store>1</show_in_store>
109
  </template_url>
110
- <custom_payment_page_code translate="label">
111
  <label>Custom payment page code</label>
 
112
  <frontend_type>text</frontend_type>
113
  <sort_order>24</sort_order>
114
  <show_in_default>1</show_in_default>
@@ -281,24 +284,27 @@
281
  <show_in_website>1</show_in_website>
282
  <show_in_store>1</show_in_store>
283
  </contract_number>
284
- <contract_number_list translate="label">
285
  <label>Contract number list</label>
 
286
  <frontend_type>text</frontend_type>
287
  <sort_order>13</sort_order>
288
  <show_in_default>1</show_in_default>
289
  <show_in_website>1</show_in_website>
290
  <show_in_store>1</show_in_store>
291
  </contract_number_list>
292
- <template_url translate="label">
293
  <label>Template URL</label>
 
294
  <frontend_type>text</frontend_type>
295
  <sort_order>23</sort_order>
296
  <show_in_default>1</show_in_default>
297
  <show_in_website>1</show_in_website>
298
  <show_in_store>1</show_in_store>
299
  </template_url>
300
- <custom_payment_page_code translate="label">
301
  <label>Custom payment page code</label>
 
302
  <frontend_type>text</frontend_type>
303
  <sort_order>24</sort_order>
304
  <show_in_default>1</show_in_default>
@@ -538,6 +544,272 @@
538
  </production>
539
  </fields>
540
  </PaylineDIRECT>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  </groups>
542
  </payment>
543
  </sections>
91
  <show_in_website>1</show_in_website>
92
  <show_in_store>1</show_in_store>
93
  </contract_number>
94
+ <contract_number_list translate="label comment">
95
  <label>Contract number list</label>
96
+ <comment>Each contract number has to be separated by ;</comment>
97
  <frontend_type>text</frontend_type>
98
  <sort_order>13</sort_order>
99
  <show_in_default>1</show_in_default>
100
  <show_in_website>1</show_in_website>
101
  <show_in_store>1</show_in_store>
102
  </contract_number_list>
103
+ <template_url translate="label comment">
104
  <label>Template URL</label>
105
+ <comment>URL to a custom HTML template. Refer to Payline documentation</comment>
106
  <frontend_type>text</frontend_type>
107
  <sort_order>23</sort_order>
108
  <show_in_default>1</show_in_default>
109
  <show_in_website>1</show_in_website>
110
  <show_in_store>1</show_in_store>
111
  </template_url>
112
+ <custom_payment_page_code translate="label comment">
113
  <label>Custom payment page code</label>
114
+ <comment>ID of a style defined in Payline administration tool.</comment>
115
  <frontend_type>text</frontend_type>
116
  <sort_order>24</sort_order>
117
  <show_in_default>1</show_in_default>
284
  <show_in_website>1</show_in_website>
285
  <show_in_store>1</show_in_store>
286
  </contract_number>
287
+ <contract_number_list translate="label comment">
288
  <label>Contract number list</label>
289
+ <comment>Each contract number has to be separated by ;</comment>
290
  <frontend_type>text</frontend_type>
291
  <sort_order>13</sort_order>
292
  <show_in_default>1</show_in_default>
293
  <show_in_website>1</show_in_website>
294
  <show_in_store>1</show_in_store>
295
  </contract_number_list>
296
+ <template_url translate="label comment">
297
  <label>Template URL</label>
298
+ <comment>URL to a custom HTML template. Refer to Payline documentation</comment>
299
  <frontend_type>text</frontend_type>
300
  <sort_order>23</sort_order>
301
  <show_in_default>1</show_in_default>
302
  <show_in_website>1</show_in_website>
303
  <show_in_store>1</show_in_store>
304
  </template_url>
305
+ <custom_payment_page_code translate="label comment">
306
  <label>Custom payment page code</label>
307
+ <comment>ID of a style defined in Payline administration tool.</comment>
308
  <frontend_type>text</frontend_type>
309
  <sort_order>24</sort_order>
310
  <show_in_default>1</show_in_default>
544
  </production>
545
  </fields>
546
  </PaylineDIRECT>
547
+
548
+ <PaylineWALLET translate="label">
549
+ <label>Payline - 1 clic payment</label>
550
+ <sort_order>210</sort_order>
551
+ <show_in_default>1</show_in_default>
552
+ <show_in_website>1</show_in_website>
553
+ <show_in_store>1</show_in_store>
554
+ <fields>
555
+ <active translate="label">
556
+ <label>Enabled</label>
557
+ <frontend_type>select</frontend_type>
558
+ <source_model>adminhtml/system_config_source_yesno</source_model>
559
+ <sort_order>1</sort_order>
560
+ <show_in_default>1</show_in_default>
561
+ <show_in_website>1</show_in_website>
562
+ <show_in_store>1</show_in_store>
563
+ </active>
564
+ <init_order_status translate="label">
565
+ <label>Initial order status</label>
566
+ <comment></comment>
567
+ <frontend_type>select</frontend_type>
568
+ <source_model>adminhtml/system_config_source_order_status_newprocessing</source_model>
569
+ <sort_order>40</sort_order>
570
+ <show_in_default>1</show_in_default>
571
+ <show_in_website>1</show_in_website>
572
+ <show_in_store>1</show_in_store>
573
+ </init_order_status>
574
+ <new_order_status translate="label">
575
+ <label>Order status when payment accepted by Payline</label>
576
+ <comment></comment>
577
+ <frontend_type>select</frontend_type>
578
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
579
+ <sort_order>41</sort_order>
580
+ <show_in_default>1</show_in_default>
581
+ <show_in_website>1</show_in_website>
582
+ <show_in_store>1</show_in_store>
583
+ </new_order_status>
584
+ <canceled_order_status translate="label">
585
+ <label>Order status when payment canceled by customer</label>
586
+ <comment></comment>
587
+ <frontend_type>select</frontend_type>
588
+ <source_model>payline/datasource_status_canceled</source_model>
589
+ <sort_order>42</sort_order>
590
+ <show_in_default>1</show_in_default>
591
+ <show_in_website>1</show_in_website>
592
+ <show_in_store>1</show_in_store>
593
+ </canceled_order_status>
594
+ <failed_order_status translate="label">
595
+ <label>Order status when payment refused by Payline</label>
596
+ <comment></comment>
597
+ <frontend_type>select</frontend_type>
598
+ <source_model>payline/datasource_status_canceled</source_model>
599
+ <sort_order>43</sort_order>
600
+ <show_in_default>1</show_in_default>
601
+ <show_in_website>1</show_in_website>
602
+ <show_in_store>1</show_in_store>
603
+ </failed_order_status>
604
+ <title translate="label">
605
+ <label>Title</label>
606
+ <frontend_type>text</frontend_type>
607
+ <sort_order>2</sort_order>
608
+ <show_in_default>1</show_in_default>
609
+ <show_in_website>1</show_in_website>
610
+ <show_in_store>1</show_in_store>
611
+ </title>
612
+ <automate_subscription translate="label comment">
613
+ <label>Automate subscription</label>
614
+ <comment>A customer wallet will be created with the first payment using Payline</comment>
615
+ <frontend_type>select</frontend_type>
616
+ <source_model>adminhtml/system_config_source_yesno</source_model>
617
+ <sort_order>3</sort_order>
618
+ <show_in_default>1</show_in_default>
619
+ <show_in_website>1</show_in_website>
620
+ <show_in_store>1</show_in_store>
621
+ </automate_subscription>
622
+ <send_wallet_id translate="label comment">
623
+ <label>Send wallet id for all Payline payment methods</label>
624
+ <comment>If wallet id is provided, wallet payment will be available during web payment</comment>
625
+ <frontend_type>select</frontend_type>
626
+ <source_model>adminhtml/system_config_source_yesno</source_model>
627
+ <sort_order>4</sort_order>
628
+ <show_in_default>1</show_in_default>
629
+ <show_in_website>1</show_in_website>
630
+ <show_in_store>1</show_in_store>
631
+ </send_wallet_id>
632
+ <merchant_id translate="label">
633
+ <label>Merchant ID</label>
634
+ <frontend_type>text</frontend_type>
635
+ <sort_order>10</sort_order>
636
+ <show_in_default>1</show_in_default>
637
+ <show_in_website>1</show_in_website>
638
+ <show_in_store>1</show_in_store>
639
+ </merchant_id>
640
+ <access_key translate="label">
641
+ <label>Access key</label>
642
+ <frontend_type>text</frontend_type>
643
+ <sort_order>11</sort_order>
644
+ <show_in_default>1</show_in_default>
645
+ <show_in_website>1</show_in_website>
646
+ <show_in_store>1</show_in_store>
647
+ </access_key>
648
+ <contract_number translate="label">
649
+ <label>Contract number</label>
650
+ <frontend_type>text</frontend_type>
651
+ <sort_order>12</sort_order>
652
+ <show_in_default>1</show_in_default>
653
+ <show_in_website>1</show_in_website>
654
+ <show_in_store>1</show_in_store>
655
+ </contract_number>
656
+ <contract_number_CB translate="label">
657
+ <label>Contract number CB</label>
658
+ <frontend_type>text</frontend_type>
659
+ <sort_order>13</sort_order>
660
+ <show_in_default>1</show_in_default>
661
+ <show_in_website>1</show_in_website>
662
+ <show_in_store>1</show_in_store>
663
+ </contract_number_CB>
664
+ <contract_number_AMEX translate="label">
665
+ <label>Contract number American Express</label>
666
+ <frontend_type>text</frontend_type>
667
+ <sort_order>14</sort_order>
668
+ <show_in_default>1</show_in_default>
669
+ <show_in_website>1</show_in_website>
670
+ <show_in_store>1</show_in_store>
671
+ </contract_number_AMEX>
672
+ <template_url translate="label comment">
673
+ <label>Template URL</label>
674
+ <comment>URL to a custom HTML template. Refer to Payline documentation</comment>
675
+ <frontend_type>text</frontend_type>
676
+ <sort_order>23</sort_order>
677
+ <show_in_default>1</show_in_default>
678
+ <show_in_website>1</show_in_website>
679
+ <show_in_store>1</show_in_store>
680
+ </template_url>
681
+ <custom_payment_page_code translate="label comment">
682
+ <label>Custom payment page code</label>
683
+ <comment>ID of a style defined in Payline administration tool.</comment>
684
+ <frontend_type>text</frontend_type>
685
+ <sort_order>24</sort_order>
686
+ <show_in_default>1</show_in_default>
687
+ <show_in_website>1</show_in_website>
688
+ <show_in_store>1</show_in_store>
689
+ </custom_payment_page_code>
690
+ <proxy_host translate="label">
691
+ <label>Proxy host</label>
692
+ <frontend_type>text</frontend_type>
693
+ <sort_order>30</sort_order>
694
+ <show_in_default>1</show_in_default>
695
+ <show_in_website>1</show_in_website>
696
+ <show_in_store>1</show_in_store>
697
+ </proxy_host>
698
+ <proxy_port translate="label">
699
+ <label>Proxy port</label>
700
+ <frontend_type>text</frontend_type>
701
+ <sort_order>31</sort_order>
702
+ <show_in_default>1</show_in_default>
703
+ <show_in_website>1</show_in_website>
704
+ <show_in_store>1</show_in_store>
705
+ </proxy_port>
706
+ <proxy_login translate="label">
707
+ <label>Proxy login</label>
708
+ <frontend_type>text</frontend_type>
709
+ <sort_order>32</sort_order>
710
+ <show_in_default>1</show_in_default>
711
+ <show_in_website>1</show_in_website>
712
+ <show_in_store>1</show_in_store>
713
+ </proxy_login>
714
+ <proxy_password translate="label">
715
+ <label>Proxy password</label>
716
+ <frontend_type>text</frontend_type>
717
+ <sort_order>33</sort_order>
718
+ <show_in_default>1</show_in_default>
719
+ <show_in_website>1</show_in_website>
720
+ <show_in_store>1</show_in_store>
721
+ </proxy_password>
722
+ <payline_payment_action translate="label">
723
+ <label>Payment action</label>
724
+ <frontend_type>select</frontend_type>
725
+ <source_model>payline/datasource_paymentactions</source_model>
726
+ <sort_order>51</sort_order>
727
+ <show_in_default>1</show_in_default>
728
+ <show_in_website>1</show_in_website>
729
+ <show_in_store>1</show_in_store>
730
+ </payline_payment_action>
731
+ <security_mode translate="label">
732
+ <label>Security mode</label>
733
+ <frontend_type>select</frontend_type>
734
+ <source_model>payline/datasource_securitymodes</source_model>
735
+ <sort_order>54</sort_order>
736
+ <show_in_default>1</show_in_default>
737
+ <show_in_website>1</show_in_website>
738
+ <show_in_store>1</show_in_store>
739
+ </security_mode>
740
+ <language translate="label">
741
+ <label>Language</label>
742
+ <frontend_type>select</frontend_type>
743
+ <source_model>payline/datasource_languages</source_model>
744
+ <sort_order>55</sort_order>
745
+ <show_in_default>1</show_in_default>
746
+ <show_in_website>1</show_in_website>
747
+ <show_in_store>1</show_in_store>
748
+ </language>
749
+ <production translate="label">
750
+ <label>Production</label>
751
+ <frontend_type>select</frontend_type>
752
+ <source_model>adminhtml/system_config_source_yesno</source_model>
753
+ <sort_order>34</sort_order>
754
+ <show_in_default>1</show_in_default>
755
+ <show_in_website>1</show_in_website>
756
+ <show_in_store>1</show_in_store>
757
+ </production>
758
+ <payline_register-oneclick_customeraccount translate="label">
759
+ <label>registration CMS block id in customer account</label>
760
+ <frontend_type>text</frontend_type>
761
+ <sort_order>36</sort_order>
762
+ <show_in_default>1</show_in_default>
763
+ <show_in_website>1</show_in_website>
764
+ <show_in_store>1</show_in_store>
765
+ </payline_register-oneclick_customeraccount>
766
+ <payline_display_register-oneclick_catalog translate="label">
767
+ <label>Show a custom text (CMS block) about registration to wallet in catalog</label>
768
+ <frontend_type>select</frontend_type>
769
+ <source_model>adminhtml/system_config_source_yesno</source_model>
770
+ <sort_order>37</sort_order>
771
+ <show_in_default>1</show_in_default>
772
+ <show_in_website>1</show_in_website>
773
+ <show_in_store>1</show_in_store>
774
+ </payline_display_register-oneclick_catalog>
775
+ <payline_register-oneclick_catalog translate="label">
776
+ <label>registration CMS block id in catalog</label>
777
+ <frontend_type>text</frontend_type>
778
+ <sort_order>38</sort_order>
779
+ <show_in_default>1</show_in_default>
780
+ <show_in_website>1</show_in_website>
781
+ <show_in_store>1</show_in_store>
782
+ </payline_register-oneclick_catalog>
783
+ <update_personal_details translate="label">
784
+ <label>Allow user to update his personal details</label>
785
+ <source_model>adminhtml/system_config_source_yesno</source_model>
786
+ <frontend_type>select</frontend_type>
787
+ <sort_order>52</sort_order>
788
+ <show_in_default>1</show_in_default>
789
+ <show_in_website>1</show_in_website>
790
+ <show_in_store>1</show_in_store>
791
+ </update_personal_details>
792
+ <update_payment_details translate="label">
793
+ <label>Allow user to update his payment details</label>
794
+ <source_model>adminhtml/system_config_source_yesno</source_model>
795
+ <frontend_type>select</frontend_type>
796
+ <sort_order>53</sort_order>
797
+ <show_in_default>1</show_in_default>
798
+ <show_in_website>1</show_in_website>
799
+ <show_in_store>1</show_in_store>
800
+ </update_payment_details>
801
+ <default_shipping_method translate="label comment">
802
+ <label>Default shipping method</label>
803
+ <comment>Shipping method to use with one click checkout. Flatrate, freeshipping and Tablerates are available</comment>
804
+ <source_model>payline/datasource_shippingmethods</source_model>
805
+ <frontend_type>select</frontend_type>
806
+ <sort_order>54</sort_order>
807
+ <show_in_default>1</show_in_default>
808
+ <show_in_website>1</show_in_website>
809
+ <show_in_store>1</show_in_store>
810
+ </default_shipping_method>
811
+ </fields>
812
+ </PaylineWALLET>
813
  </groups>
814
  </payment>
815
  </sections>
app/code/community/Monext/Payline/sql/payline_setup/mysql4-install-1.6.0.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* @var $this Monext_Payline_Model_Resource_Eav_Mysql4_Setup */
3
+ $installer=$this;
4
+ $installer->startSetup();
5
+ //Create the wallet id if doesn't exists
6
+ $attribute = $installer->getAttribute('customer', 'wallet_id');
7
+ if (empty($attribute['attribute_id'])) {
8
+
9
+ $installer->addAttribute('customer', 'wallet_id',
10
+ array(
11
+ 'type' => 'varchar',
12
+ 'backend' => '',
13
+ 'frontend' => '',
14
+ 'label' => 'Payline User ID',
15
+ 'input' => 'text',
16
+ 'class' => '',
17
+ 'source' => '',
18
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
19
+ 'visible' => false,
20
+ 'required' => false,
21
+ 'user_defined' => false,
22
+ 'default' => '',
23
+ 'searchable' => false,
24
+ 'filterable' => false,
25
+ 'comparable' => false,
26
+ 'visible_on_front' => false,
27
+ 'visible_in_advanced_search' => false,
28
+ 'unique' => true,
29
+ 'position' => 1
30
+ )
31
+ );
32
+ }
33
+
34
+ //Create default static CMS blocks for registration to one click payment
35
+ $connection=$installer->getConnection();
36
+ if (!$connection->fetchOne("SELECT block_id FROM ".$installer->getTable('cms_block')." WHERE `identifier`='payline_register-oneclick_catalog'")) {
37
+ $connection->insert($installer->getTable('cms/block'), array(
38
+ 'title' => 'Register to one click checkout',
39
+ 'identifier' => 'payline_register-oneclick_catalog',
40
+ 'content' => "<p>Save time by registering now to our one click checkout service</p>",
41
+ 'creation_time' => now(),
42
+ 'update_time' => now(),
43
+ 'is_active' => 1,
44
+ ));
45
+
46
+ $connection->insert($installer->getTable('cms/block_store'), array(
47
+ 'block_id' => $connection->lastInsertId(),
48
+ 'store_id' => 0
49
+ ));
50
+ }
51
+ if (!$connection->fetchOne("SELECT block_id FROM ".$installer->getTable('cms_block')." WHERE `identifier`='payline_register-oneclick_customeraccount'")) {
52
+ $connection->insert($installer->getTable('cms/block'), array(
53
+ 'title' => 'Register to one click checkout',
54
+ 'identifier' => 'payline_register-oneclick_customeraccount',
55
+ 'content' => "<p>Save time by registering now to our one click checkout service</p>",
56
+ 'creation_time' => now(),
57
+ 'update_time' => now(),
58
+ 'is_active' => 1,
59
+ ));
60
+
61
+ $connection->insert($installer->getTable('cms/block_store'), array(
62
+ 'block_id' => $connection->lastInsertId(),
63
+ 'store_id' => 0
64
+ ));
65
+ }
66
+ $installer->endSetup();
app/design/frontend/default/default/layout/payline.xml ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="right">
5
+ <block type="payline/wallet_sidebar" ifconfig="payment/PaylineWALLET/active" name="left.payline-wallet-sidebar" template="payline/wallet/sidebar.phtml" after="cart_sidebar"/>
6
+ </reference>
7
+ <reference name="head">
8
+ <action method="addCss"><stylesheet>css/payline.css</stylesheet></action>
9
+ </reference>
10
+ </default>
11
+
12
+ <catalog_product_view>
13
+ <reference name="right">
14
+ <block type="payline/logo" name="right.payline-logo" template="payline/logo.phtml"/>
15
+ </reference>
16
+ </catalog_product_view>
17
+ <catalog_category_default>
18
+ <reference name="right">
19
+ <block type="payline/logo" name="right.payline-logo" template="payline/logo.phtml"/>
20
+ </reference>
21
+ </catalog_category_default>
22
+ <catalog_category_layered>
23
+ <reference name="right">
24
+ <block type="payline/logo" name="right.payline-logo" template="payline/logo.phtml"/>
25
+ </reference>
26
+ </catalog_category_layered>
27
+ <cms_index_index>
28
+ <reference name="right">
29
+ <block type="payline/logo" name="right.payline-logo" template="payline/logo.phtml"/>
30
+ </reference>
31
+ </cms_index_index>
32
+
33
+ <customer_account>
34
+ <reference name="customer_account_navigation">
35
+ <action method="addLink" translate="label" module="payline" ifconfig="payment/PaylineWALLET/active"><name>payline</name><path>payline/wallet/manage</path><label>Wallet management</label></action>
36
+ </reference>
37
+ <reference name="left">
38
+ <block type="payline/wallet_sidebar" name="left.payline-wallet-sidebar" template="payline/wallet/sidebar.phtml" after="cart_sidebar" ifconfig="payment/PaylineWALLET/active"/>
39
+ </reference>
40
+ </customer_account>
41
+
42
+ <checkout_cart_index>
43
+ <reference name="checkout.cart.methods">
44
+ <block type="payline/wallet_checkoutbtn" after="checkout.cart.methods.onepage" name="payline-wallet.checkoutbtn" ifconfig="payment/PaylineWALLET/active"/>
45
+ </reference>
46
+ <reference name="checkout.cart.top_methods">
47
+ <block type="payline/wallet_checkoutbtn" after="checkout.cart.methods.onepage" name="payline-wallet.checkoutbtn" ifconfig="payment/PaylineWALLET/active"/>
48
+ </reference>
49
+ </checkout_cart_index>
50
+
51
+ <payline_wallet_manage>
52
+ <update handle="customer_account"/>
53
+ <reference name="content">
54
+ <block type="core/template" name="payline-wallet-manage" template="payline/wallet/manage.phtml">
55
+ <block type="payline/wallet_details" name="payline-wallet-details" />
56
+ </block>
57
+ </reference>
58
+ </payline_wallet_manage>
59
+
60
+ <payline_wallet_subscribe>
61
+ <update handle="customer_account"/>
62
+ <reference name="root">
63
+ <action method="setHeaderTitle" translate="title"><title>Subscribe to wallet</title></action>
64
+ </reference>
65
+ <reference name="content">
66
+ <block type="core/template" name="payline-wallet-subscribe" template="payline/wallet/subscribe.phtml">
67
+ <block type="cms/block" name="payline-wallet-subscribe-cmsblock" ifconfig="payment/PaylineWALLET/payline_register-oneclick_customeraccount" >
68
+ <!-- <action method="setBlockId"><id>payline_register-oneclick_customeraccount</id></action>-->
69
+ </block>
70
+ <block type="core/template" name="payline-wallet-subscribe-iframe" template="payline/iframe.phtml" />
71
+ </block>
72
+ </reference>
73
+ </payline_wallet_subscribe>
74
+
75
+ <payline_unloggedwallet_subscribereturn>
76
+ <reference name="root">
77
+ <action method="setTemplate"><template>payline/page/empty.phtml</template></action>
78
+ </reference>
79
+ <reference name="content">
80
+ <block name="payline-iframe-leaver" type="core/template" template="payline/iframeleaver.phtml" />
81
+ </reference>
82
+ </payline_unloggedwallet_subscribereturn>
83
+ <payline_unloggedwallet_subscribecancel>
84
+ <reference name="root">
85
+ <action method="setTemplate"><template>payline/page/empty.phtml</template></action>
86
+ </reference>
87
+ <reference name="content">
88
+ <block name="payline-iframe-leaver" type="core/template" template="payline/iframeleaver.phtml" />
89
+ </reference>
90
+ </payline_unloggedwallet_subscribecancel>
91
+
92
+
93
+ <payline_wallet_update>
94
+ <update handle="customer_account"/>
95
+ <reference name="root">
96
+ <action method="setHeaderTitle" translate="title"><title>Update wallet</title></action>
97
+ </reference>
98
+ <reference name="content">
99
+ <block type="core/template" name="payline-wallet-update" template="payline/wallet/update.phtml">
100
+ <block type="core/template" name="payline-wallet-update-iframe" template="payline/iframe.phtml" />
101
+ </block>
102
+ </reference>
103
+ </payline_wallet_update>
104
+
105
+ <payline_unloggedwallet_updatereturn>
106
+ <reference name="root">
107
+ <action method="setTemplate"><template>payline/page/empty.phtml</template></action>
108
+ </reference>
109
+ <reference name="content">
110
+ <block name="payline-iframe-leaver" type="core/template" template="payline/iframeleaver.phtml" />
111
+ </reference>
112
+ </payline_unloggedwallet_updatereturn>
113
+ <payline_unloggedwallet_updatecancel>
114
+ <reference name="root">
115
+ <action method="setTemplate"><template>payline/page/empty.phtml</template></action>
116
+ </reference>
117
+ <reference name="content">
118
+ <block name="payline-iframe-leaver" type="core/template" template="payline/iframeleaver.phtml" />
119
+ </reference>
120
+ </payline_unloggedwallet_updatecancel>
121
+
122
+ <payline_checkoutonepage_index>
123
+ <update handle="checkout_onepage_index" />
124
+ <reference name="content">
125
+ <block type="core/template" name="payline-checkoutonepage" template="payline/checkout/onepage.phtml" />
126
+ </reference>
127
+ </payline_checkoutonepage_index>
128
+ </layout>
app/design/frontend/default/default/template/payline/checkout/onepage.phtml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Monext_Payline_Block_Checkout_Onepage */?>
2
+ <p id="wait-txt"><?php echo $this->htmlEscape($this->__('Please wait a few seconds, we\'re processing your order...'));?>
3
+ <script type="text/javascript">
4
+ //<![CDATA[
5
+ //ActionPile contains the remaining Ajax calls to validate each steps
6
+ var actionPile=[
7
+ {
8
+ 'url':"<?php echo $this->getUrl('checkout/onepage/saveBilling');?>",
9
+ 'parameters':{"billing[country_id]":'US',"billing_address_id":<?php echo Mage::getSingleton('checkout/type_onepage')->getQuote()->getBillingAddress()->getId();?>}
10
+ },
11
+ {
12
+ 'url':"<?php echo $this->getUrl('checkout/onepage/saveShipping');?>",
13
+ 'parameters':{"shipping[country_id]":'US',"shipping_address_id":<?php echo Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getId();?>}
14
+ },
15
+ ];
16
+
17
+ <?php
18
+ $shippingMethod=Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getShippingMethod();
19
+ if (!empty($shippingMethod)):?>
20
+
21
+ actionPile.push({
22
+ 'url':"<?php echo $this->getUrl('checkout/onepage/saveShippingMethod');?>",
23
+ 'parameters':{"shipping_method":"<?php echo Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getShippingMethod();?>"}
24
+ });
25
+ actionPile.push({
26
+ 'url':"<?php echo $this->getUrl('checkout/onepage/savePayment');?>",
27
+ 'parameters':{"payment[method]":"<?php echo Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethod();?>"}
28
+ });
29
+ <?php endif;?>
30
+
31
+ /**
32
+ * Show or hide elem as a popin
33
+ */
34
+ function showPopin(elem,show){
35
+ if (show){
36
+ //If the elem is already shown (having the popin class), we should not recalculate its position
37
+ if (!elem.hasClassName('popin')){
38
+ var screenHeight=document.body.clientHeight;
39
+ var screenWidth=document.body.clientWidth;
40
+ var elemDimensions=elem.getDimensions();
41
+ var topPos=screenHeight/2 - elemDimensions.height/2;
42
+ var leftPos=screenWidth/2 - elemDimensions.width/2;
43
+ elem.style.top=topPos+'px';
44
+ elem.style.left=leftPos+'px';
45
+ elem.addClassName('popin');
46
+ }
47
+ }else{
48
+ elem.removeClassName('popin');
49
+ }
50
+ }
51
+ function saveStepFromActionPile(){
52
+ if (actionPile.length>0){
53
+ showPopin($('wait-txt'),true);
54
+ var action=actionPile.shift();
55
+ var request = new Ajax.Request(
56
+ action.url,
57
+ {
58
+ method:'post',
59
+ onComplete:null,
60
+ onSuccess: initBlockHtml,
61
+ onFailure: checkout.ajaxFailure.bind(checkout),
62
+ parameters:action.parameters
63
+ }
64
+ );
65
+ }else{
66
+ checkout.reloadProgressBlock();
67
+ showPopin($('wait-txt'), false);
68
+ //checkout.gotoSection('review');
69
+ }
70
+ }
71
+
72
+ function initBlockHtml(transport){
73
+ response='';
74
+ if (transport && transport.responseText){
75
+ try{
76
+ response = eval('(' + transport.responseText + ')');
77
+ }
78
+ catch (e) {
79
+ response = {};
80
+ }
81
+ }
82
+ if (response.update_section) {
83
+ $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
84
+ }
85
+ if (response.allow_sections) {
86
+ response.allow_sections.each(function(e){
87
+ $('opc-'+e).addClassName('allow');
88
+ });
89
+ }
90
+
91
+ if (response.goto_section) {
92
+ //this.reloadProgressBlock();
93
+ checkout.gotoSection(response.goto_section);
94
+ }
95
+
96
+ saveStepFromActionPile();
97
+ }
98
+
99
+ saveStepFromActionPile();
100
+ //]]>
101
+ </script>
app/design/frontend/default/default/template/payline/checkout/onepage/shipping-method.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form id="co-shipping-method-form" action="">
2
+ <div id="checkout-shipping-method-load">
3
+ <?php echo $this->getChildHtml('available') ?>
4
+ </div>
5
+ <script type="text/javascript">
6
+ //<![CDATA[
7
+ var shippingMethod = new ShippingMethod('co-shipping-method-form', "<?php echo $this->getUrl('payline/checkoutonepage/saveShippingMethod') ?>");
8
+ function saveShippingAndPayment(){
9
+ //shippingMethod.save();
10
+ if (shippingMethod.validate()) {
11
+ actionPile.push({
12
+ 'url':"<?php echo $this->getUrl('checkout/onepage/saveShippingMethod');?>",
13
+ 'parameters':Form.serialize(shippingMethod.form)
14
+ });
15
+ actionPile.push({
16
+ 'url':"<?php echo $this->getUrl('checkout/onepage/savePayment');?>",
17
+ 'parameters':{"payment[method]":"<?php echo $this->getCheckout()->getQuote()->getPayment()->getMethod();?>"}
18
+ });
19
+ saveStepFromActionPile();
20
+ }
21
+ }
22
+ //]]>
23
+ </script>
24
+ <div id="onepage-checkout-shipping-method-additional-load">
25
+ <?php echo $this->getChildHtml('additional') ?>
26
+ </div>
27
+ <div class="buttons-set" id="shipping-method-buttons-container">
28
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
29
+ <button id="btn-submit-shipping-method" type="button" class="button" onclick="saveShippingAndPayment()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
30
+ <span id="shipping-method-please-wait" class="please-wait" style="display:none;">
31
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
32
+ </span>
33
+ </div>
34
+ </form>
35
+ <script type="text/javascript">
36
+ //<[CDATA[
37
+
38
+ //]]>
39
+ </script>
app/design/frontend/default/default/template/payline/iframe.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <iframe allowtransparency="true"
2
+ frameborder="0"
3
+ scrolling="no"
4
+ src="<?php echo $this->htmlEscape($this->getIframeSrc());?>"
5
+ class="<?php echo $this->htmlEscape($this->getIframeClassName());?>"
6
+ ></iframe>
app/design/frontend/default/default/template/payline/iframeleaver.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ //<![CDATA[
3
+ if (top.location != location) {
4
+ top.location.href = "<?php echo Mage::getBaseUrl().$this->htmlEscape($this->getRedirectUrl());?>" ;
5
+ }
6
+ //]]>
7
+ </script>
app/design/frontend/default/default/template/payline/logo.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php if ($this->isPaylineAvailable()):?>
2
+ <div class="payline-logo">
3
+ <img src="https://webpayment.payline.com/webpayment/image?key=img.product" alt="<?php echo $this->__('Secured by Payline');?>" />
4
+ </div>
5
+ <?php endif;?>
app/design/frontend/default/default/template/payline/page/empty.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
2
+ <html>
3
+
4
+ <body style="background-color:transparent;">
5
+ <?php echo $this->getChildHtml('content');?>
6
+ </body>
7
+ </html>
app/design/frontend/default/default/template/payline/wallet/checkoutbtn.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <button
2
+ class="button btn-checkout"
3
+ onclick="window.location='<?php echo $this->getRedirectUrl();?>';"
4
+ title="<?php echo $this->__('1-click checkout');?>"
5
+ type="button">
6
+ <span><span><?php echo $this->__('1-click checkout');?></span></span>
7
+ </button>
8
+ <div class="secured-by"><em><?php echo $this->__('Secured by Payline');?></em></div>
app/design/frontend/default/default/template/payline/wallet/details.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wallet_details">
2
+ <?php $wallet=$this->getWallet();?>
3
+ <?php if ($wallet):?>
4
+ <div class="box-account">
5
+ <div class="col2-set">
6
+ <div class="col-1">
7
+ <h3><?php echo $this->__('Card informations')?></h3>
8
+ <div class="box-content">
9
+ <?php echo $this->htmlEscape($wallet['card']['type']);?><br/>
10
+ <?php echo $this->htmlEscape($wallet['card']['number']);?><br/>
11
+ <?php echo $this->__('Expiration date (mmyy)').': '.$this->htmlEscape($wallet['card']['expirationDate']);?>
12
+ </div>
13
+ </div>
14
+ <div class="col-2">
15
+ <h3><?php echo $this->__('Owner')?></h3>
16
+ <div class="box-content">
17
+ <?php echo $this->htmlEscape($wallet['firstName'].' '.$wallet['lastName']);?>
18
+ </div>
19
+ </div>
20
+ </div>
21
+
22
+ <?php if ($this->showShippingDetails):?>
23
+ <div class="box-title"><h3><?php echo $this->__('Contact informations');?></h3></div>
24
+ <div class="col2-set">
25
+ <div class="col-1">
26
+ <h4><?php echo $this->__('Phone and e-mail address')?></h4>
27
+ <div class="box-content">
28
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['phone'])?><br/>
29
+ <?php echo $this->htmlEscape($wallet['email']);?>
30
+ </div>
31
+ </div>
32
+ <div class="col-2">
33
+ <h4><?php echo $this->__('Shipping address')?></h4>
34
+ <div class="box-content">
35
+ <address>
36
+ <strong><?php echo $this->htmlEscape($wallet['shippingAddress']['name']);?></strong><br/>
37
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['street1']); ?><br/>
38
+ <?php if ($wallet['shippingAddress']['street2']):?>
39
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['street2']); ?><br/>
40
+ <?php endif;?>
41
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['zipCode']).' '.$this->htmlEscape($wallet['shippingAddress']['cityName']); ?><br/>
42
+ </address>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ <?php endif;?>
47
+ </div>
48
+ <?php endif;?>
49
+ </div>
50
+ <?php /*
51
+ <dl>
52
+ <dt><h3><?php echo $this->__('Owner')?></h3></dt>
53
+ <dd><?php echo $this->htmlEscape($wallet['firstName'].' '.$wallet['lastName']);?></dd>
54
+ <dt><h3><?php echo $this->__('Card informations')?></h3></dt>
55
+ <dd><?php echo $this->htmlEscape($wallet['card']['type']).'<br/>'.$this->htmlEscape($wallet['card']['number']).'<br/>'.$this->__('Expiration date (mmyy)').': '.$this->htmlEscape($wallet['card']['expirationDate']);?></dd>
56
+ <?php if ($this->showShippingDetails):?>
57
+ <dt><h3><?php echo $this->__('Contact informations');?></h3></dt>
58
+ <dd>
59
+ <dl>
60
+ <dt><h4><?php echo $this->__('Shpping address')?></h4></dt>
61
+ <dd>
62
+ <address>
63
+ <strong><?php echo $this->htmlEscape($wallet['shippingAddress']['name']);?></strong><br/>
64
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['street1']); ?><br/>
65
+ <?php if ($wallet['shippingAddress']['street2']):?>
66
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['street2']); ?><br/>
67
+ <?php endif;?>
68
+ <?php echo $this->htmlEscape($wallet['shippingAddress']['zipCode']).' '.$this->htmlEscape($wallet['shippingAddress']['cityName']); ?><br/>
69
+ </address>
70
+ </dd>
71
+ <dt><h4><?php echo $this->__('Phone')?></h4></dt>
72
+ <dd><?php echo $this->htmlEscape($wallet['shippingAddress']['phone'])?></dd>
73
+ <dt><h4><?php echo $this->__('Email address')?></h4></dt>
74
+ <dd><?php echo $this->htmlEscape($wallet['email']);?></dd>
75
+ </dl>
76
+ </dd>
77
+ <?php endif;?>
78
+ </dl>
79
+ <?php endif;?>
80
+
81
+ </div>
82
+ */
app/design/frontend/default/default/template/payline/wallet/form.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $walletData=$this->getWalletData();
3
+ if (!empty($walletData)):?>
4
+ <fieldset class="form-list">
5
+ <?php $_code=$this->getMethodCode() ?>
6
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
7
+ <?php foreach ($walletData as $key=>$value):?>
8
+ <li>
9
+ <strong><?php echo $this->htmlEscape($key);?></strong>:
10
+ <?php echo $this->htmlEscape($value);?>
11
+ </li>
12
+ <?php endforeach;?>
13
+ </ul>
14
+ </fieldset>
15
+ <?php endif;?>
app/design/frontend/default/default/template/payline/wallet/manage.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="dashboard">
2
+ <div class="page-title">
3
+ <h1><?php echo $this->__('Wallet management') ?></h1>
4
+ </div>
5
+ <script type="text/javascript">
6
+ function checkDisableWallet(){
7
+ if(window.confirm("<?php echo $this->__("Are you sure?");?>")){
8
+ window.setLocation('<?php echo Mage::getBaseUrl().'/payline/wallet/disable' ?>');
9
+ }
10
+ }
11
+ </script>
12
+ <div class="wallet-manage-content">
13
+ <p><?php echo $this->__('You can manage here your saved payment informations');?></p>
14
+ <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
15
+
16
+ <?php echo $this->getChildHtml('payline-wallet-details');?>
17
+ <div class="actions">
18
+ <button type="button" title="<?php echo $this->__('Update payment informations') ?>" class="button" onclick="setLocation('<?php echo Mage::getBaseUrl().'/payline/wallet/update' ?>')"><span><span><?php echo $this->__('Update payment informations') ?></span></span></button>
19
+ <button type="button" title="<?php echo $this->__('Disable wallet') ?>" class="button" onclick="checkDisableWallet();"><span><span><?php echo $this->__('Disable wallet') ?></span></span></button>
20
+ </div>
21
+ </div>
22
+ </div>
app/design/frontend/default/default/template/payline/wallet/sidebar.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /* @var $this Monext_Payline_Block_Wallet_Sidebar */?>
2
+ <?php if ($this->getIsNeedToDisplaySideBar()): ?>
3
+ <div class="block block-oneclick">
4
+ <div class="block-title">
5
+ <strong><span><?php echo $this->__('One click checkout') ?></span></strong>
6
+ </div>
7
+ <div class="block-content">
8
+ <?php echo $this->getContent(); ?>
9
+ </div>
10
+ </div>
11
+ <?php endif;?>
app/design/frontend/default/default/template/payline/wallet/sidebar/form.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form id="wallet-checkout" method="post" action="<?php echo Mage::getUrl('payline/checkoutonepage/index');?>" >
2
+ <div class="secured-by"><em><?php echo $this->__('Secured by Payline');?></em></div>
3
+ <dl>
4
+ <dt><?php echo $this->__('Billing address')?></dt>
5
+ <dd><?php echo $this->getBillingAddresses();?></dd>
6
+ <dt><?php echo $this->__('Shipping address')?></dt>
7
+ <dd><?php echo $this->getShippingAddresses();?></dd>
8
+ </dl>
9
+ <p><a href="<?php echo Mage::getUrl('customer/address/');?>"><?php echo $this->__('Edit my data')?></a></p>
10
+ <div class="actions">
11
+ <button class="button btn-wallet-checkout" title="<?php echo $this->__('1-click checkout');?>" type="submit"><span><span><?php echo $this->__('1-click checkout');?></span></span></button>
12
+ </div>
13
+ </form>
app/design/frontend/default/default/template/payline/wallet/sidebar/notlogged.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <div class="notlogged">
2
+ <?php echo $this->getChildHtml();?>
3
+ </div>
4
+ <div class="actions">
5
+ <button class="button btn-wallet-checkout" onclick="window.location='<?php echo Mage::getBaseUrl().'/payline/wallet/subscribe'?>';" title="<?php echo $this->__('Register');?>" type="button"><span><span><?php echo $this->__('Register');?></span></span></button>
6
+ </div>
app/design/frontend/default/default/template/payline/wallet/subscribe.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <div class="dashboard">
2
+ <div class="page-title">
3
+ <h1><?php echo $this->__('Subscribe to wallet') ?></h1>
4
+ </div>
5
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
6
+
7
+ <?php echo $this->getChildHtml('payline-wallet-subscribe-cmsblock');?>
8
+ <?php echo $this->getChildHtml('payline-wallet-subscribe-iframe');?>
9
+
10
+ </div>
app/design/frontend/default/default/template/payline/wallet/update.phtml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <div class="dashboard">
2
+ <div class="page-title">
3
+ <h1><?php echo $this->__('Update payment informations') ?></h1>
4
+ </div>
5
+ <?php echo $this->getChildHtml('payline-wallet-update-iframe');?>
6
+ </div>
app/etc/modules/Monext_Payline.xml CHANGED
@@ -6,6 +6,7 @@
6
  <codePool>community</codePool>
7
  <depends>
8
  <Mage_Payment />
 
9
  </depends>
10
  </Monext_Payline>
11
  </modules>
6
  <codePool>community</codePool>
7
  <depends>
8
  <Mage_Payment />
9
+ <Mage_Customer />
10
  </depends>
11
  </Monext_Payline>
12
  </modules>
app/locale/en_US/Monext_Payline.csv CHANGED
@@ -42,7 +42,7 @@
42
  "Wallet","Wallet"
43
  "Payline - 1 clic payment","Payline - 1 clic payment"
44
  "Wallet subscription","Wallet subscription"
45
- "Wallet management","Wallet management"
46
  "One click checkout","One click checkout"
47
  "registration CMS block id in customer account","registration CMS block id in customer account"
48
  "registration CMS block id in catalog","registration CMS block id in catalog"
@@ -56,7 +56,8 @@
56
  "Error while retrieving wallet information","Error while retrieving wallet information"
57
  "You can manage here your saved payment informations","You can manage here your saved payment informations"
58
  "Update payment informations","Update payment informations"
59
- "Disable wallet","Disable wallet"
 
60
  "Update wallet","Update wallet"
61
  "French","French"
62
  "English","English"
@@ -65,4 +66,48 @@
65
  "Italian","Italian"
66
  "German","German"
67
  "Flemish","Flemish"
68
- "Finn","Finn"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  "Wallet","Wallet"
43
  "Payline - 1 clic payment","Payline - 1 clic payment"
44
  "Wallet subscription","Wallet subscription"
45
+ "Wallet management","My payment method"
46
  "One click checkout","One click checkout"
47
  "registration CMS block id in customer account","registration CMS block id in customer account"
48
  "registration CMS block id in catalog","registration CMS block id in catalog"
56
  "Error while retrieving wallet information","Error while retrieving wallet information"
57
  "You can manage here your saved payment informations","You can manage here your saved payment informations"
58
  "Update payment informations","Update payment informations"
59
+ "Disable wallet","Delete wallet"
60
+ "Your wallet has been disabled.","Your wallet has been deleted."
61
  "Update wallet","Update wallet"
62
  "French","French"
63
  "English","English"
66
  "Italian","Italian"
67
  "German","German"
68
  "Flemish","Flemish"
69
+ "Finn","Finn"
70
+ "Wallet update succeed","Wallet update succeed"
71
+ "Error during update","Error during update"
72
+ "Shipping address","Shipping address"
73
+ "Contact information","Contact information"
74
+ "Billing address","Billing address"
75
+ "Shipping address","Shipping address"
76
+ "Send wallet id for all Payline payment methods","Send wallet id for all Payline payment methods"
77
+ "Automate subscription","Automatiser l'inscription"
78
+ "Error while updating wallet","Erreur lors de la mise à jour du wallet"
79
+ "Free shipping","Livraison gratuite"
80
+ "Flat rate","Tarification unique"
81
+ "Table rates","Tarifications"
82
+ "Default shipping method","Méthodes de livraison par défaut"
83
+ "Card type","Card type"
84
+ "Number","Number"
85
+ "Exp. date","Exp. Date"
86
+ "Please wait a few seconds, we're processing your order...","Please wait a few seconds, we're processing your order..."
87
+ "The credit card of your wallet has expired.","The credit card of your wallet has expired."
88
+ "Update your wallet information","Update your wallet information"
89
+ " or process your order below."," or process your order below."
90
+ "The wallet payment method is disabled. You can process your order below.","The wallet payment method is disabled. You can process your order below."
91
+ "Contract number American Express","Contract number American Express"
92
+ "Contract number CB","Contract number CB"
93
+ "Show a custom text (CMS block) about registration to wallet in catalog","Show a custom text (CMS block) about registration to wallet in catalog"
94
+ "Each contract number has to be separated by ;","Each contract number has to be separated by ;"
95
+ "URL to a custom HTML template. Refer to Payline documentation","URL to a custom HTML template. Refer to Payline documentation"
96
+ "ID of a style defined in Payline administration tool.","ID of a style defined in Payline administration tool."
97
+ "Shipping method to use with one click checkout. Flatrate, freeshipping and Tablerates are available","Shipping method to use with one click checkout. Flatrate, freeshipping and Tablerates are available"
98
+ "Default shipping method","Default shipping method"
99
+ "Allow user to update his personal details","Allow user to update his personal details"
100
+ "Allow user to update his payment details","Allow user to update his payment details"
101
+ "Automate subscription","Automate subscription"
102
+ "A customer wallet will be created with the first payment using Payline","A customer wallet will be created with the first payment using Payline"
103
+ "If wallet id is provided, wallet payment will be available during web payment","If wallet id is provided, wallet payment will be available during web payment"
104
+ "Billing occurences","Billing occurences"
105
+ "Billing cycle","Billing cycle"
106
+ "daily","daily"
107
+ "weekly","weekly"
108
+ "monthly","monthly"
109
+ "twice a month","twice a month"
110
+ "Phone and e-mail address","Phone and e-mail address"
111
+ "1-click checkout","1-click checkout"
112
+ "Secured by Payline","Secured by Payline"
113
+ "Edit my data","Edit my data"
app/locale/fr_FR/Monext_Payline.csv CHANGED
@@ -10,7 +10,7 @@
10
  "Order status when payment canceled by customer","Status de commande quand paiement annulé par le client"
11
  "Order status when payment refused by Payline","Status de commande quand paiement refusé par Payline"
12
  "Merchant ID","ID commerçant"
13
- "Access key","Clef d'accès"
14
  "Contract number","Numéro de contrat"
15
  "Contract number list","Liste des numéros de contrat"
16
  "Template URL","URL du template"
@@ -27,7 +27,7 @@
27
  "Month","Mois"
28
  "Year","Année"
29
  "Name on Card","Nom sur la carte"
30
- "Credit Card Type"," "Type de carte"
31
  "Credit Card Number","Numéro de carte"
32
  "Expiration Date","Date d'expiration"
33
  "Card Verification Number","Numéro de vérification"
@@ -42,7 +42,7 @@
42
  "Wallet","Portefeuille"
43
  "Payline - 1 clic payment","Payline – Paiement en un clic"
44
  "Wallet subscription","Inscription au portefeuille"
45
- "Wallet management","Gestion du portefeuille"
46
  "One click checkout","Commandez en 1 clic"
47
  "registration CMS block id in customer account","ID du bloc CMS d'inscription dans le compte client"
48
  "registration CMS block id in catalog","ID du bloc CMS d'inscription dans le catalogue"
@@ -51,12 +51,13 @@
51
  "Error during subscribtion","Erreur lors de l'inscription"
52
  "Wallet subscription succeed","Inscription au portefeuille réussie"
53
  "Owner","Titulaire"
54
- "Card information","Informations de la carte"
55
  "Expiration date (mmyy)","Date d'expiration (mmaa)"
56
  "Error while retrieving wallet information","Erreur lors de la récupération des informations du portefeuille"
57
  "You can manage here your saved payment informations","Vous pouvez gérer ici vos informations de paiement enregistrées"
58
  "Update payment informations","Mettre à jour les informations de paiement"
59
- "Disable wallet","Désactiver votre portefeuille"
 
60
  "Update wallet","Mise à jour du portefeuille"
61
  "French","Français"
62
  "English","Anglais"
@@ -65,4 +66,48 @@
65
  "Italian","Italien"
66
  "German","Allemand"
67
  "Flemish","Flamand"
68
- "Finn","Finlandais"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  "Order status when payment canceled by customer","Status de commande quand paiement annulé par le client"
11
  "Order status when payment refused by Payline","Status de commande quand paiement refusé par Payline"
12
  "Merchant ID","ID commerçant"
13
+ "Access key","Clé d'accès"
14
  "Contract number","Numéro de contrat"
15
  "Contract number list","Liste des numéros de contrat"
16
  "Template URL","URL du template"
27
  "Month","Mois"
28
  "Year","Année"
29
  "Name on Card","Nom sur la carte"
30
+ "Credit Card Type","Type de carte"
31
  "Credit Card Number","Numéro de carte"
32
  "Expiration Date","Date d'expiration"
33
  "Card Verification Number","Numéro de vérification"
42
  "Wallet","Portefeuille"
43
  "Payline - 1 clic payment","Payline – Paiement en un clic"
44
  "Wallet subscription","Inscription au portefeuille"
45
+ "Wallet management","Mon moyen de paiement"
46
  "One click checkout","Commandez en 1 clic"
47
  "registration CMS block id in customer account","ID du bloc CMS d'inscription dans le compte client"
48
  "registration CMS block id in catalog","ID du bloc CMS d'inscription dans le catalogue"
51
  "Error during subscribtion","Erreur lors de l'inscription"
52
  "Wallet subscription succeed","Inscription au portefeuille réussie"
53
  "Owner","Titulaire"
54
+ "Card informations","Informations de la carte"
55
  "Expiration date (mmyy)","Date d'expiration (mmaa)"
56
  "Error while retrieving wallet information","Erreur lors de la récupération des informations du portefeuille"
57
  "You can manage here your saved payment informations","Vous pouvez gérer ici vos informations de paiement enregistrées"
58
  "Update payment informations","Mettre à jour les informations de paiement"
59
+ "Disable wallet","Supprimez votre portefeuille"
60
+ "Your wallet has been disabled.","Votre portefeuille a été supprimé."
61
  "Update wallet","Mise à jour du portefeuille"
62
  "French","Français"
63
  "English","Anglais"
66
  "Italian","Italien"
67
  "German","Allemand"
68
  "Flemish","Flamand"
69
+ "Finn","Finlandais"
70
+ "Wallet update succeed","Mise à jour du portefeuille effectuée"
71
+ "Error during update","Erreur lors de la mise à jour"
72
+ "Shipping address","Adresse de livraison"
73
+ "Contact information","Informations de contact"
74
+ "Billing address","Adresse de facturation"
75
+ "Shipping address","Adresse de livraison"
76
+ "Send wallet id for all Payline payment methods","Envoyer le wallet_id pour tous paiements Payline"
77
+ "Automate subscription","Automate subscription"
78
+ "Error while updating wallet","Error while updating wallet"
79
+ "Free shipping","Free shipping"
80
+ "Flat rate","Flat rate"
81
+ "Table rates","Table rates"
82
+ "Default shipping method","Default shipping method"
83
+ "Card type","Type carte"
84
+ "Number","Numéro"
85
+ "Exp. date","Date d'exp."
86
+ "Please wait a few seconds, we're processing your order...","Merci de patienter quelques secondes, nous calculons votre commande..."
87
+ "The credit card of your wallet has expired.","La carte de crédit de votre portefeuille a expiré."
88
+ "Update your wallet information","Mettez à jour les information de votre portefeuille"
89
+ " or process your order below."," ou continuer votre commande ci-dessous."
90
+ "The wallet payment method is disabled. You can process your order below.","Le paiement par portefeuille est désactivé. Vous pouvez continuer votre commande ci-dessous"
91
+ "Contract number American Express","N° de contrat American Express"
92
+ "Contract number CB","N° de contrat CB"
93
+ "Show a custom text (CMS block) about registration to wallet in catalog","Afficher un texte personalisable sur l'inscription au wallet en catalogue"
94
+ "Each contract number has to be separated by ;","Chaque numéro de contrat doit être séparé par un ;"
95
+ "URL to a custom HTML template. Refer to Payline documentation","URL vers un template HTML personalisé. Se référer à la doc Payline"
96
+ "ID of a style defined in Payline administration tool.","ID d'un style défini dans l'espace d'administration Payline."
97
+ "Shipping method to use with one click checkout. Flatrate, freeshipping and Tablerates are available","Méthode de livraison à utiliser avec le paiement en un clic. Les méthodes flatrate, tablerate et freeshipping sont disponibles"
98
+ "Default shipping method","Méthode de livraison par défaut"
99
+ "Allow user to update his personal details","Autoriser l'utilisateur à mettre à jour ses données personnelles"
100
+ "Allow user to update his payment details","Autoriser l'utilisateur à mettre à jour ses informations de paiement"
101
+ "Automate subscription","Inscription automatique"
102
+ "A customer wallet will be created with the first payment using Payline","Un portefeuille client sera créé au premier paiement du client par Payline"
103
+ "If wallet id is provided, wallet payment will be available during web payment","Si l'ID du wallet est fourni, Payline pourra proposer le mode de paiement par wallet pendant un paiement Web"
104
+ "Billing occurences","Nombre de prélèvements"
105
+ "Billing cycle","Période entre chaque prélèvement"
106
+ "daily","journalier"
107
+ "weekly","hebdomadaire"
108
+ "monthly","mensuel"
109
+ "twice a month","deux fois par mois"
110
+ "Phone and e-mail address","Téléphone et adresse email"
111
+ "1-click checkout","Commander en un clic"
112
+ "Secured by Payline","Securisé par Payline"
113
+ "Edit my data","Modifier mes informations"
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Payline</name>
4
- <version>1.5.7</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Payline payment module</description>
11
  <notes>Add the wallet paiement method and 1 clic checkout</notes>
12
  <authors><author><name>payline</name><user>auto-converted</user><email>support@payline.com</email></author></authors>
13
- <date>2011-01-04</date>
14
- <time>15:48:28</time>
15
- <contents><target name="magelocale"><dir name="en_US"><file name="Monext_Payline.csv" hash="16ea4e8b33a751dd63155cf5d6cff45f"/></dir><dir name="fr_FR"><file name="Monext_Payline.csv" hash="83ee15cb66000b5eb2652741c536c2b7"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="payline"><file name="Direct.phtml" hash="b731469e615d30fa604f143822eaa8ad"/><file name="Payline.phtml" hash="dc264172e5a6c5ae627b697208dff65d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Monext_Payline.xml" hash="588e88c573b925d7094d3026acf334d3"/></dir></target><target name="magecommunity"><dir name="Monext"><dir name="Payline"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><dir name="Create"><file name="Items.php" hash="6119849c47710d859ef0bfea4ced25fe"/></dir></dir></dir></dir></dir><file name="Cpt.php" hash="22ef3e967c71a050eabcd66c6ee2c2e6"/><file name="Direct.php" hash="06fe67401331e1b131148388060eebc4"/><file name="Nx.php" hash="ecd1a70cb83cc106cce7bf407733036b"/></dir><dir name="controllers"><file name="IndexController.php" hash="48865b47c712f2cb9042bc965aff3f40"/></dir><dir name="etc"><file name="config.xml" hash="8f5deb080cb2e1b5a8ea0003866d7438"/><file name="system.xml" hash="7db3c8792fa290b63069fe5dc5f49e8d"/></dir><dir name="Helper"><file name="Data.php" hash="d6c3304d18796e49dd7127817705ec77"/><file name="Logger.php" hash="45a2b9e6d583adc7a816af29af16c430"/></dir><dir name="Model"><dir name="Datasource"><dir name="Status"><file name="Canceled.php" hash="c4e799efcb052536081339520c7b72c2"/></dir><file name="Actions.php" hash="2152344a8bd5fbf7dbe711c58f97356c"/><file name="Billingcycles.php" hash="ba126134c137da23d8176b6819ca81e6"/><file name="Billingoccurrences.php" hash="581ce23ec626ed71791b13c7b11fe6db"/><file name="Languages.php" hash="17053eec4880c5c5b1f233a3ca9f0bda"/><file name="Paymentactions.php" hash="6c4aae3b1b4e8b987a4da7393a3a92eb"/><file name="Securitymodes.php" hash="06c55b65e9254d96fa87595322839932"/></dir><file name="Cpt.php" hash="55cc8025101a7e6efdde8f347eddd771"/><file name="Direct.php" hash="f8dfb2e707a68eaddacf54225bfb1b83"/><file name="Nx.php" hash="830433cc06e92665fd554fe0030070f0"/></dir><dir name="PaylinePHPKit"><dir name="lib"><file name="paylineSDK.php" hash="fe6e4a3025e389e1eb8b92f31331a121"/></dir><dir name="wsdl"><dir name="homologation"><file name="DirectPaymentAPI.wsdl" hash="ff2c4e078d4b1ed81054faa3ed6f0d00"/><file name="ExtendedAPI.wsdl" hash="ee799a667945cf7eb96e8b900497287c"/><file name="WebPaymentAPI.wsdl" hash="e579a258bd082e291359eea3355c6e26"/></dir><dir name="production"><file name="DirectPaymentAPI.wsdl" hash="bca9e74419fee1c7e55112fffd4331ee"/><file name="ExtendedAPI.wsdl" hash="021f0c11e8b17ca017b00170d6a47b5b"/><file name="WebPaymentAPI.wsdl" hash="090b55eac01074b96323482d07b2d5ed"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Payline</name>
4
+ <version>1.6.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
10
  <description>Payline payment module</description>
11
  <notes>Add the wallet paiement method and 1 clic checkout</notes>
12
  <authors><author><name>payline</name><user>auto-converted</user><email>support@payline.com</email></author></authors>
13
+ <date>2011-02-09</date>
14
+ <time>16:52:24</time>
15
+ <contents><target name="magelocale"><dir name="en_US"><file name="Monext_Payline.csv" hash="e5e2e60581347c07e687bd7daf803c4e"/></dir><dir name="fr_FR"><file name="Monext_Payline.csv" hash="4f3a410d5433b929d9e69b88dc407a24"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="payline.css" hash="36cb9692fb85c57f5c1430a20cbfe7ec"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="payline.xml" hash="83a061dd99daa4e48c4411ea8ea28391"/></dir><dir name="template"><dir name="payline"><dir name="checkout"><dir name="onepage"><file name="shipping-method.phtml" hash="c6ffe910d812e68d7a737944cf5e567f"/></dir><file name="onepage.phtml" hash="c7abb66eecc1f0e2903cad81f77e2249"/></dir><dir name="page"><file name="empty.phtml" hash="02134361869217c7445f46af028a050a"/></dir><dir name="wallet"><dir name="sidebar"><file name="form.phtml" hash="0fc6234cc29bf056252bb40c8b9f3f2b"/><file name="notlogged.phtml" hash="bf184e04f9648cf8c4671662896b99b1"/></dir><file name="checkoutbtn.phtml" hash="a1bbb577e4b2cb85bec079f315d22c15"/><file name="details.phtml" hash="b8d7e336b994261f66f1a9af5841661e"/><file name="form.phtml" hash="7358f21e31266c65982afb15239e659f"/><file name="manage.phtml" hash="994c98abd9b4f2f68f76eefe20c637d1"/><file name="sidebar.phtml" hash="011f01957ec5f5015941f59bc6c3b61b"/><file name="subscribe.phtml" hash="a737e95240e262e91ec01a02e2ce97a2"/><file name="update.phtml" hash="1b7048c9a839b0b0994beaf5e72b755c"/></dir><file name="Direct.phtml" hash="b731469e615d30fa604f143822eaa8ad"/><file name="iframe.phtml" hash="255f2ad6c09019f7e403cff3aadb9c72"/><file name="iframeleaver.phtml" hash="b617751653aa68ada738385a3959e863"/><file name="logo.phtml" hash="c22e80c9afabaaec0a7e936b15f8a219"/><file name="Payline.phtml" hash="dc264172e5a6c5ae627b697208dff65d"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Monext_Payline.xml" hash="59980c5c4127dc2a7ca46a894efeb94f"/></dir></target><target name="magecommunity"><dir name="Monext"><dir name="Payline"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><dir name="Create"><file name="Items.php" hash="c7cd82866d8788ff32d42df8fcdc11f8"/></dir></dir></dir></dir></dir><dir name="Wallet"><file name="Checkoutbtn.php" hash="2574357df9378d0d25ec0d970750f0a5"/><file name="Details.php" hash="03cb96bd76d2265b842677b2a6825303"/><file name="Infos.php" hash="15d4731c490b2dcbc3f7b480608e9b1b"/><file name="Sidebar.php" hash="08293c0348e8c59c1a72041a0ca59d5b"/></dir><file name="Cpt.php" hash="32c8a04035fd4fb05fefe3bff0162663"/><file name="Direct.php" hash="6d84f0363fb7eb5a967319c7cccc72fb"/><file name="Logo.php" hash="2b7784f040f04489448fbc13b05ffe74"/><file name="Nx.php" hash="c4f40f23a346e0ba67e6a7096de620ba"/><file name="Wallet.php" hash="6326c9e76c84777597f30a89d718ccb4"/></dir><dir name="controllers"><file name="CheckoutonepageController.php" hash="9a95809b771ac9f4cd08fea69108a9a9"/><file name="IndexController.php" hash="fe05b9366eae7310655f17937533826c"/><file name="UnloggedwalletController.php" hash="ec8f49526c713ce9904eadf2abb8bb4c"/><file name="WalletController.php" hash="fae482a7e7c0e3d4a0f3ea78231abe16"/></dir><dir name="etc"><file name="config.xml" hash="5924a3cbd17dce42d102a584c5618370"/><file name="system.xml" hash="6476454539be3e1ce460ccb9086fa587"/></dir><dir name="Helper"><file name="Data.php" hash="eb4ac048e57ce80e8051aed963f2ad14"/><file name="Logger.php" hash="45a2b9e6d583adc7a816af29af16c430"/></dir><dir name="Model"><dir name="Datasource"><dir name="Status"><file name="Canceled.php" hash="c4e799efcb052536081339520c7b72c2"/></dir><file name="Actions.php" hash="2152344a8bd5fbf7dbe711c58f97356c"/><file name="Billingcycles.php" hash="bef244e6d9e744fbbc3afed9cc2050f9"/><file name="Billingoccurrences.php" hash="581ce23ec626ed71791b13c7b11fe6db"/><file name="Languages.php" hash="17053eec4880c5c5b1f233a3ca9f0bda"/><file name="Paymentactions.php" hash="6c4aae3b1b4e8b987a4da7393a3a92eb"/><file name="Securitymodes.php" hash="06c55b65e9254d96fa87595322839932"/><file name="Shippingmethods.php" hash="1c67f2af87583aae049c86cb4dcdf881"/></dir><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Setup.php" hash="f0cb886cd65e23ec397e651d7913ea9e"/></dir></dir></dir><file name="Cpt.php" hash="55cc8025101a7e6efdde8f347eddd771"/><file name="Direct.php" hash="f8dfb2e707a68eaddacf54225bfb1b83"/><file name="Nx.php" hash="830433cc06e92665fd554fe0030070f0"/><file name="Wallet.php" hash="c8cb9ce833f667374d036f3e15b60222"/></dir><dir name="PaylinePHPKit"><dir name="lib"><file name="paylineSDK.php" hash="6d810f5039c636c02c93c32c3226fab0"/></dir><dir name="wsdl"><dir name="homologation"><file name="DirectPaymentAPI.wsdl" hash="ff2c4e078d4b1ed81054faa3ed6f0d00"/><file name="ExtendedAPI.wsdl" hash="ee799a667945cf7eb96e8b900497287c"/><file name="WebPaymentAPI.wsdl" hash="e579a258bd082e291359eea3355c6e26"/></dir><dir name="production"><file name="DirectPaymentAPI.wsdl" hash="bca9e74419fee1c7e55112fffd4331ee"/><file name="ExtendedAPI.wsdl" hash="021f0c11e8b17ca017b00170d6a47b5b"/><file name="WebPaymentAPI.wsdl" hash="090b55eac01074b96323482d07b2d5ed"/></dir></dir></dir><dir name="sql"><dir name="payline_setup"><file name="mysql4-install-1.6.0.php" hash="ed5013f743ba36a7b2884fc432f97e16"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
skin/frontend/default/default/css/payline.css ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @CHARSET "UTF-8";
2
+ .iframe-subscribe-wallet, .iframe-update-wallet{
3
+ width:100%;
4
+ height:500px;
5
+ border:none;
6
+ overflow:hidden;
7
+ }
8
+
9
+ .iframe-with-perso-data{
10
+ height:700px;
11
+ }
12
+
13
+ .wallet-manage-content .actions{
14
+ margin-top:20px;
15
+ }
16
+ .wallet_details dt{
17
+ font-weight:bold;
18
+ }
19
+
20
+ .wallet_details dl dd {
21
+ padding-left:20px;
22
+ }
23
+
24
+ .side-col .block-oneclick dl,
25
+ .side-col .block-oneclick .notlogged,
26
+ .sidebar .block-oneclick dl,
27
+ .sidebar .block-oneclick .notlogged,
28
+ .checkout-types .block-oneclick dl,
29
+ .checkout-types .block-oneclick .notlogged {
30
+ padding:5px;
31
+ }
32
+ .side-col .block-oneclick select,
33
+ .checkout-types .block-oneclick select,
34
+ .sidebar .block-oneclick select{
35
+ width:100%;
36
+ }
37
+
38
+ .checkout-types .block-oneclick{
39
+ text-align:left;
40
+ }
41
+
42
+ .payline-checkoutonepage-index #wait-txt{
43
+ display:none;
44
+ padding:20px;
45
+ width:300px;
46
+ height:30px;
47
+ }
48
+ .payline-checkoutonepage-index .popin{
49
+ position:absolute;
50
+ display:block!important;
51
+ background-color:#FFFFFF;
52
+ border:2px solid black;
53
+ text-align:center;
54
+ z-index:999;
55
+ }
56
+
57
+ .payline-checkoutonepage-index .col-main {
58
+ padding: 20px 0 0;
59
+ }
60
+
61
+ form#wallet-checkout p{
62
+ padding:0 5px;
63
+ }
64
+ .sidebar .payline-logo {
65
+ display: block;
66
+ margin: 10px 0;
67
+ text-align: center;
68
+ }
69
+ #wallet-checkout .secured-by{
70
+ padding:0 5px;
71
+ text-align:right;
72
+ }