FuturePayUS - Version 2.0.11

Version Notes

FuturePay Payment method

Download this release

Release Info

Developer FuturePay
Extension FuturePayUS
Version 2.0.11
Comparing to
See all releases


Code changes from version 2.0.0 to 2.0.11

Files changed (22) hide show
  1. app/code/community/FuturePay/FuturePay/Block/Form/Futurepay.php +1 -1
  2. app/code/community/FuturePay/FuturePay/Block/Info/Futurepay.php +1 -1
  3. app/code/community/FuturePay/FuturePay/Block/Process.php +0 -1
  4. app/code/community/FuturePay/FuturePay/Helper/Data.php +20 -63
  5. app/code/community/FuturePay/FuturePay/Model/Method/Futurepay.php +79 -68
  6. app/code/community/FuturePay/FuturePay/Model/Observer.php +0 -49
  7. app/code/community/FuturePay/FuturePay/Model/Resource/Setup.php +25 -4
  8. app/code/community/FuturePay/FuturePay/Model/Source/Order/Status.php +6 -4
  9. app/code/community/FuturePay/FuturePay/Model/Source/Payment/Action.php +6 -4
  10. app/code/community/FuturePay/FuturePay/Model/Source/Title/Custom.php +6 -4
  11. app/code/community/FuturePay/FuturePay/controllers/IndexController.php +188 -357
  12. app/code/community/FuturePay/FuturePay/data/futurepay_setup/data-install-2.0.0.php +0 -6
  13. app/code/community/FuturePay/FuturePay/data/futurepay_setup/data-install-2.0.11.php +18 -0
  14. app/code/community/FuturePay/FuturePay/etc/config.xml +1 -16
  15. app/design/adminhtml/base/default/template/futurepay/info/futurepay.phtml +1 -1
  16. app/design/frontend/base/default/layout/futurepay.xml +0 -11
  17. app/design/frontend/base/default/template/futurepay/form/mark.phtml +10 -14
  18. app/design/frontend/base/default/template/futurepay/form/redirect.phtml +268 -248
  19. app/design/frontend/base/default/template/futurepay/info/futurepay.phtml +7 -12
  20. app/design/frontend/base/default/template/futurepay/process.phtml +0 -49
  21. app/etc/modules/Futurepay_Futurepay.xml +1 -1
  22. package.xml +4 -4
app/code/community/FuturePay/FuturePay/Block/Form/Futurepay.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  protected function _construct()
3
  {
4
  $mark = new $mark;
5
  $mark->setTemplate('futurepay/form/mark.phtml')
6
  ->setPaymentAcceptanceMarkSrc($this->getSkinUrl('futurepay/fp_small_logo.png'))
7
  ;
8
  $this->setTemplate('futurepay/form/redirect.phtml')
9
  ->setRedirectMessage(
10
  Mage::helper('paypal')->__('Buy Now and Pay Later without a credit card using FuturePay. It\'s secure, convenient and easy to use. Don\'t have an account yet? You can signup and checkout in seconds.')
11
  )
12
  ->setMethodTitle('') // Output PayPal mark, omit title
13
  ->setMethodLabelAfterHtml($mark->toHtml())
14
  ;
15
  }
 
16
  /**
17
  * Override the default Block Form with FuturePay logo and template
18
  *
19
  * @return void
20
  */
21
  protected function _construct() {
22
  $mark = Mage::getConfig()->getBlockClassName('core/template');
23
  $mark = new $mark;
24
  $mark->setTemplate('futurepay/form/mark.phtml')
25
  ->setPaymentAcceptanceMarkSrc($this->getSkinUrl('futurepay/fp_small_logo.png'));
26
  $this->setTemplate('futurepay/form/redirect.phtml')
27
  ->setRedirectMessage(
28
  Mage::helper('futurepay')->__('Buy Now and Pay Later without a credit card using FuturePay. It\'s secure, convenient and easy to use. Don\'t have an account yet? You can signup and checkout in seconds.')
29
  )
30
  ->setMethodTitle('') // Output mark, omit title
31
  ->setMethodLabelAfterHtml($mark->toHtml());
32
 
33
  parent::_construct();
34
  }
 
1
  protected function _construct()
2
  {
3
  $mark = new $mark;
4
  $mark->setTemplate('futurepay/form/mark.phtml')
5
  ->setPaymentAcceptanceMarkSrc($this->getSkinUrl('futurepay/fp_small_logo.png'))
6
  ;
7
  $this->setTemplate('futurepay/form/redirect.phtml')
8
  ->setRedirectMessage(
9
  Mage::helper('paypal')->__('Buy Now and Pay Later without a credit card using FuturePay. It\'s secure, convenient and easy to use. Don\'t have an account yet? You can signup and checkout in seconds.')
10
  )
11
  ->setMethodTitle('') // Output PayPal mark, omit title
12
  ->setMethodLabelAfterHtml($mark->toHtml())
13
  ;
14
  }
15
+ <?php
16
  /**
17
  * Override the default Block Form with FuturePay logo and template
18
  *
19
  * @return void
20
  */
21
  protected function _construct() {
22
  $mark = Mage::getConfig()->getBlockClassName('core/template');
23
  $mark = new $mark;
24
  $mark->setTemplate('futurepay/form/mark.phtml')
25
  ->setPaymentAcceptanceMarkSrc($this->getSkinUrl('futurepay/fp_small_logo.png'));
26
  $this->setTemplate('futurepay/form/redirect.phtml')
27
  ->setRedirectMessage(
28
  Mage::helper('futurepay')->__('Buy Now and Pay Later without a credit card using FuturePay. It\'s secure, convenient and easy to use. Don\'t have an account yet? You can signup and checkout in seconds.')
29
  )
30
  ->setMethodTitle('') // Output mark, omit title
31
  ->setMethodLabelAfterHtml($mark->toHtml());
32
 
33
  parent::_construct();
34
  }
app/code/community/FuturePay/FuturePay/Block/Info/Futurepay.php CHANGED
@@ -1 +1 @@
1
- <?php
2
  protected $_checkout;
3
  protected function _construct()
4
  {
5
  parent::_construct();
6
  $this->setTemplate('futurepay/info/futurepay.phtml');
7
  }
8
  /**
9
  * Enter description here...
10
  *
11
  * @return string
12
  */
13
  public function getPayableTo()
14
  {
15
  return '';
16
  }
17
  /**
18
  * Enter description here...
19
  *
20
  * @return string
21
  */
22
  public function getMailingAddress()
23
  {
24
  return '';
25
  }
26
  public function getCheckout()
27
  {
28
  if (is_null($this->_checkout)) {
29
  $this->_convertAdditionalData();
30
  }
31
  return $this->_checkout;
32
  }
33
 
34
  public function getReturnUrl()
35
  {
36
  return '';
37
  }
38
  /**
39
  * Enter description here...
40
  *
41
  * @return Mage_Payment_Block_Info_Checkmo
42
  */
43
  protected function _convertAdditionalData()
44
  {
45
  $details = @unserialize($this->getInfo()->getAdditionalData());
46
  if (is_array($details)) {
47
  $this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
48
  $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
49
  $this->_return_url = isset($details['return_url']) ? (string) $details['return_url'] : '';
50
  $this->_checkout = isset($details['checkout']) ? (string) $details['checkout'] : '';
51
  $this->_merchantID = isset($details['merchantID']) ? (string) $details['merchantID'] : '';
52
  $this->_secure_code = isset($details['secure_code']) ? (string) $details['secure_code'] : '';
53
  } else {
54
  $this->_payableTo = '';
55
  $this->_mailingAddress = '';
56
  $this->_return_url='';
57
  $this->_checkout='';
58
  $this->_merchantID='';
59
  $this->_secure_code='';
60
  }
61
  return $this;
62
  }
63
 
64
  public function toPdf()
65
  {
66
  $this->setTemplate('futurepay/info/futurepay.phtml');
67
  return $this->toHtml();
68
  }
 
69
  protected $_checkout;
70
  protected function _construct() {
71
  parent::_construct();
72
 
73
  // override the default info block template
74
  $this->setTemplate('futurepay/info/futurepay.phtml');
75
  }
76
 
77
  /**
78
  * Override default getPayableTo() to return an empty string
79
  *
80
  * @return string
81
  */
82
  public function getPayableTo() {
83
  return '';
84
  }
85
 
86
  /**
87
  * Override default getMailingAddress() to return an empty string
88
  *
89
  * @return string
90
  */
91
  public function getMailingAddress() {
92
  return '';
93
  }
94
 
95
  /**
96
  * Override default getCheckout()
97
  *
98
  * @return string
99
  */
100
  public function getCheckout() {
101
  if (is_null($this->_checkout)) {
102
  $this->_convertAdditionalData();
103
  }
104
  return $this->_checkout;
105
  }
106
 
107
  /**
108
  * Override default getReturnUrl() to return an empty string
109
  *
110
  * @return string
111
  */
112
  public function getReturnUrl() {
113
  return '';
114
  }
115
  /**
116
  * Convert additional data to strings and return this instance
117
  *
118
  * @return Mage_Payment_Block_Info_FuturePay
119
  */
120
  protected function _convertAdditionalData() {
121
  $details = @unserialize($this->getInfo()->getAdditionalData());
122
  if (is_array($details)) {
123
  $this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
124
  $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
125
  $this->_return_url = isset($details['return_url']) ? (string) $details['return_url'] : '';
126
  $this->_checkout = isset($details['checkout']) ? (string) $details['checkout'] : '';
127
  $this->_merchantID = isset($details['merchantID']) ? (string) $details['merchantID'] : '';
128
  $this->_secure_code = isset($details['secure_code']) ? (string) $details['secure_code'] : '';
129
 
130
  } else {
131
  $this->_payableTo = '';
132
  $this->_mailingAddress = '';
133
  $this->_return_url = '';
134
  $this->_checkout = '';
135
  $this->_merchantID = '';
136
  $this->_secure_code = '';
137
  }
138
  return $this;
139
  }
140
 
141
  /**
142
  * Override default toPdf() function to return the FuturePay info template
143
  * as HTML
144
  *
145
  * @return string
146
  */
147
  public function toPdf() {
148
  $this->setTemplate('futurepay/info/futurepay.phtml');
149
  return $this->toHtml();
150
  }
 
1
  protected $_checkout;
2
  protected function _construct()
3
  {
4
  parent::_construct();
5
  $this->setTemplate('futurepay/info/futurepay.phtml');
6
  }
7
  /**
8
  * Enter description here...
9
  *
10
  * @return string
11
  */
12
  public function getPayableTo()
13
  {
14
  return '';
15
  }
16
  /**
17
  * Enter description here...
18
  *
19
  * @return string
20
  */
21
  public function getMailingAddress()
22
  {
23
  return '';
24
  }
25
  public function getCheckout()
26
  {
27
  if (is_null($this->_checkout)) {
28
  $this->_convertAdditionalData();
29
  }
30
  return $this->_checkout;
31
  }
32
 
33
  public function getReturnUrl()
34
  {
35
  return '';
36
  }
37
  /**
38
  * Enter description here...
39
  *
40
  * @return Mage_Payment_Block_Info_Checkmo
41
  */
42
  protected function _convertAdditionalData()
43
  {
44
  $details = @unserialize($this->getInfo()->getAdditionalData());
45
  if (is_array($details)) {
46
  $this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
47
  $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
48
  $this->_return_url = isset($details['return_url']) ? (string) $details['return_url'] : '';
49
  $this->_checkout = isset($details['checkout']) ? (string) $details['checkout'] : '';
50
  $this->_merchantID = isset($details['merchantID']) ? (string) $details['merchantID'] : '';
51
  $this->_secure_code = isset($details['secure_code']) ? (string) $details['secure_code'] : '';
52
  } else {
53
  $this->_payableTo = '';
54
  $this->_mailingAddress = '';
55
  $this->_return_url='';
56
  $this->_checkout='';
57
  $this->_merchantID='';
58
  $this->_secure_code='';
59
  }
60
  return $this;
61
  }
62
 
63
  public function toPdf()
64
  {
65
  $this->setTemplate('futurepay/info/futurepay.phtml');
66
  return $this->toHtml();
67
  }
68
+ <?php
69
  protected $_checkout;
70
  protected function _construct() {
71
  parent::_construct();
72
 
73
  // override the default info block template
74
  $this->setTemplate('futurepay/info/futurepay.phtml');
75
  }
76
 
77
  /**
78
  * Override default getPayableTo() to return an empty string
79
  *
80
  * @return string
81
  */
82
  public function getPayableTo() {
83
  return '';
84
  }
85
 
86
  /**
87
  * Override default getMailingAddress() to return an empty string
88
  *
89
  * @return string
90
  */
91
  public function getMailingAddress() {
92
  return '';
93
  }
94
 
95
  /**
96
  * Override default getCheckout()
97
  *
98
  * @return string
99
  */
100
  public function getCheckout() {
101
  if (is_null($this->_checkout)) {
102
  $this->_convertAdditionalData();
103
  }
104
  return $this->_checkout;
105
  }
106
 
107
  /**
108
  * Override default getReturnUrl() to return an empty string
109
  *
110
  * @return string
111
  */
112
  public function getReturnUrl() {
113
  return '';
114
  }
115
  /**
116
  * Convert additional data to strings and return this instance
117
  *
118
  * @return Mage_Payment_Block_Info_FuturePay
119
  */
120
  protected function _convertAdditionalData() {
121
  $details = @unserialize($this->getInfo()->getAdditionalData());
122
  if (is_array($details)) {
123
  $this->_payableTo = isset($details['payable_to']) ? (string) $details['payable_to'] : '';
124
  $this->_mailingAddress = isset($details['mailing_address']) ? (string) $details['mailing_address'] : '';
125
  $this->_return_url = isset($details['return_url']) ? (string) $details['return_url'] : '';
126
  $this->_checkout = isset($details['checkout']) ? (string) $details['checkout'] : '';
127
  $this->_merchantID = isset($details['merchantID']) ? (string) $details['merchantID'] : '';
128
  $this->_secure_code = isset($details['secure_code']) ? (string) $details['secure_code'] : '';
129
 
130
  } else {
131
  $this->_payableTo = '';
132
  $this->_mailingAddress = '';
133
  $this->_return_url = '';
134
  $this->_checkout = '';
135
  $this->_merchantID = '';
136
  $this->_secure_code = '';
137
  }
138
  return $this;
139
  }
140
 
141
  /**
142
  * Override default toPdf() function to return the FuturePay info template
143
  * as HTML
144
  *
145
  * @return string
146
  */
147
  public function toPdf() {
148
  $this->setTemplate('futurepay/info/futurepay.phtml');
149
  return $this->toHtml();
150
  }
app/code/community/FuturePay/FuturePay/Block/Process.php DELETED
@@ -1 +0,0 @@
1
- <?php
 
app/code/community/FuturePay/FuturePay/Helper/Data.php CHANGED
@@ -1,67 +1,24 @@
1
  <?php
2
 
3
-
4
-
5
- class FuturePay_FuturePay_Helper_Data extends Mage_Core_Helper_Abstract
6
-
7
- {
8
-
9
- public function isSandboxMode(){
10
-
11
- return Mage::getStoreConfig('payment/futurepay/is_sandbox_mode');
12
-
13
- }
14
-
15
-
16
-
17
- /**
18
-
19
- * Get API Url
20
-
21
- */
22
-
23
- public function getApiUrl(){
24
-
25
- return $this->isSandboxMode()?Mage::getStoreConfig('payment/futurepay/sandbox_checkout_url'):Mage::getStoreConfig('payment/futurepay/checkout_url');
26
-
27
- }
28
-
29
-
30
-
31
-
32
-
33
- /**
34
-
35
- * Get cart integration url
36
-
37
- */
38
-
39
- public function getCartIntegrationUrl(){
40
-
41
- return $this->isSandboxMode()?Mage::getStoreConfig('payment/futurepay/sandbox_cart_integration'):Mage::getStoreConfig('payment/futurepay/cart_integration');
42
-
43
- }
44
-
45
-
46
-
47
- /**
48
-
49
- * Get order verification url
50
-
51
- */
52
-
53
- public function getOrderVerificationUrl(){
54
-
55
- return $this->isSandboxMode()?Mage::getStoreConfig('payment/futurepay/sandbox_order_verification_url'):Mage::getStoreConfig('payment/futurepay/order_verification_url');
56
-
57
- }
58
-
59
- /**
60
- *Get is Auto Create Invoice
61
- */
62
-
63
- public function autoCreateInvoice(){
64
- return Mage::getStoreConfig('payment/futurepay/auto_invoice');
65
- }
66
 
67
  }
1
  <?php
2
 
3
+ class FuturePay_FuturePay_Helper_Data extends Mage_Core_Helper_Abstract {
4
+
5
+
6
+ /**
7
+ * Returns 1 if FuturePay is configured for Sandbox mode, or 0 if it's not
8
+ *
9
+ * @return int
10
+ */
11
+ public function isSandboxMode() {
12
+ return Mage::getStoreConfig('payment/futurepay/is_sandbox_mode');
13
+ }
14
+
15
+
16
+ /**
17
+ * Returns 1 if FuturePay is configured to auto-create invoices, or 0 if
18
+ * it's not
19
+ */
20
+ public function autoCreateInvoice() {
21
+ return Mage::getStoreConfig('payment/futurepay/auto_invoice');
22
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  }
app/code/community/FuturePay/FuturePay/Model/Method/Futurepay.php CHANGED
@@ -1,109 +1,120 @@
1
  <?php
2
- class FuturePay_FuturePay_Model_Method_FuturePay extends Mage_Payment_Model_Method_Abstract
3
- {
4
 
5
- protected $_code = 'futurepay';
 
 
6
  protected $_formBlockType = 'futurepay/form_futurepay';
7
  protected $_infoBlockType = 'futurepay/info_futurepay';
8
  protected $_canAuthorize = true;
9
  protected $_canRefund = true;
10
  protected $_canRefundInvoicePartial = true;
11
  protected $_canCapture = true;
12
-
 
 
 
 
 
 
 
 
13
  public function refund(\Varien_Object $payment, $amount) {
14
-
15
- // Setup curl request:
 
 
16
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
17
  $requestHost = 'sandbox.futurepay.com';
18
  } else {
19
  $requestHost = 'api.futurepay.com';
20
  }
 
21
  $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
22
- $address = 'https://' . $requestHost . '/remote/merchant-returns';
23
- $postDataArray = array();
24
- $postDataArray['api_version'] = '2';
25
- $postDataArray['PlatformId'] = '302';
26
- $postDataArray['gmid'] = $GMID;
27
- // Returned in the JavaScript Response from a successful purchase
28
- $postDataArray['order_action'] = 'refund';
29
- //$postDataArray['reference'] = get_object_vars($payment)['_data']['refund_transaction_id'];
30
- //$postDataArray['reference'] = get_object_vars($payment)['_data']['entity_id'];
31
- $postDataArray['reference'] = $payment->getOrder()->getIncrementId();
32
-
33
- $postDataArray['description'] = 'Retailer Refunded: #' . $payment->getOrder()->getIncrementId();
34
- $postDataArray['total_price'] = (float)$amount;
35
- //$postDataArray['amount'] = $amount;
36
 
 
 
 
 
 
 
 
 
37
  $postdata = http_build_query($postDataArray);
38
 
39
- // Create CURL request to the server
40
- $hash = base64_encode(hash_hmac('sha256', time() . FP_API_KEY . FP_SECRET, FP_API_KEY, true));
41
  $ch = curl_init();
42
  curl_setopt($ch, CURLOPT_URL, $address);
43
  curl_setopt($ch, CURLOPT_POST, 1);
44
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
45
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
46
- curl_setopt($cr, CURLOPT_HTTPHEADER, array(
47
- 'api_key: ' . FP_SECRET,
48
- "signature: $hash"
 
49
  ));
50
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
51
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
52
 
53
  // Receive response from FuturePay
54
- $server_output = curl_exec ($ch);
 
55
 
56
- // Close the connection socket
57
  curl_close($ch);
58
-
59
- // Use the server output to handle error responses
60
- // (success response should continue through the existing workflow)
61
- //var_dump($server_output, $postDataArray);
62
 
63
- // they'll either return a success or error.. hopefully...
64
-
65
- // if there was an error, do this (faye might want it changed, but for now...):
66
- $responseStatus = get_object_vars(json_decode($server_output))['status'];
67
-
68
- if ($responseStatus != 'FP_REFUND_SUCCESSFUL') {
69
- //$fpErrorCode = 'FP0000069';
70
- $fpErrorMessage = $responseStatus;
71
- $errorMsg = $this->_getHelper()->__("Refund failed: {$fpErrorMessage}");
72
  Mage::throwException($errorMsg);
73
- }
74
-
75
- // just leave this here.. if there were no errors above, this will run
76
- return parent::refund($payment, $amount);
 
 
 
 
 
 
77
 
78
-
79
- }
80
-
81
-
82
- public function assignData($data)
83
- {
84
- $details = array();
85
- if($this->getCheckout()){
86
- $details['checkout']=$this->getCheckout();
87
- }
88
- if (!empty($details)) {
89
- $this->getInfoInstance()->setAdditionalData(serialize($details));
90
  }
91
- return $this;
92
- }
93
 
94
- public function getCheckout()
95
- {
96
- return $this->getConfigData('checkout_url');
97
  }
98
-
99
-
100
  /**
101
- * Return Order place redirect url
102
  *
103
  * @return string
104
  */
105
- public function getOrderPlaceRedirectUrl()
106
- {
107
- return Mage::getUrl('futurepay/index/process');
108
- } public function isAvailable($quote = null){ $countryCode = $quote->getBillingAddress()->getCountry(); $isAvailable = ($countryCode == 'US'); return $isAvailable && parent::isAvailable($quote); }
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
1
  <?php
 
 
2
 
3
+ class FuturePay_FuturePay_Model_Method_FuturePay extends Mage_Payment_Model_Method_Abstract {
4
+
5
+ protected $_code = 'futurepay';
6
  protected $_formBlockType = 'futurepay/form_futurepay';
7
  protected $_infoBlockType = 'futurepay/info_futurepay';
8
  protected $_canAuthorize = true;
9
  protected $_canRefund = true;
10
  protected $_canRefundInvoicePartial = true;
11
  protected $_canCapture = true;
12
+
13
+ /**
14
+ * Perform a refund
15
+ *
16
+ * @param \Varien_Object $payment
17
+ * @param float $amount
18
+ * @throws Mage_Core_Exception
19
+ * @return Mage_Payment_Model_Method_Abstract
20
+ */
21
  public function refund(\Varien_Object $payment, $amount) {
22
+
23
+
24
+ // this value is set in:
25
+ // Magento Admin > Configuration > Payment Methods > FuturePay
26
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
27
  $requestHost = 'sandbox.futurepay.com';
28
  } else {
29
  $requestHost = 'api.futurepay.com';
30
  }
31
+
32
  $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
33
+ $fpMerchantId = trim(substr($GMID, 40, 45));
34
+
35
+ $address = 'https://' . $requestHost . '/api/order';
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ // build the request
38
+ $postDataArray = array(
39
+ 'order_action' => 'refund',
40
+ 'reference' => $payment->getOrder()->getIncrementId(),
41
+ 'order_description' => 'Retailer Refunded: #' . $payment->getOrder()->getIncrementId(),
42
+ 'amount' => (float) $amount,
43
+ );
44
+
45
  $postdata = http_build_query($postDataArray);
46
 
47
+ // send the refund request to FuturePay
48
+ $hash = base64_encode(hash_hmac('sha256', time() . $GMID . $fpMerchantId, $GMID, true));
49
  $ch = curl_init();
50
  curl_setopt($ch, CURLOPT_URL, $address);
51
  curl_setopt($ch, CURLOPT_POST, 1);
52
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
53
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
54
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Magento/FuturePay Plugin v2.0');
55
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
56
+ 'api_key: ' . $fpMerchantId,
57
+ 'signature: ' . $hash,
58
  ));
59
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
60
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
61
 
62
  // Receive response from FuturePay
63
+ $serverResponse = curl_exec($ch);
64
+ $curlError = curl_error($ch);
65
 
 
66
  curl_close($ch);
 
 
 
 
67
 
68
+ // empty response typically means a curl error. report it!
69
+ if (strlen($serverResponse) < 1) {
70
+ // get the curl error and display to the merchant. this error isn't
71
+ // customer-facing, so it's okay to display technical errors here
72
+ $errorMsg = $this->_getHelper()->__("Refund failed: {$curlError}");
 
 
 
 
73
  Mage::throwException($errorMsg);
74
+ } else {
75
+ // the response from FuturePay should be a json object
76
+ $serverResponseArray = json_decode($serverResponse, true);
77
+ if (is_array($serverResponseArray)) {
78
+
79
+ if ($serverResponseArray['status'] != 1) {
80
+ // FP is reporting an error
81
+ $fpErrorMessage = "{$serverResponseArray['code']} {$serverResponseArray['message']}";
82
+ Mage::throwException("Refund failed: {$fpErrorMessage}");
83
+ }
84
 
85
+ } else {
86
+ // report the contents of the server's response body as an error
87
+ // message
88
+ Mage::throwException("Refund failed: {$serverResponse}");
89
+ }
90
+
 
 
 
 
 
 
91
  }
 
 
92
 
93
+ // after successfully requesting the refund from FuturePay, continue
94
+ // with the default refund process
95
+ return parent::refund($payment, $amount);
96
  }
97
+
 
98
  /**
99
+ * Returns the URL to the process controller
100
  *
101
  * @return string
102
  */
103
+ public function getOrderPlaceRedirectUrl() {
104
+ return Mage::getUrl('futurepay/index/process');
105
+ }
106
+
107
+ /**
108
+ * Returns true if FuturePay is available as a payment method. To meet this
109
+ * criteria, the customer's billing address must be in the US.
110
+ *
111
+ * @param Mage_Sales_Model_Quote $quote
112
+ * @return boolean
113
+ */
114
+ public function isAvailable($quote = null) {
115
+ $countryCode = $quote->getBillingAddress()->getCountry();
116
+ $isAvailable = ($countryCode == 'US');
117
+ return $isAvailable && parent::isAvailable($quote);
118
+ }
119
+
120
  }
app/code/community/FuturePay/FuturePay/Model/Observer.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
-
3
- class FuturePay_FuturePay_Model_Observer
4
- {
5
- public function checkTransactionStatus(){
6
- $transactions = Mage::getModel('sales/order_payment_transaction')->getCollection();
7
- foreach($transactions as $trans){
8
- if($trans->getOrderPaymentObject()->getMethod() == 'futurepay'){
9
- $txnId = $trans->getTxnId();
10
- $serverResult = $this->_call_fp_api_get_order_token($txnId);
11
- if($serverResult){
12
- $serverResult = json_decode($serverResult,true);
13
- $orderStatusCode = isset($serverResult['OrderStatusCode'])?$serverResult['OrderStatusCode']:false;
14
- /*Do something here*/
15
- }
16
- }
17
- }
18
- }
19
- protected function _call_fp_api_get_order_token($order_transaction_id) {
20
- // Setup curl request:
21
- $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
22
-
23
- $postDataArray = array();
24
- $postDataArray['gmid'] = $GMID;
25
- // Returned in the JavaScript Response from a successful purchase
26
- $postDataArray['otxnid'] = $order_transaction_id;
27
-
28
- $postdata = http_build_query($postDataArray);
29
-
30
- //create CURL request to the server
31
- $ch = curl_init();
32
-
33
- curl_setopt($ch, CURLOPT_URL,Mage::helper('futurepay')->getOrderVerificationUrl());
34
- curl_setopt($ch, CURLOPT_POST, 1);
35
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
36
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
37
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
38
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
39
-
40
- //receive response from FuturePay
41
- $server_output = curl_exec ($ch);
42
-
43
- //close the connection socket
44
- curl_close($ch);
45
-
46
- return $server_output;
47
- }
48
-
49
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/FuturePay/FuturePay/Model/Resource/Setup.php CHANGED
@@ -2,11 +2,32 @@
2
 
3
  class FuturePay_FuturePay_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
4
 
5
- public function endFpSetup()
6
- {
7
- $messageContent = "Extension: FuturePay\r\nVersion: 2.0.0\r\nWebsite: " . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  mail('fmceachern@futurepay.com', 'Magento Install Notification', $messageContent);
9
- $this->endSetup();
10
  }
11
 
 
 
 
 
12
  }
2
 
3
  class FuturePay_FuturePay_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
4
 
5
+ // set this to false if you would *not* like to notify FuturePay
6
+ const NOTIFY_FUTUREPAY_ON_INSTALL = true;
7
+
8
+
9
+ /**
10
+ * This function will notify FuturePay when this extension has been
11
+ * installed. This can be disabled by setting the class constant
12
+ * "NOTIFY_FUTUREPAY_ON_INSTALL" (above) to FALSE.
13
+ *
14
+ * @return void
15
+ */
16
+ public function endFpSetup() {
17
+ if (FuturePay_FuturePay_Model_Resource_Setup::NOTIFY_FUTUREPAY_ON_INSTALL) {
18
+
19
+ $websiteUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
20
+ $extensionVersion = Mage::getConfig()->getNode()->modules->FuturePay_FuturePay->version;
21
+ $messageContent = <<<TXT
22
+ Extension: FuturePay
23
+ Version: {$extensionVersion}
24
+ Website: {$websiteUrl}
25
+ TXT;
26
  mail('fmceachern@futurepay.com', 'Magento Install Notification', $messageContent);
 
27
  }
28
 
29
+ // end the default set up as
30
+ $this->endSetup();
31
+ }
32
+
33
  }
app/code/community/FuturePay/FuturePay/Model/Source/Order/Status.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
 
2
  class FuturePay_FuturePay_Model_Source_Order_Status
3
  {
4
- static public function toOptionArray()
5
- {
6
  return array(
7
- '' => '',
8
- 'pending' => Mage::helper('futurepay')->__('Pending'),
9
  );
10
  }
 
11
  }
1
  <?php
2
+
3
  class FuturePay_FuturePay_Model_Source_Order_Status
4
  {
5
+
6
+ static public function toOptionArray() {
7
  return array(
8
+ '' => '',
9
+ 'pending' => Mage::helper('futurepay')->__('Pending'),
10
  );
11
  }
12
+
13
  }
app/code/community/FuturePay/FuturePay/Model/Source/Payment/Action.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
 
2
  class FuturePay_FuturePay_Model_Source_Payment_Action
3
  {
4
- static public function toOptionArray()
5
- {
6
  return array(
7
- 'Sale' => 'Sale',
8
- 'Authorization' => Mage::helper('futurepay')->__('Authorization'),
9
  );
10
  }
 
11
  }
1
  <?php
2
+
3
  class FuturePay_FuturePay_Model_Source_Payment_Action
4
  {
5
+
6
+ static public function toOptionArray() {
7
  return array(
8
+ 'Sale' => 'Sale',
9
+ 'Authorization' => Mage::helper('futurepay')->__('Authorization'),
10
  );
11
  }
12
+
13
  }
app/code/community/FuturePay/FuturePay/Model/Source/Title/Custom.php CHANGED
@@ -1,11 +1,13 @@
1
  <?php
 
2
  class FuturePay_FuturePay_Model_Source_Title_Custom
3
  {
4
- static public function toOptionArray()
5
- {
6
  return array(
7
- '0' => 'Default',
8
- '1' => 'Custom',
9
  );
10
  }
 
11
  }
1
  <?php
2
+
3
  class FuturePay_FuturePay_Model_Source_Title_Custom
4
  {
5
+
6
+ static public function toOptionArray() {
7
  return array(
8
+ '0' => 'Default',
9
+ '1' => 'Custom',
10
  );
11
  }
12
+
13
  }
app/code/community/FuturePay/FuturePay/controllers/IndexController.php CHANGED
@@ -1,92 +1,118 @@
1
  <?php
2
  class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Action
3
  {
4
-
5
- //const USE_FUTUREPAY_SANDBOX = true;
6
-
7
- /**
8
  * Get one page checkout model
9
  *
10
  * @return Mage_Checkout_Model_Type_Onepage
11
  */
12
- public function getOnepage()
13
- {
14
  return Mage::getSingleton('checkout/type_onepage');
15
  }
16
-
17
- // @debug
18
- public function getFPTokenAction()
19
- {
20
- var_dump(Mage::getSingleton('core/session')->getFpToken());
21
- exit;
22
- }
23
-
24
- public function storeFPTokenAction()
25
- {
 
26
  // store the token
27
  $request = $this->getRequest()->getParams();
28
- if (isset($request['token'])
29
- && strlen($request['token']) > 0) {
30
  Mage::getSingleton('core/session')->setFpToken($request['token']);
31
  }
32
  }
33
-
34
- public function getSignupLoginFormAction()
35
- {
 
 
 
 
 
36
  $this->loadLayout();
37
  $this->renderLayout();
38
  }
 
39
 
40
- public function getMerchantLoginFormAction()
41
- {
42
- //$fpData = Mage::helper('futurepay/data'); // @debug
 
 
 
 
43
  $this->loadLayout();
44
  $this->renderLayout();
45
  }
 
46
 
47
- public function getMerchantSignupFormAction()
48
- {
 
 
 
 
 
49
  $this->loadLayout();
50
  $this->renderLayout();
51
  }
 
52
 
53
- public function doMerchantLoginAction()
54
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  $request = $this->getRequest()->getParams();
56
- if (strlen($request['user_name']) > 0
57
- && strlen($request['password']) > 0) {
58
-
59
- // send the request to futurepay
60
- set_time_limit(0);
61
- ini_set('max_execution_time', 300); // 5 minutes, which is overkill.
62
  $request['user_name'] = urlencode($request['user_name']);
63
  $request['password'] = urlencode($request['password']);
64
-
65
- /*if (self::USE_FUTUREPAY_SANDBOX) {
66
- $request_host = 'demo.futurepay.com';
67
- } else {
68
- $request_host = 'api.futurepay.com';
69
- }*/
70
-
71
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
72
  $requestHost = 'sandbox.futurepay.com';
73
  } else {
74
  $requestHost = 'api.futurepay.com';
75
  }
76
-
 
77
  $requestUrl = "https://{$requestHost}/remote/merchant-request-key?type=retrieve"
78
- . "&user_name={$_POST['user_name']}"
79
- . "&password={$_POST['password']}";
80
-
 
81
  if (filter_var($requestUrl, FILTER_VALIDATE_URL)) {
82
 
 
 
 
83
  $ch = curl_init($requestUrl);
84
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
85
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
86
- curl_setopt($ch, CURLOPT_USERAGENT, 'Magento/FuturePay Plugin v1.0');
87
  $result = curl_exec($ch);
88
- // if the connection failed, report it back to the browser, otherwise
89
- // pass the json object back.
 
90
  if ($result !== false) {
91
  $this->getResponse()->setHeader('Content-type', 'application/json');
92
  $this->getResponse()->setBody($result);
@@ -98,7 +124,9 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
98
  )));
99
  }
100
  curl_close($ch);
 
101
  } else {
 
102
  $this->getResponse()->setHeader('Content-type', 'application/json');
103
  $this->getResponse()->setBody(json_encode(array(
104
  'error' => 1,
@@ -107,31 +135,44 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
107
  }
108
  }
109
  }
110
-
111
- public function doMerchantSignupAction()
112
- {
113
-
 
 
 
 
 
 
 
 
 
 
 
 
114
  $request = $this->getRequest()->getParams();
115
-
116
- set_time_limit(0);
117
- ini_set('max_execution_time', 300); // 5 minutes, which is overkill.
118
 
119
- /*if (self::USE_FUTUREPAY_SANDBOX) {
120
- $requestHost = 'demo.futurepay.com';
121
- } else {
122
- $requestHost = 'api.futurepay.com';
123
- }*/
124
-
125
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
126
  $requestHost = 'sandbox.futurepay.com';
127
  } else {
128
  $requestHost = 'api.futurepay.com';
129
  }
130
 
131
- unset($request['isAjax']);
132
- unset($request['form_key']);
133
- $request['type'] = 'signup';
 
 
 
 
 
134
 
 
 
 
135
  // remove 'futurepay_' from the beginning of form field names
136
  $tempRequest = $request;
137
  foreach ($tempRequest as $k => $v) {
@@ -139,17 +180,23 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
139
  $k = str_replace('futurepay_', '', $k);
140
  $request[$k] = $v;
141
  }
142
-
 
143
  $queryString = http_build_query($request);
144
  $requestUrl = "https://{$requestHost}/remote/merchant-request-key?{$queryString}";
145
 
 
146
  if (filter_var($requestUrl, FILTER_VALIDATE_URL)) {
147
 
 
 
 
148
  $ch = curl_init($requestUrl);
149
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
150
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
151
- curl_setopt($ch, CURLOPT_USERAGENT, 'Magento/FuturePay Plugin v1.0');
152
  $result = curl_exec($ch);
 
153
  // if the connection failed, report it back to the browser, otherwise
154
  // pass the json object back.
155
  if ($result !== false) {
@@ -163,7 +210,9 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
163
  )));
164
  }
165
  curl_close($ch);
 
166
  } else {
 
167
  $this->getResponse()->setHeader('Content-type', 'application/json');
168
  $this->getResponse()->setBody(json_encode(array(
169
  'error' => 1,
@@ -171,103 +220,39 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
171
  )));
172
  }
173
  }
 
174
 
175
- public function getCountryRegionsAction()
176
- {
 
 
 
 
 
177
  $regionList = Mage::getModel('directory/region')
178
- ->getResourceCollection()
179
- ->addCountryFilter($this->getRequest()->getParam('country'))
180
- ->load()
181
- ->toArray();
182
  $this->getResponse()->setHeader('Content-type', 'application/json');
183
  $this->getResponse()->setBody(json_encode($regionList));
184
  }
 
185
 
186
- // protected function callFpApiGetOrderToken(Mage_Sales_Model_Order $order) {
187
- // //setup curl request:
188
- // $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
189
- //
190
- // // Platform Merchant Identifier
191
- // $PMID = Mage::getStoreConfig('payment/futurepay/pmid');
192
- //
193
- // $postDataArray = array();
194
- // $postDataArray['gmid'] = $GMID;
195
- // $postDataArray['pmid'] = $PMID;
196
- // $postDataArray['reference'] = $order->getIncrementId(); /*order id*/
197
- // $billing = $order->getBillingAddress();
198
- // /*billing information*/
199
- // $postDataArray['email'] = $order->getCustomerEmail();
200
- // $postDataArray['first_name'] = $billing->getFirstname();
201
- // $postDataArray['last_name'] = $billing->getLastname();
202
- // $postDataArray['address_line_1'] = $billing->getStreet(1);
203
- // $postDataArray['address_line_2'] = $billing->getStreet(2);
204
- // $postDataArray['city'] = $billing->getCity();
205
- // $postDataArray['state'] = $billing->getRegionCode();
206
- // $postDataArray['country'] = $billing->getCountry();
207
- // $postDataArray['zip'] = $billing->getPostcode();
208
- // $postDataArray['phone'] = $billing->getTelephone();
209
- //
210
- // if(!$order->getIsVirtual()){
211
- // $shipping = $order->getShippingAddress();
212
- // $postDataArray['shipping_address_line_1'] = $shipping->getStreet(1);
213
- // $postDataArray['shipping_address_line_2'] = $shipping->getStreet(2);
214
- // $postDataArray['shipping_city'] = $shipping->getCity();
215
- // $postDataArray['shipping_state'] = $shipping->getRegionCode();
216
- // $postDataArray['shipping_country'] = $shipping->getCountry();
217
- // $postDataArray['shipping_zip'] = $shipping->getPostcode();
218
- //
219
- // }
220
- // /*foreach($order->getAllVisibleItems() as $item){
221
- // $postDataArray['sku'][] = $item->getSku(); // FEDEX SKU
222
- // $postDataArray['price'][] = $item->getPrice(); // Shipping Cost
223
- // $postDataArray['tax_amount'][] = $item->getTaxAmount(); // Must be zero
224
- // $postDataArray['description'][] = $item->getName();
225
- // $postDataArray['quantity'][] = intval($item->getQtyOrdered());
226
- // }*/
227
- // $postDataArray['sku'][] = $order->getIncrementId(); // Order Increment ID
228
- // $postDataArray['price'][] = Mage::helper('directory')->currencyConvert($order->getBaseGrandTotal(),$order->getBaseCurrencyCode(),'USD'); // Grand Total
229
- // $postDataArray['tax_amount'][] = 0; // Must be zero
230
- // $postDataArray['description'][] = Mage::helper('futurepay')->__('Payment for order #%s',$order->getIncrementId());
231
- // $postDataArray['quantity'][] = 1;
232
- // // Continued --------------------------------
233
- // $postdata = http_build_query($postDataArray);
234
- //
235
- // //create CURL request to the server
236
- // $ch = curl_init();
237
- //
238
- // curl_setopt($ch, CURLOPT_URL,Mage::helper('futurepay')->getApiUrl());
239
- // curl_setopt($ch, CURLOPT_POST, 1);
240
- // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
241
- // curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
242
- // curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
243
- // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
244
- //
245
- // //receive response from FuturePay
246
- // $server_output = curl_exec ($ch);
247
- //
248
- // //close the connection socket
249
- // curl_close($ch);
250
- // // If the $server_ouput starts with FPTK followed by a hashed string
251
- // // Then the call to create a pre-order has been successful
252
- // // Otherwise there will be an error response code that is defined in
253
- // // The error code table of this document
254
- // if(strpos($server_output, "FPTK")) {
255
- // // Push the token to the javascript request on the cart
256
- // return $server_output;
257
- // }else{
258
- // throw new FuturePay_FuturePay_Exception($server_output);
259
- // }
260
- // return false;
261
- // }
262
-
263
- public function processAction() {
264
- // PAGE 8 STARTS HERE
265
- //die();
266
  if (!$this->getOnepage()->getCheckout()->getLastSuccessQuoteId()) {
267
  $this->_redirect('checkout/cart');
268
  return;
269
  }
270
- $lastQuoteId = $this->getOnepage()->getCheckout()->getLastQuoteId();
271
  $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
272
  $order = Mage::getModel('sales/order')->load($lastOrderId);
273
  Mage::register('current_order', $order);
@@ -276,15 +261,12 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
276
 
277
  // this token was stored in storeFPTokenAction()
278
  $token = Mage::getSingleton('core/session')->getFpToken();
279
-
280
  if ($token) {
281
-
282
- //define('FP_API_KEY', Mage::getStoreConfig('payment/futurepay/gmid'));
283
- //define('FP_SECRET', Mage::getStoreConfig('payment/futurepay/merchant_id'));
284
  $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
285
  $fpMerchantId = trim(substr($GMID, 40, 45));
286
-
287
- //header('Content-Type: application/json');
288
  $postData = array(
289
  'api_version' => '2',
290
  'order_action' => 'capture',
@@ -292,272 +274,121 @@ class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Act
292
  'PlatformId' => '302',
293
  'reference' => $order->getIncrementId(),
294
  'amount' => $order->getGrandTotal(),
295
- //'order_tag' => '',
296
  'order_description' => Mage::helper('futurepay')->__('Payment for order #%s', $order->getIncrementId()),
297
  'soft_descriptor' => Mage::app()->getStore()->getName(),
298
- //'merchant_id' => '',
299
  'shipping_cost' => $order->getShippingAmount(),
300
  'shipping_address' => "{$order->getShippingAddress()->getStreet(1)}\n{$order->getShippingAddress()->getStreet(2)}",
301
  'shipping_zip' => $order->getShippingAddress()->getPostcode(),
302
  'shipping_country' => $order->getShippingAddress()->getCountry(),
303
- // commented out because if we don't have it, we need to omit
304
- // it
305
- //'shipping_region' => $order->getShippingAddress()->getRegionCode(),
306
  'subscription' => 0,
307
  'billing_address' => "{$order->getBillingAddress()->getStreet(1)}\n{$order->getBillingAddress()->getStreet(2)}",
308
  'billing_zip' => $order->getBillingAddress()->getPostcode(),
309
  'billing_country' => $order->getBillingAddress()->getCountry(),
310
- 'billing_region' => $order->getBillingAddress()->getRegionCode(),
311
  );
 
312
 
 
 
 
313
  $shippingRegionCode = $order->getShippingAddress()->getRegionCode();
 
 
314
  if (strlen($shippingRegionCode) == 2) {
315
  $postData['shipping_region'] = $shippingRegionCode;
316
  }
317
- $testPostData = $postData;
 
 
 
 
318
  $postData = http_build_query($postData);
319
 
 
 
320
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
321
  $requestHost = "sandbox.futurepay.com";
322
  } else {
323
  $requestHost = "api.futurepay.com";
324
  }
325
-
326
  $hash = base64_encode(hash_hmac('sha256', time() . $GMID . $fpMerchantId, $GMID, true));
 
327
  $cr = curl_init("https://" . $requestHost . "/api/order");
328
  curl_setopt($cr, CURLOPT_POST, true);
329
  curl_setopt($cr, CURLOPT_POSTFIELDS, $postData);
330
  curl_setopt($cr, CURLOPT_HTTPHEADER, array(
331
- 'api_key: ' . $fpMerchantId,
332
- "signature: $hash"
333
  ));
 
334
  curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
335
  $response = curl_exec($cr);
336
 
337
- if (!$response)
 
 
338
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not valid'));
 
 
 
339
  $serverResult = json_decode($response, true);
340
 
341
  if (!is_array($serverResult)) {
 
 
 
342
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted'));
343
  } elseif ($serverResult['status'] != 1) {
 
 
344
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted: ' . $serverResult['message']));
345
  }
 
 
346
  $capturedAmount = $serverResult['object']['order_total'];
347
 
 
348
  $txtId = $serverResult['object']['transaction_references'][0];
349
 
350
-
351
- // testing
352
  $payment = $order->getPayment();
353
  $payment->setTransactionId($txtId)
354
- ->setCurrencyCode($order->getBaseCurrencyCode())
355
- ->setPreparedMessage('')
356
- ->setParentTransactionId($txtId)
357
- ->setShouldCloseParentTransaction(true)
358
- ->setIsTransactionClosed(1);
359
- //->registerCaptureNotification($capturedAmount);
360
- //$order->save();
361
-
362
 
363
-
364
-
365
-
366
-
367
- /* Save the transaction and create invoice */
368
- // $payment = $order->getPayment();
369
- // $payment->setTransactionId($txtId)
370
- // ->setPreparedMessage('')
371
- // ->setIsTransactionClosed(0)
372
- ;
373
  if (Mage::helper('futurepay')->autoCreateInvoice()) {
374
  $payment->registerCaptureNotification($capturedAmount);
375
- $order->save();
376
  // notify customer
377
  $invoice = $payment->getCreatedInvoice();
378
  if ($invoice && !$order->getEmailSent()) {
379
  $order->sendNewOrderEmail()->addStatusHistoryComment(
380
  Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
381
  )
382
- ->setIsCustomerNotified(true)
383
- ->save();
384
  }
385
  } else {
386
  $payment->registerAuthorizationNotification($capturedAmount);
387
  if (!$order->getEmailSent()) {
388
  $order->sendNewOrderEmail();
389
  }
390
- $order->save();
391
  }
392
-
 
 
393
  $this->_redirect('checkout/onepage/success');
 
 
 
394
  }
395
  } catch (Exception $e) {
 
 
396
  Mage::getSingleton('checkout/session')->addError($e->getMessage());
397
- //$order->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)->save();
398
  $this->_redirect('checkout/cart');
399
  }
400
  }
401
 
402
- /**
403
- * Cancel action
404
- */
405
- public function cancelAction(){
406
- $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
407
- Mage::getSingleton('checkout/session')->addError(Mage::helper('futurepay')->__('Your order has been canceled'));
408
- $order = Mage::getModel('sales/order')->load($lastOrderId);
409
- $order->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)->save();
410
- $this->_redirect('checkout/cart');
411
- }
412
-
413
- /**
414
- * Error action
415
- */
416
- public function errorAction(){
417
- $errorCode = $this->getRequest()->getParam('error_code');
418
- $errorReason = $this->getRequest()->getParam('error_reason');
419
- if($errorCode){
420
- Mage::getSingleton('checkout/session')->addError(Mage::helper('futurepay')->__($errorReason));
421
- }else{
422
- Mage::getSingleton('checkout/session')->addError(Mage::helper('futurepay')->__('There is an error occurred we cannot process your order'));
423
- }
424
- /*$lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
425
- $order = Mage::getModel('sales/order')->load($lastOrderId);
426
- $order->setStatus(Mage_Sales_Model_Order::STATE_CANCELED)->save();*/
427
- $this->_redirect('checkout/cart');
428
- }
429
- /**
430
- * Success action
431
- */
432
- /*public function successAction(){
433
- $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
434
- $order = Mage::getModel('sales/order')->load($lastOrderId);
435
-
436
- try{
437
- $transaction = Mage::getModel('sales/order_payment_transaction');
438
- $txtId = $this->getRequest()->getParam('transaction_id');
439
- if(!$txtId) throw new Exception(Mage::helper('futurepay')->__('The transaction is not valid'));
440
-
441
- /*Check if the transaction is success*/
442
- /*$serverResult = $this->_call_fp_api_get_order_token($txtId);
443
- if(!$serverResult) throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not valid'));
444
-
445
- $serverResult = json_decode($serverResult,true);
446
- if(!is_array($serverResult) || $serverResult['OrderStatusCode'] != 'ACCEPTED') throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted'));
447
-
448
- $capturedAmount = $serverResult['t.TotalPrice'];
449
-
450
- /*Save the transaction and create invoice*/
451
- /*$payment = $order->getPayment();
452
- $payment->setTransactionId($txtId)
453
- ->setPreparedMessage('')
454
- ->setIsTransactionClosed(0)
455
- ;
456
- if(Mage::helper('futurepay')->autoCreateInvoice()){
457
- $payment->registerCaptureNotification($capturedAmount);
458
- $order->save();
459
- // notify customer
460
- $invoice = $payment->getCreatedInvoice();
461
- if ($invoice && !$order->getEmailSent()) {
462
- $order->sendNewOrderEmail()->addStatusHistoryComment(
463
- Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
464
- )
465
- ->setIsCustomerNotified(true)
466
- ->save();
467
- }
468
- }else{
469
- $payment->registerAuthorizationNotification($capturedAmount);
470
- if (!$order->getEmailSent()) {
471
- $order->sendNewOrderEmail();
472
- }
473
- $order->save();
474
- }
475
-
476
-
477
-
478
-
479
-
480
- $result = array(
481
- 'sucecss' => true,
482
- 'url' => Mage::getUrl('checkout/onepage/success'),
483
- );
484
- $this->getResponse()->setBody(json_encode($result));
485
- }catch (Exception $e){
486
- Mage::getSingleton('checkout/session')->__($e->getMessage());
487
- $result = array(
488
- 'sucecss' => false,
489
- 'url' => Mage::getUrl('checkout/cart'),
490
- 'msg' => $e->getMessage(),
491
- );
492
- $this->getResponse()->setBody(json_encode($result));
493
- }
494
- }*/
495
-
496
- protected function _call_fp_api_get_order_token($order_transaction_id) {
497
- // Setup curl request:
498
- $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
499
- $postDataArray = array();
500
- $postDataArray['gmid'] = $GMID;
501
- // Returned in the JavaScript Response from a successful purchase
502
- $postDataArray['otxnid'] = $order_transaction_id;
503
- $postdata = http_build_query($postDataArray);
504
- //create CURL request to the server
505
- $ch = curl_init();
506
- curl_setopt($ch, CURLOPT_URL,Mage::helper('futurepay')->getOrderVerificationUrl());
507
- curl_setopt($ch, CURLOPT_POST, 1);
508
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
509
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
510
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
511
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
512
- //receive response from FuturePay
513
- $server_output = curl_exec ($ch);
514
-
515
- //close the connection socket
516
- curl_close($ch);
517
-
518
- return $server_output;
519
- }
520
-
521
- function _call_fp_refund_order($order_transaction_id) {
522
-
523
- // Setup curl request:
524
- if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
525
- $requestHost = 'sandbox.futurepay.com';
526
- } else {
527
- $requestHost = 'api.futurepay.com';
528
- }
529
- $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
530
- $address = 'https://' . $requestHost . '/remote/merchant-returns';
531
- $postDataArray = array();
532
- $postDataArray['gmid'] = $GMID;
533
- // Returned in the JavaScript Response from a successful purchase
534
- $postDataArray['reference'] = $order_transaction_id;
535
- $postDataArray['total_price'] = $refund_total;
536
-
537
- $postdata = http_build_query($postDataArray);
538
-
539
- // Create CURL request to the server
540
- $ch = curl_init();
541
- curl_setopt($ch, CURLOPT_URL, $address);
542
- curl_setopt($ch, CURLOPT_POST, 1);
543
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
544
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
545
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
546
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
547
-
548
- // Receive response from FuturePay
549
- $server_output = curl_exec ($ch);
550
-
551
- // Close the connection socket
552
- curl_close($ch);
553
-
554
- // Use the server output to handle error responses
555
- // (success response should continue through the existing workflow)
556
- return $server_output;
557
-
558
- }
559
-
560
- public function testAction(){
561
- Mage::getModel('futurepay/observer')->checkTransactionStatus();
562
- }
563
  }
1
  <?php
2
  class FuturePay_FuturePay_IndexController extends Mage_Core_Controller_Front_Action
3
  {
4
+
5
+ /**
 
 
6
  * Get one page checkout model
7
  *
8
  * @return Mage_Checkout_Model_Type_Onepage
9
  */
10
+ public function getOnepage() {
 
11
  return Mage::getSingleton('checkout/type_onepage');
12
  }
13
+
14
+ /**
15
+ * During the purchase process, FuturePay will return a token which
16
+ * represents a pre-authorization of funds within the customer's FuturePay
17
+ * account.
18
+ *
19
+ * This ajax endpoint stores this token within the customer's session.
20
+ *
21
+ * @return void
22
+ */
23
+ public function storeFPTokenAction() {
24
  // store the token
25
  $request = $this->getRequest()->getParams();
26
+ if (isset($request['token']) && strlen($request['token']) > 0) {
 
27
  Mage::getSingleton('core/session')->setFpToken($request['token']);
28
  }
29
  }
30
+
31
+ /**
32
+ * Render the Sign-up/Login template for the Admin interface
33
+ *
34
+ * @see app/design/frontend/base/default/template/futurepay/getsignuploginform.phtml
35
+ * @return void
36
+ */
37
+ public function getSignupLoginFormAction() {
38
  $this->loadLayout();
39
  $this->renderLayout();
40
  }
41
+
42
 
43
+ /**
44
+ * Render the Merchant Login template for the Admin interface
45
+ *
46
+ * @see app/design/frontend/base/default/template/futurepay/getmerchantloginform.phtml
47
+ * @return void
48
+ */
49
+ public function getMerchantLoginFormAction() {
50
  $this->loadLayout();
51
  $this->renderLayout();
52
  }
53
+
54
 
55
+ /**
56
+ * Render the Merchant Sign-up template for the Admin interface
57
+ *
58
+ * @see app/design/frontend/base/default/template/futurepay/getmerchantsignupform.phtml
59
+ * @return void
60
+ */
61
+ public function getMerchantSignupFormAction() {
62
  $this->loadLayout();
63
  $this->renderLayout();
64
  }
65
+
66
 
67
+ /**
68
+ * Retrieve the merchant's GMID (merchant ID) from FuturePay by email
69
+ * address and password.
70
+ *
71
+ * If is_sandbox_mode is set to 1, the call will be made to FuturePay's
72
+ * sandbox instance (sandbox.futurepay.com).
73
+ *
74
+ * This function will render a json response containing either the
75
+ * response from FuturePay or a generated response containing an error
76
+ * message.
77
+ *
78
+ * @return void
79
+ */
80
+ public function doMerchantLoginAction() {
81
+ //get the incoming request
82
  $request = $this->getRequest()->getParams();
83
+
84
+ if (strlen($request['user_name']) > 0 && strlen($request['password']) > 0) {
85
+
 
 
 
86
  $request['user_name'] = urlencode($request['user_name']);
87
  $request['password'] = urlencode($request['password']);
88
+
89
+ // this value is set in:
90
+ // Magento Admin > Configuration > Payment Methods > FuturePay
 
 
 
 
91
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
92
  $requestHost = 'sandbox.futurepay.com';
93
  } else {
94
  $requestHost = 'api.futurepay.com';
95
  }
96
+
97
+ // build the request URL
98
  $requestUrl = "https://{$requestHost}/remote/merchant-request-key?type=retrieve"
99
+ . "&user_name={$request['user_name']}"
100
+ . "&password={$request['password']}";
101
+
102
+ // make sure the request URL is valid
103
  if (filter_var($requestUrl, FILTER_VALIDATE_URL)) {
104
 
105
+ set_time_limit(0);
106
+ ini_set('max_execution_time', 300); // 5 minutes
107
+
108
  $ch = curl_init($requestUrl);
109
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
110
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
111
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Magento/FuturePay Plugin v2.x');
112
  $result = curl_exec($ch);
113
+
114
+ // if the connection failed, report it back to the browser,
115
+ // otherwise pass the json object back.
116
  if ($result !== false) {
117
  $this->getResponse()->setHeader('Content-type', 'application/json');
118
  $this->getResponse()->setBody($result);
124
  )));
125
  }
126
  curl_close($ch);
127
+
128
  } else {
129
+ // the request URL did not validate
130
  $this->getResponse()->setHeader('Content-type', 'application/json');
131
  $this->getResponse()->setBody(json_encode(array(
132
  'error' => 1,
135
  }
136
  }
137
  }
138
+
139
+ /**
140
+ * Retrieve the merchant's GMID (merchant ID) from FuturePay by email
141
+ * address and password.
142
+ *
143
+ * If is_sandbox_mode is set to 1, the call will be made to FuturePay's
144
+ * sandbox instance (sandbox.futurepay.com).
145
+ *
146
+ * This function will render a json response containing either the
147
+ * response from FuturePay or a generated response containing an error
148
+ * message.
149
+ *
150
+ * @return void
151
+ */
152
+ public function doMerchantSignupAction() {
153
+
154
  $request = $this->getRequest()->getParams();
 
 
 
155
 
156
+ // this value is set in:
157
+ // Magento Admin > Configuration > Payment Methods > FuturePay
 
 
 
 
158
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
159
  $requestHost = 'sandbox.futurepay.com';
160
  } else {
161
  $requestHost = 'api.futurepay.com';
162
  }
163
 
164
+ // these parameters are *sometimes* added to the request by magento
165
+ // unset them if they exist - they're not needed
166
+ if (isset($request['isAjax'])) {
167
+ unset($request['isAjax']);
168
+ }
169
+ if (isset($request['form_key'])) {
170
+ unset($request['form_key']);
171
+ }
172
 
173
+ // we're requesting a merchant signup
174
+ $request['type'] = 'signup';
175
+
176
  // remove 'futurepay_' from the beginning of form field names
177
  $tempRequest = $request;
178
  foreach ($tempRequest as $k => $v) {
180
  $k = str_replace('futurepay_', '', $k);
181
  $request[$k] = $v;
182
  }
183
+
184
+ // build the request URL
185
  $queryString = http_build_query($request);
186
  $requestUrl = "https://{$requestHost}/remote/merchant-request-key?{$queryString}";
187
 
188
+ // make sure the request URL validates
189
  if (filter_var($requestUrl, FILTER_VALIDATE_URL)) {
190
 
191
+ set_time_limit(0);
192
+ ini_set('max_execution_time', 300); // 5 minutes
193
+
194
  $ch = curl_init($requestUrl);
195
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
196
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
197
+ curl_setopt($ch, CURLOPT_USERAGENT, 'Magento/FuturePay Plugin v2.0');
198
  $result = curl_exec($ch);
199
+
200
  // if the connection failed, report it back to the browser, otherwise
201
  // pass the json object back.
202
  if ($result !== false) {
210
  )));
211
  }
212
  curl_close($ch);
213
+
214
  } else {
215
+ // the request URL did not validate
216
  $this->getResponse()->setHeader('Content-type', 'application/json');
217
  $this->getResponse()->setBody(json_encode(array(
218
  'error' => 1,
220
  )));
221
  }
222
  }
223
+
224
 
225
+ /**
226
+ * Fetch a list of regions for the specified country and render them as
227
+ * a json response
228
+ *
229
+ * @return void
230
+ */
231
+ public function getCountryRegionsAction() {
232
  $regionList = Mage::getModel('directory/region')
233
+ ->getResourceCollection()
234
+ ->addCountryFilter($this->getRequest()->getParam('country'))
235
+ ->load()
236
+ ->toArray();
237
  $this->getResponse()->setHeader('Content-type', 'application/json');
238
  $this->getResponse()->setBody(json_encode($regionList));
239
  }
240
+
241
 
242
+ /**
243
+ * Pass the order details, including FuturePay's pre-authorization token to
244
+ * FuturePay to be finalized.
245
+ *
246
+ * @return void
247
+ * @throws FuturePay_FuturePay_Exception
248
+ */
249
+ public function processAction() {
250
+
251
+ // if we can't find the last quote ID, redirect back to the cart page
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  if (!$this->getOnepage()->getCheckout()->getLastSuccessQuoteId()) {
253
  $this->_redirect('checkout/cart');
254
  return;
255
  }
 
256
  $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
257
  $order = Mage::getModel('sales/order')->load($lastOrderId);
258
  Mage::register('current_order', $order);
261
 
262
  // this token was stored in storeFPTokenAction()
263
  $token = Mage::getSingleton('core/session')->getFpToken();
264
+
265
  if ($token) {
266
+
 
 
267
  $GMID = Mage::getStoreConfig('payment/futurepay/gmid');
268
  $fpMerchantId = trim(substr($GMID, 40, 45));
269
+
 
270
  $postData = array(
271
  'api_version' => '2',
272
  'order_action' => 'capture',
274
  'PlatformId' => '302',
275
  'reference' => $order->getIncrementId(),
276
  'amount' => $order->getGrandTotal(),
 
277
  'order_description' => Mage::helper('futurepay')->__('Payment for order #%s', $order->getIncrementId()),
278
  'soft_descriptor' => Mage::app()->getStore()->getName(),
 
279
  'shipping_cost' => $order->getShippingAmount(),
280
  'shipping_address' => "{$order->getShippingAddress()->getStreet(1)}\n{$order->getShippingAddress()->getStreet(2)}",
281
  'shipping_zip' => $order->getShippingAddress()->getPostcode(),
282
  'shipping_country' => $order->getShippingAddress()->getCountry(),
 
 
 
283
  'subscription' => 0,
284
  'billing_address' => "{$order->getBillingAddress()->getStreet(1)}\n{$order->getBillingAddress()->getStreet(2)}",
285
  'billing_zip' => $order->getBillingAddress()->getPostcode(),
286
  'billing_country' => $order->getBillingAddress()->getCountry(),
 
287
  );
288
+
289
 
290
+ // FuturePay will only accept ISO 3166-2 region codes, although
291
+ // the form will allow a customer to manually enter a region
292
+ // when no region codes are available for the selected country
293
  $shippingRegionCode = $order->getShippingAddress()->getRegionCode();
294
+ $billingRegionCode = $order->getBillingAddress()->getRegionCode();
295
+
296
  if (strlen($shippingRegionCode) == 2) {
297
  $postData['shipping_region'] = $shippingRegionCode;
298
  }
299
+ if (strlen($billingRegionCode) == 2) {
300
+ $postData['billing_region'] = $billingRegionCode;
301
+ }
302
+
303
+ // convert the request array to a HTTP query
304
  $postData = http_build_query($postData);
305
 
306
+ // this value is set in:
307
+ // Magento Admin > Configuration > Payment Methods > FuturePay
308
  if (Mage::getStoreConfig('payment/futurepay/is_sandbox_mode') == 1) {
309
  $requestHost = "sandbox.futurepay.com";
310
  } else {
311
  $requestHost = "api.futurepay.com";
312
  }
313
+
314
  $hash = base64_encode(hash_hmac('sha256', time() . $GMID . $fpMerchantId, $GMID, true));
315
+
316
  $cr = curl_init("https://" . $requestHost . "/api/order");
317
  curl_setopt($cr, CURLOPT_POST, true);
318
  curl_setopt($cr, CURLOPT_POSTFIELDS, $postData);
319
  curl_setopt($cr, CURLOPT_HTTPHEADER, array(
320
+ "api_key: {$fpMerchantId}",
321
+ "signature: {$hash}",
322
  ));
323
+
324
  curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
325
  $response = curl_exec($cr);
326
 
327
+ if (!$response) {
328
+ // the curl call failed, but surpress the error because this
329
+ // is customer-facing
330
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not valid'));
331
+ }
332
+
333
+ // FuturePay returns a json object - convert it to an array
334
  $serverResult = json_decode($response, true);
335
 
336
  if (!is_array($serverResult)) {
337
+ // if the FuturePay response contains invalid json, the
338
+ // order has most likely failed, but we didn't receieve an
339
+ // error message
340
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted'));
341
  } elseif ($serverResult['status'] != 1) {
342
+ // the json was parsed currectly, but the order failed on
343
+ // FuturePay's side. Report the error to the customer
344
  throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted: ' . $serverResult['message']));
345
  }
346
+
347
+ // this should be the order total
348
  $capturedAmount = $serverResult['object']['order_total'];
349
 
350
+ // this is the FuturePay transaction ID
351
  $txtId = $serverResult['object']['transaction_references'][0];
352
 
353
+ // get the payment object and complete it
 
354
  $payment = $order->getPayment();
355
  $payment->setTransactionId($txtId)
356
+ ->setCurrencyCode($order->getBaseCurrencyCode())
357
+ ->setPreparedMessage('')
358
+ ->setParentTransactionId($txtId)
359
+ ->setShouldCloseParentTransaction(true)
360
+ ->setIsTransactionClosed(1);
 
 
 
361
 
 
 
 
 
 
 
 
 
 
 
362
  if (Mage::helper('futurepay')->autoCreateInvoice()) {
363
  $payment->registerCaptureNotification($capturedAmount);
 
364
  // notify customer
365
  $invoice = $payment->getCreatedInvoice();
366
  if ($invoice && !$order->getEmailSent()) {
367
  $order->sendNewOrderEmail()->addStatusHistoryComment(
368
  Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId())
369
  )
370
+ ->setIsCustomerNotified(true);
 
371
  }
372
  } else {
373
  $payment->registerAuthorizationNotification($capturedAmount);
374
  if (!$order->getEmailSent()) {
375
  $order->sendNewOrderEmail();
376
  }
 
377
  }
378
+ $order->save();
379
+
380
+ // the order was a success! redirect to the success page
381
  $this->_redirect('checkout/onepage/success');
382
+ } else {
383
+ // no futurepay token available
384
+ throw new FuturePay_FuturePay_Exception(Mage::helper('futurepay')->__('The transaction is not accepted'));
385
  }
386
  } catch (Exception $e) {
387
+ // there was an error. return the customer to the cart page.
388
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
389
  Mage::getSingleton('checkout/session')->addError($e->getMessage());
 
390
  $this->_redirect('checkout/cart');
391
  }
392
  }
393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
  }
app/code/community/FuturePay/FuturePay/data/futurepay_setup/data-install-2.0.0.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->endFpSetup();
5
-
6
- ?>
 
 
 
 
 
 
app/code/community/FuturePay/FuturePay/data/futurepay_setup/data-install-2.0.11.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * FuturePay install data script
4
+ *
5
+ * @see FuturePay/Model/Resource/Setup.php
6
+ */
7
+ $this->startSetup();
8
+
9
+
10
+
11
+ // fix for missing payment method name in sales report on previous versions
12
+ $mageCodeModelConfig = new Mage_Core_Model_Config();
13
+ $mageCodeModelConfig->saveConfig('payment/futurepay/title', 'Buy Now and Pay Later with FuturePay', 'default', 0);
14
+
15
+
16
+ $this->endFpSetup();
17
+
18
+ ?>
app/code/community/FuturePay/FuturePay/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <futurepay_futurepay>
5
- <version>2.0.0</version>
6
  </futurepay_futurepay>
7
  </modules>
8
 
@@ -68,13 +68,6 @@
68
  <futurepay>
69
  <active>1</active>
70
  <model>futurepay/method_futurepay</model>
71
- <checkout_url>https://api.futurepay.com/remote/merchant-request-order-token</checkout_url>
72
- <cart_integration>https://api.futurepay.com/remote/cart-integration/</cart_integration>
73
- <order_verification_url>https://api.futurepay.com/remote/merchant-order-verification?</order_verification_url>
74
- <pmid>33525d80d1e7a2d04e6adf9950619d297cff5c36FPM674662647</pmid>
75
- <sandbox_checkout_url>https://sandbox.futurepay.com/remote/merchant-request-order-token</sandbox_checkout_url>
76
- <sandbox_cart_integration>https://sandbox.futurepay.com/remote/cart-integration/</sandbox_cart_integration>
77
- <sandbox_order_verification_url>https://sandbox.futurepay.com/remote/merchant-order-verification?</sandbox_order_verification_url>
78
  <order_status>pending</order_status>
79
  <title>Buy Now and Pay Later with FuturePay</title>
80
  <allowspecific>0</allowspecific>
@@ -82,12 +75,4 @@
82
  </futurepay>
83
  </payment>
84
  </default>
85
- <crontab>
86
- <jobs>
87
- <futurepay_check_transaction_status>
88
- <schedule><cron_expr>*/10 * * * *</cron_expr></schedule>
89
- <run><model>futurepay/observer::checkTransactionStatus</model></run>
90
- </futurepay_check_transaction_status>
91
- </jobs>
92
- </crontab>
93
  </config>
2
  <config>
3
  <modules>
4
  <futurepay_futurepay>
5
+ <version>2.0.11</version>
6
  </futurepay_futurepay>
7
  </modules>
8
 
68
  <futurepay>
69
  <active>1</active>
70
  <model>futurepay/method_futurepay</model>
 
 
 
 
 
 
 
71
  <order_status>pending</order_status>
72
  <title>Buy Now and Pay Later with FuturePay</title>
73
  <allowspecific>0</allowspecific>
75
  </futurepay>
76
  </payment>
77
  </default>
 
 
 
 
 
 
 
 
78
  </config>
app/design/adminhtml/base/default/template/futurepay/info/futurepay.phtml CHANGED
@@ -1 +1 @@
1
- <?php /*?><p><?php echo $this->getMethod()->getTitle() ?></p><?php */?>
2
  <?php if($this->getPayableTo()): ?>
3
  <p><strong><?php echo $this->__('Make Check payable to:') ?></strong> <?php echo $this->htmlEscape($this->getPayableTo()) ?></p>
4
  <?php endif; ?>
5
  <?php if($this->getMailingAddress()): ?>
6
  <p><strong><?php echo Mage::helper('payment')->__('Send to:') ?></strong></p>
7
  <address class="checkmo-mailing-address">
8
  <?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
9
  </address>
10
  <?php endif; ?>
 
11
  <?php if($this->getPayableTo()): ?>
12
  <p><strong><?php echo $this->__('Make Check payable to:') ?></strong> <?php echo $this->htmlEscape($this->getPayableTo()) ?></p>
13
  <?php endif; ?>
14
  <?php if($this->getMailingAddress()): ?>
15
  <p><strong><?php echo Mage::helper('payment')->__('Send to:') ?></strong></p>
16
  <address class="checkmo-mailing-address">
17
  <?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
18
  </address>
19
  <?php endif; ?>
 
1
  <?php if($this->getPayableTo()): ?>
2
  <p><strong><?php echo $this->__('Make Check payable to:') ?></strong> <?php echo $this->htmlEscape($this->getPayableTo()) ?></p>
3
  <?php endif; ?>
4
  <?php if($this->getMailingAddress()): ?>
5
  <p><strong><?php echo Mage::helper('payment')->__('Send to:') ?></strong></p>
6
  <address class="checkmo-mailing-address">
7
  <?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
8
  </address>
9
  <?php endif; ?>
10
+ <img src="<?php echo $this->getSkinUrl('futurepay/fp_logo.png')?>" alt="FuturePay" title="FuturePay"/>
11
  <?php if($this->getPayableTo()): ?>
12
  <p><strong><?php echo $this->__('Make Check payable to:') ?></strong> <?php echo $this->htmlEscape($this->getPayableTo()) ?></p>
13
  <?php endif; ?>
14
  <?php if($this->getMailingAddress()): ?>
15
  <p><strong><?php echo Mage::helper('payment')->__('Send to:') ?></strong></p>
16
  <address class="checkmo-mailing-address">
17
  <?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
18
  </address>
19
  <?php endif; ?>
app/design/frontend/base/default/layout/futurepay.xml CHANGED
@@ -3,17 +3,6 @@
3
  <default>
4
 
5
  </default>
6
- <futurepay_index_process>
7
- <reference name="head">
8
- <action method="addCss"><css>futurepay/styles.css</css></action>
9
- </reference>
10
- <reference name="root">
11
- <action method="setTemplate"><template>page/empty.phtml</template></action>
12
- </reference>
13
- <reference name="content">
14
- <block type="futurepay/process" name="futurepay.process" template="futurepay/process.phtml" />
15
- </reference>
16
- </futurepay_index_process>
17
  <futurepay_index_getsignuploginform>
18
  <reference name="head">
19
  <action method="addCss"><css>futurepay/styles.css</css></action>
3
  <default>
4
 
5
  </default>
 
 
 
 
 
 
 
 
 
 
 
6
  <futurepay_index_getsignuploginform>
7
  <reference name="head">
8
  <action method="addCss"><css>futurepay/styles.css</css></action>
app/design/frontend/base/default/template/futurepay/form/mark.phtml CHANGED
@@ -1,15 +1,18 @@
1
  <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600' rel='stylesheet' type='text/css'>
2
- <?php if (substr(Mage::getVersion(), 0, 3) == '1.8' || substr(Mage::getVersion(), 0, 3) == '1.7' || substr(Mage::getVersion(), 0, 3) == '1.6' || substr(Mage::getVersion(), 0, 3) == '1.5') {
 
 
3
  echo "<link href='". $this->getSkinUrl('futurepay/styles18.css') ."' rel='stylesheet' type='text/css'>";
4
  } else {
5
  echo "<link href='". $this->getSkinUrl('futurepay/styles19.css') ."' rel='stylesheet' type='text/css'>";
6
- } ?>
 
7
  <style>
8
  <?php if (Mage::getStoreConfig('payment/futurepay/custom_image')): echo "#fp-custom-description { margin-left: 6px; margin-top: 6px; }"; endif; ?>
9
  <?php if (!Mage::getStoreConfig('payment/futurepay/custom_image') && Mage::getStoreConfig('payment/futurepay/custom_description') == ''): echo "#fp-info { position: relative; right: 5px; top: 8px; }"; endif; ?>
10
  <?php if (!Mage::getStoreConfig('payment/futurepay/custom_image') && Mage::getStoreConfig('payment/futurepay/custom_description') != ''): echo "#fp-info { position: relative; bottom: 6px; right: 4px; }"; endif; ?>
11
- <?php if ((Mage::getStoreConfig('payment/futurepay/custom_description') != '') && (substr(Mage::getVersion(), 0, 3) == '1.8' || substr(Mage::getVersion(), 0, 3) == '1.7' || substr(Mage::getVersion(), 0, 3) == '1.6' || substr(Mage::getVersion(), 0, 3) == '1.5')): echo "#fp-info { position: relative; bottom: 0px; right: 0px; left: 5px; }"; endif; ?>
12
- <?php if ((Mage::getStoreConfig('payment/futurepay/custom_description') == '') && (substr(Mage::getVersion(), 0, 3) == '1.8' || substr(Mage::getVersion(), 0, 3) == '1.7' || substr(Mage::getVersion(), 0, 3) == '1.6' || substr(Mage::getVersion(), 0, 3) == '1.5')): echo "#fp-info { position: relative; bottom: 0px; right: 2px; left: 5px; }"; endif; ?>
13
  </style>
14
  <div id="fp-info-popup" style="z-index:15; position: absolute; display:none; top:0;">
15
  <div class="fpInfo">
@@ -52,8 +55,6 @@
52
  if (Mage::getStoreConfig('payment/futurepay/custom_description') != '') {
53
  echo '<span id="fp-custom-description">' . Mage::getStoreConfig('payment/futurepay/custom_description') . '</span>';
54
  }
55
- //var_dump(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA));
56
- //var_dump(Mage::getStoreConfig('payment/futurepay/custom_image'));
57
  ?>
58
  <a id="fp-info" href="#" onclick="return false;"><?php echo $this->__('Learn More'); ?></a>
59
  <!-- FuturePay Logo -->
@@ -63,8 +64,8 @@ $('fp-info').observe('click', function (e) {
63
  var overlay = new Element('div');
64
  overlay.id = 'fp-info-overlay';
65
  overlay.setStyle({
66
- 'top': 0, // e.clientY - (overlay.getHeight() / 2), // center around pointer?
67
- 'left': 0, // e.clientY - (overlay.getWidth() / 2), // center around pointer?
68
  'width': '100%',
69
  'height': '100%',
70
  'opacity': 0.5,
@@ -83,22 +84,17 @@ $('fp-info').observe('click', function (e) {
83
  $('fp-info-popup').hide();
84
  overlay.remove();
85
  });
86
- <?php if (substr(Mage::getVersion(), 0, 3) == '1.8' || substr(Mage::getVersion(), 0, 3) == '1.7' || substr(Mage::getVersion(), 0, 3) == '1.6' || substr(Mage::getVersion(), 0, 3) == '1.5') { ?>
87
  $('fp-info-popup').setStyle({
88
  'left': '15%',
89
  'right': '15%',
90
- // 'top': e.clientY - (overlay.getHeight() / 2),
91
- // 'left': e.clientY - (overlay.getWidth() / 2)
92
  'top': '5%',
93
  'position': 'fixed',
94
  'background-color': '#FFFFFF',
95
- //'padding': '20px',
96
  });
97
  <?php } else { ?>
98
  $('fp-info-popup').setStyle({
99
  'left': 0
100
- // 'top': e.clientY - (overlay.getHeight() / 2),
101
- // 'left': e.clientY - (overlay.getWidth() / 2)
102
  });
103
  <?php } ?>
104
  $('fp-info-popup').show();
1
  <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,600' rel='stylesheet' type='text/css'>
2
+ <?php
3
+ // switch the stylesheet based on the magento version
4
+ if (in_array(substr(Mage::getVersion(), 0, 3), array('1.8', '1.7', '1.6', '1.5'))) {
5
  echo "<link href='". $this->getSkinUrl('futurepay/styles18.css') ."' rel='stylesheet' type='text/css'>";
6
  } else {
7
  echo "<link href='". $this->getSkinUrl('futurepay/styles19.css') ."' rel='stylesheet' type='text/css'>";
8
+ }
9
+ ?>
10
  <style>
11
  <?php if (Mage::getStoreConfig('payment/futurepay/custom_image')): echo "#fp-custom-description { margin-left: 6px; margin-top: 6px; }"; endif; ?>
12
  <?php if (!Mage::getStoreConfig('payment/futurepay/custom_image') && Mage::getStoreConfig('payment/futurepay/custom_description') == ''): echo "#fp-info { position: relative; right: 5px; top: 8px; }"; endif; ?>
13
  <?php if (!Mage::getStoreConfig('payment/futurepay/custom_image') && Mage::getStoreConfig('payment/futurepay/custom_description') != ''): echo "#fp-info { position: relative; bottom: 6px; right: 4px; }"; endif; ?>
14
+ <?php if ((Mage::getStoreConfig('payment/futurepay/custom_description') != '') && in_array(substr(Mage::getVersion(), 0, 3), array('1.8', '1.7', '1.6', '1.5'))): echo "#fp-info { position: relative; bottom: 0px; right: 0px; left: 5px; }"; endif; ?>
15
+ <?php if ((Mage::getStoreConfig('payment/futurepay/custom_description') == '') && in_array(substr(Mage::getVersion(), 0, 3), array('1.8', '1.7', '1.6', '1.5'))): echo "#fp-info { position: relative; bottom: 0px; right: 2px; left: 5px; }"; endif; ?>
16
  </style>
17
  <div id="fp-info-popup" style="z-index:15; position: absolute; display:none; top:0;">
18
  <div class="fpInfo">
55
  if (Mage::getStoreConfig('payment/futurepay/custom_description') != '') {
56
  echo '<span id="fp-custom-description">' . Mage::getStoreConfig('payment/futurepay/custom_description') . '</span>';
57
  }
 
 
58
  ?>
59
  <a id="fp-info" href="#" onclick="return false;"><?php echo $this->__('Learn More'); ?></a>
60
  <!-- FuturePay Logo -->
64
  var overlay = new Element('div');
65
  overlay.id = 'fp-info-overlay';
66
  overlay.setStyle({
67
+ 'top': 0,
68
+ 'left': 0,
69
  'width': '100%',
70
  'height': '100%',
71
  'opacity': 0.5,
84
  $('fp-info-popup').hide();
85
  overlay.remove();
86
  });
87
+ <?php if (in_array(substr(Mage::getVersion(), 0, 3), array('1.8', '1.7', '1.6', '1.5'))) { ?>
88
  $('fp-info-popup').setStyle({
89
  'left': '15%',
90
  'right': '15%',
 
 
91
  'top': '5%',
92
  'position': 'fixed',
93
  'background-color': '#FFFFFF',
 
94
  });
95
  <?php } else { ?>
96
  $('fp-info-popup').setStyle({
97
  'left': 0
 
 
98
  });
99
  <?php } ?>
100
  $('fp-info-popup').show();
app/design/frontend/base/default/template/futurepay/form/redirect.phtml CHANGED
@@ -1,102 +1,18 @@
1
- <?php /* <style type="text/css">
2
- .FP_redirectmessage #fp-signup-form,
3
- .FP_redirectmessage #fp-login-form {
4
- max-width: 500px;
5
- padding: 10px;
6
- margin: 10px;
7
- vertical-align: middle;
8
- font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
9
- -webkit-border-radius: 5px;
10
- -moz-border-radius: 5px;
11
- border-radius: 5px;
12
- -moz-background-clip: padding;
13
- -webkit-background-clip: padding-box;
14
- background-clip: padding-box;
15
- }
16
- .FP_redirectmessage #fp-signup-form .fp-label,
17
- .FP_redirectmessage #fp-login-form .fp-label {
18
- display: block;
19
- margin-right: 20px;
20
- padding-left: 4px;
21
- font-weight: bold;
22
- color: grey;
23
- }
24
- .FP_redirectmessage #fp-signup-form input,
25
- .FP_redirectmessage #fp-login-form input,
26
- .FP_redirectmessage #fp-signup-form select,
27
- .FP_redirectmessage #fp-login-form select {
28
- font-family: Lato, monospace !important;
29
- width: 100%;
30
- display: inline-block;
31
- font-size: 1em;
32
- margin: 5px 10px 10px 10px auto;
33
- padding: 0 10px !important;
34
- }
35
- .FP_redirectmessage #fp-signup-form select,
36
- .FP_redirectmessage #fp-login-form select {
37
- width: 95px;
38
- background-color: white;
39
- }
40
- .FP_redirectmessage #fp-signup-form #zip,
41
- .FP_redirectmessage #fp-login-form #zip,
42
- .FP_redirectmessage #fp-signup-form #main_phone,
43
- .FP_redirectmessage #fp-login-form #main_phone,
44
- .FP_redirectmessage #fp-signup-form #ssn,
45
- .FP_redirectmessage #fp-login-form #ssn {
46
- max-width: 305px;
47
- }
48
- .FP_redirectmessage #fp-signup-form img,
49
- .FP_redirectmessage #fp-login-form img {
50
- vertical-align: middle;
51
- display: inline;
52
- }
53
- .FP_redirectmessage #fp-signup-form input[type="button"],
54
- .FP_redirectmessage #fp-login-form input[type="button"] {
55
- margin: 15px 0px 15px 15px;
56
- height: 32px;
57
- display: inline-block;
58
- font-size: 1em;
59
- margin-left: 89px;
60
- text-decoration: none;
61
- width: 120px !important;
62
- }
63
- .FP_redirectmessage #fp-signup-form .fp-signup-link,
64
- .FP_redirectmessage #fp-login-form .fp-signup-link {
65
- text-decoration: none;
66
- font-weight: bold;
67
- font-size: 1em !important;
68
- float: none;
69
- }
70
- .FP_redirectmessage #fp-signup-form input[type="checkbox"].fp-checkbox,
71
- .FP_redirectmessage #fp-login-form input[type="checkbox"].fp-checkbox {
72
- text-align: left;
73
- width: 13px !important;
74
- height: 13px;
75
- padding: 0;
76
- vertical-align: middle;
77
- }
78
- .FP_redirectmessage #fp-signup-form .fp-terms-label,
79
- .FP_redirectmessage #fp-login-form .fp-terms-label {
80
- width: 300px;
81
- }
82
- .FP_redirectmessage #fp-signup-form .fp-error-element,
83
- .FP_redirectmessage #fp-login-form .fp-error-element {
84
- height: 1em;
85
- text-align: center;
86
- display: inline-block;
87
- width: 100%;
88
- }
89
- .FP_redirectmessage #fp-signup-form .fp-error-message,
90
- .FP_redirectmessage #fp-login-form .fp-error-message {
91
- text-align: left;
92
- font-family: "Raleway", "Helvetica Neue", Verdana, Arial, sans-serif;
93
- }
94
- </style> */ ?>
95
- <?php if (substr(Mage::getVersion(), 0, 3) == '1.8' || substr(Mage::getVersion(), 0, 3) == '1.7' || substr(Mage::getVersion(), 0, 3) == '1.6' || substr(Mage::getVersion(), 0, 3) == '1.5') {
96
- echo "<link href='". $this->getSkinUrl('futurepay/styles18.css') ."' rel='stylesheet' type='text/css'>";
97
- } else {
98
  echo "<link href='". $this->getSkinUrl('futurepay/styles19.css') ."' rel='stylesheet' type='text/css'>";
99
- } ?>
 
 
 
100
  <ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
101
  <li class="form-alt">
102
  <div id="FP_redirectmessage" class="FP_redirectmessage">
@@ -107,6 +23,16 @@
107
  </li>
108
  </ul>
109
  <?php
 
 
 
 
 
 
 
 
 
 
110
  $customerEmail = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getEmail();
111
  if (!$customerEmail) {
112
  $customerEmail = Mage::getSingleton('checkout/session')->getQuote()->getCustomerEmail();
@@ -115,12 +41,21 @@ if (!$customerEmail) {
115
  // get the order total
116
  $quoteData = Mage::getModel('checkout/session')->getQuote()->getData();
117
  $grandTotal = $quoteData['grand_total'];
 
 
 
118
  ?>
119
  <script type="text/javascript">
120
  var customerEmail = '<?php echo urlencode($customerEmail); ?>';
 
 
 
 
 
 
 
 
121
  var FP_MerchantId = "<?php echo trim(substr(Mage::getStoreConfig('payment/futurepay/gmid'), 40, 45)); ?>";
122
- var FP_Initialized = false;
123
- var FP_Available = false;
124
  var FP_Messages = {
125
  'FPS00001': 'Congratulations! Your FuturePay account has been created successfully. Please continue on with your purchase and check your email for further details.',
126
  'FPS00003': 'Congratulations! Your FuturePay account has been created successfully. Please continue on with your purchase and check your email for further details.',
@@ -128,185 +63,270 @@ $grandTotal = $quoteData['grand_total'];
128
  'FPE00011': 'Your FuturePay account could not be created. Please check your email for further details.',
129
  'FPE00018': 'Your order exceeds your available FuturePay credit. Please log into your FuturePay account or contact support at 1-855-984-1125 for further details.'
130
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  $('p_method_<?php echo $this->getMethodCode(); ?>').checked = false;
132
- if (customerEmail.length > 0
133
- && FP_MerchantId.length > 0) {
134
-
135
  if (<?php echo Mage::getStoreConfig('payment/futurepay/is_sandbox_mode'); ?> === 1) {
136
  var requestHost = 'sandbox.futurepay.com';
137
  } else {
138
  var requestHost = 'api.futurepay.com';
139
  }
140
 
141
- new Ajax.Request('https://' + requestHost + '/api/content/merchant_id/' + FP_MerchantId + '/email/' + customerEmail, {
142
- method: 'get',
143
- onCreate: function(request) {
144
- //disable pre-flight
145
- request.transport.setRequestHeader = Prototype.emptyFunction;
146
- },
147
- onSuccess: function(response) {
148
- if (response.getResponseHeader('Content-Type') === 'text/javascript') {
149
- try {
150
- var functionCall = new Function(response.responseText);
151
- } catch (e) {
152
- if (e instanceof SyntaxError) {
153
- console.log('Syntax error reported in FuturePay js: ' + e.message);
154
- }
155
- }
156
-
157
- if (typeof(functionCall) === 'function') {
158
- // this is the FP object
159
- functionCall();
160
- FP_Available = true;
161
- }
162
- } else {
163
- // fp json error - insert the error into $('FP_applicationForm')
164
- // disable the Continue button if futurepay is selected
165
- var responseObj = response.responseText.evalJSON();
166
- console.log('FP ERROR ON INIT', responseObj);
167
- if (typeof(responseObj) == 'object') {
168
- if (typeof(FP_Messages[responseObj.code]) != 'undefined') {
169
- $('FP_applicationForm').update(FP_Messages[responseObj.code]);
170
- } else {
171
- $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
172
- }
173
- }
174
- }
175
- }
176
- });
177
-
178
  // detect a change in the rest of the payment methods
179
  $$('input[id^=p_method_]').each(function (el) {
180
  if (el.id != 'p_method_<?php echo $this->getMethodCode(); ?>') {
181
  el.observe('change', function () {
182
  // enable the continue button
183
- $('payment-buttons-container').down('button').removeClassName('disabled');
184
- $('payment-buttons-container').down('button').writeAttribute("disabled", false);;
 
 
 
 
 
 
 
 
 
 
 
185
  });
186
  }
187
  });
188
 
189
  // detect a change in ONLY the futurepay payment method
190
- $('p_method_<?php echo $this->getMethodCode(); ?>').observe('change', function () {
191
-
192
- // disable the continue button
193
- $('payment-buttons-container').down('button').addClassName('disabled');
194
- $('payment-buttons-container').down('button').writeAttribute("disabled", "disabled");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
 
196
- if (FP_Available && !FP_Initialized) {
197
- FP.handleResponse = function(data)
198
- {
199
- if (data.status == '1') {
200
- console.log('FP SUCCESS RESPONSE', data);
201
- if (data.object.available_credit >= <?php echo $grandTotal; ?>) {
202
-
203
- new Ajax.Request("<?php echo Mage::getUrl('futurepay/index/storefptoken'); ?>", {
204
- parameters: data,
205
- method: 'post',
206
- onComplete: function(response) {
207
 
208
- // login/application successful - hide the form
209
- // and let the user carry on
210
- $('FP_applicationForm').update();
211
- // allow the user to click "Continue"
212
- $('payment-buttons-container').down('button').removeClassName('disabled');
213
- $('payment-buttons-container').down('button').writeAttribute("disabled", false);
 
 
 
 
 
 
 
 
 
 
 
214
 
215
- // call the built-in function to move to the next step
216
- payment.save();
217
- }
218
- });
219
- } else {
220
- // not enough credit available
221
- $('FP_applicationForm').update(FP_Messages['FPE00018']);
222
- }
223
- } else {
224
- console.log('FP FAIL RESPONSE', data.code, FP_Messages[data.code]);
225
- // fp didn't accept them - insert the error into $('FP_applicationForm')
226
- // or maybe this is handled by FP.setValidationErrorCallback?
 
227
 
228
- // sometimes, we'll get this error: The Initialization Token has expired
229
- // we'll need to re-initialize FP
230
- if (typeof(data.code) != 'undefined'
231
- && (typeof(FP_Messages[data.code]) != 'undefined' || data.code == 'FPE00031')) {
232
-
233
- // if the error message is not a failed login
234
- if (data.code != 'FPE00031') {
235
- $('FP_applicationForm').update(FP_Messages[data.code]);
236
- }
237
- } else {
238
- $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
239
- }
240
-
241
- if ($('fp-submit') !== null) {
242
- $('fp-submit').removeAttribute('disabled');
243
- }
244
- if ($('fp-login') !== null) {
245
- $('fp-login').removeAttribute('disabled');
246
- }
247
-
248
- }
249
- }
250
 
251
- FP.loadCompleteCallback = function () {
 
 
 
 
 
 
252
 
253
- FP.initializeFuturePay({
254
- element_id: "FP_applicationForm",
255
- first_name: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getCustomerFirstname(); ?>',
256
- last_name: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getCustomerLastname(); ?>',
257
- zip: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getPostcode(); ?>',
258
- street_address: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getStreet(1); ?>',
259
- phone: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getTelephone(); ?>'
260
- });
261
 
262
- // Adapt the futurepay HTML to fit the current magento style
263
- try { $("fp-submit").addClassName("button") } catch (e) {};
264
- try { $("fp-login").addClassName("button") } catch (e) {};
265
 
266
- if ($('fp-submit') !== null) {
267
- $('fp-submit').observe('click', function () {
268
- if (FP.isValid()) {
269
- $('fp-submit').setAttribute('disabled', 'disabled');
270
- }
271
- });
272
- }
273
- if ($('fp-login') !== null) {
274
- $('fp-login').observe('click', function () {
275
- if (FP.isValid()) {
276
- $('fp-login').setAttribute('disabled', 'disabled');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  }
278
- });
279
- }
280
-
281
- if ($('fp-signup-form') !== null) {
282
-
283
- // force-validate the FP form
284
- //FP.validateForm();
285
-
286
- FP.validateNumber();
287
- FP.validateZip();
288
- FP.validateEmail();
289
- FP.displayErrors();
290
-
291
- // hide fields already populated
292
- $('fp-signup-form').select(':input[type=text]').each(function (el) {
293
- // unless fp marked them with an error
294
- if (el.value.length > 0 && !el.hasClassName('fp-error')) {
295
- try { $$('label[for=' + el.name + ']')[0].hide(); } catch (e) {};
296
- try { $$('.error_' + el.name)[0].hide(); } catch (e) {};
297
- el.hide();
298
  }
299
- });
 
 
 
 
300
  }
301
-
302
- FP_Initialized = true;
303
- }
304
-
305
- FP.loadCompleteCallback();
306
  }
307
  });
308
  } else {
309
- // the user has to select another payment option
310
  $('FP_applicationForm').update('FuturePay is not available at this time. Please select another payment method.');
311
  }
312
  </script>
1
+ <?php
2
+ // this will be set to true if the extension is installed on Magento EE
3
+ $isEnterprise = Mage::getConfig ()->getModuleConfig ( 'Enterprise_Enterprise' )
4
+ && Mage::getConfig ()->getModuleConfig ( 'Enterprise_AdminGws' )
5
+ && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Checkout' )
6
+ && Mage::getConfig ()->getModuleConfig ( 'Enterprise_Customer' );
7
+
8
+ // switch the stylesheet based on the magento version
9
+ if ( (version_compare(Mage::getVersion(), '1.14', '>=') && $isEnterprise)
10
+ || (version_compare(Mage::getVersion(), '1.9', '>=') && !$isEnterprise) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  echo "<link href='". $this->getSkinUrl('futurepay/styles19.css') ."' rel='stylesheet' type='text/css'>";
12
+ } else {
13
+ echo "<link href='". $this->getSkinUrl('futurepay/styles18.css') ."' rel='stylesheet' type='text/css'>";
14
+ }
15
+ ?>
16
  <ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
17
  <li class="form-alt">
18
  <div id="FP_redirectmessage" class="FP_redirectmessage">
23
  </li>
24
  </ul>
25
  <?php
26
+ $customerFirstname = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getFirstname();
27
+ if (!$customerFirstname) {
28
+ $customerFirstname = Mage::getSingleton('checkout/session')->getQuote()->getCustomerFirstname();;
29
+ }
30
+
31
+ $customerLastname = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getLastname();
32
+ if (!$customerLastname) {
33
+ $customerLastname = Mage::getSingleton('checkout/session')->getQuote()->getCustomerLastname();
34
+ }
35
+
36
  $customerEmail = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getEmail();
37
  if (!$customerEmail) {
38
  $customerEmail = Mage::getSingleton('checkout/session')->getQuote()->getCustomerEmail();
41
  // get the order total
42
  $quoteData = Mage::getModel('checkout/session')->getQuote()->getData();
43
  $grandTotal = $quoteData['grand_total'];
44
+ if ($grandTotal < 0) {
45
+ $grandTotal = 0;
46
+ }
47
  ?>
48
  <script type="text/javascript">
49
  var customerEmail = '<?php echo urlencode($customerEmail); ?>';
50
+ var prePopulatedFields = {
51
+ element_id: "FP_applicationForm",
52
+ first_name: '<?php echo $customerFirstname; ?>',
53
+ last_name: '<?php echo $customerLastname; ?>',
54
+ zip: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getPostcode(); ?>',
55
+ street_address: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getStreet(1); ?>',
56
+ phone: '<?php echo Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getTelephone(); ?>'
57
+ };
58
  var FP_MerchantId = "<?php echo trim(substr(Mage::getStoreConfig('payment/futurepay/gmid'), 40, 45)); ?>";
 
 
59
  var FP_Messages = {
60
  'FPS00001': 'Congratulations! Your FuturePay account has been created successfully. Please continue on with your purchase and check your email for further details.',
61
  'FPS00003': 'Congratulations! Your FuturePay account has been created successfully. Please continue on with your purchase and check your email for further details.',
63
  'FPE00011': 'Your FuturePay account could not be created. Please check your email for further details.',
64
  'FPE00018': 'Your order exceeds your available FuturePay credit. Please log into your FuturePay account or contact support at 1-855-984-1125 for further details.'
65
  };
66
+
67
+ var createOnestepButtonPlaceholder = function () {
68
+ if ($('onestepcheckout-button-place-order') !== null) {
69
+ if ($('onestepcheckout-button-place-order-FP') !== null) {
70
+ $('onestepcheckout-button-place-order-FP').remove();
71
+ }
72
+ buttonPlaceholderEl = $('onestepcheckout-button-place-order').clone(true);
73
+ buttonPlaceholderEl.id = 'onestepcheckout-button-place-order-FP';
74
+ buttonPlaceholderEl.addClassName('disabled');
75
+ buttonPlaceholderEl.writeAttribute('disabled', 'disabled');
76
+ $('onestepcheckout-button-place-order').insert({after: buttonPlaceholderEl});
77
+ buttonPlaceholderEl.hide();
78
+ }
79
+ };
80
+
81
+ var buttonPlaceholderEl;
82
+ document.observe("dom:loaded", function() {
83
+ createOnestepButtonPlaceholder();
84
+ });
85
+
86
+
87
+ // uncheck futurepay as a payment method on first load
88
  $('p_method_<?php echo $this->getMethodCode(); ?>').checked = false;
89
+ if (FP_MerchantId.length > 0) {
90
+
 
91
  if (<?php echo Mage::getStoreConfig('payment/futurepay/is_sandbox_mode'); ?> === 1) {
92
  var requestHost = 'sandbox.futurepay.com';
93
  } else {
94
  var requestHost = 'api.futurepay.com';
95
  }
96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  // detect a change in the rest of the payment methods
98
  $$('input[id^=p_method_]').each(function (el) {
99
  if (el.id != 'p_method_<?php echo $this->getMethodCode(); ?>') {
100
  el.observe('change', function () {
101
  // enable the continue button
102
+ if ($('payment-buttons-container') !== null) {
103
+ $('payment-buttons-container').down('button').removeClassName('disabled');
104
+ $('payment-buttons-container').down('button').writeAttribute("disabled", false);
105
+ } else if ($('checkout-review') !== null) {
106
+ $('checkout-review').down('button').removeClassName('disabled');
107
+ $('checkout-review').down('button').writeAttribute("disabled", false);
108
+ } else if ($('onestepcheckout-button-place-order') !== null) {
109
+ $('onestepcheckout-button-place-order').removeClassName('disabled');
110
+ $('onestepcheckout-button-place-order').writeAttribute('disabled', false);
111
+ $('onestepcheckout-button-place-order').show();
112
+ createOnestepButtonPlaceholder();
113
+ buttonPlaceholderEl.hide();
114
+ }
115
  });
116
  }
117
  });
118
 
119
  // detect a change in ONLY the futurepay payment method
120
+ $('p_method_<?php echo $this->getMethodCode(); ?>').observe('click', function () {
121
+
122
+ if (<?php echo $grandTotal; ?> > 0) {
123
+
124
+ // get the updated customer email address from the form if it's
125
+ // available
126
+ if (typeof($$(':input[name=billing\[email\]]')) === 'object'
127
+ && $$(':input[name=billing\[email\]]').length > 0) {
128
+ customerEmail = $$(':input[name=billing\[email\]]')[0].value;
129
+ }
130
+
131
+ // disable the continue button
132
+ if ($('payment-buttons-container') !== null) {
133
+ $('payment-buttons-container').down('button').addClassName('disabled');
134
+ $('payment-buttons-container').down('button').writeAttribute("disabled", "disabled");
135
+ } else if ($('checkout-review') !== null) {
136
+ $('checkout-review').down('button').addClassName('disabled');
137
+ $('checkout-review').down('button').writeAttribute("disabled", 'disabled');
138
+ } else if($('onestepcheckout-button-place-order') !== null) {
139
+ $('onestepcheckout-button-place-order').addClassName('disabled');
140
+ $('onestepcheckout-button-place-order').writeAttribute('disabled', 'disabled');
141
+ $('onestepcheckout-button-place-order').hide();
142
+ createOnestepButtonPlaceholder();
143
+ buttonPlaceholderEl.show();
144
+ }
145
+
146
+ // clear out the form
147
+ $('FP_applicationForm').update();
148
+
149
+ new Ajax.Request('https://' + requestHost + '/api/content/merchant_id/' + FP_MerchantId + '/email/' + customerEmail, {
150
+ method: 'get',
151
+ onCreate: function(request) {
152
+ //disable pre-flight
153
+ request.transport.setRequestHeader = Prototype.emptyFunction;
154
+ },
155
+ onSuccess: function(response) {
156
+ if (response.getResponseHeader('Content-Type') === 'text/javascript') {
157
+ try {
158
+ var functionCall = new Function(response.responseText);
159
+ } catch (e) {
160
+ if (e instanceof SyntaxError) {
161
+ console.log('Syntax error reported in FuturePay js: ' + e.message);
162
+ }
163
+ }
164
+ if (typeof(functionCall) === 'function') {
165
+ // this is the FP object
166
+ functionCall();
167
+
168
+ FP.handleResponse = function(data)
169
+ {
170
+ if (data.status == '1') {
171
+ if (data.object.available_credit >= <?php echo $grandTotal; ?>) {
172
 
173
+ // store the pre-auth token returned by futurepay
174
+ // to pass with final order
175
+ new Ajax.Request("<?php echo Mage::getUrl('futurepay/index/storefptoken', array('_secure' => true)); ?>", {
176
+ parameters: data,
177
+ method: 'post',
178
+ onComplete: function(response) {
 
 
 
 
 
179
 
180
+ // login/application successful - hide the form
181
+ // and let the user carry on
182
+ $('FP_applicationForm').update();
183
+ if ($('payment-buttons-container') !== null) {
184
+ // allow the user to click "Continue"
185
+ $('payment-buttons-container').down('button').removeClassName('disabled');
186
+ $('payment-buttons-container').down('button').writeAttribute("disabled", false);
187
+ } else if ($('checkout-review') !== null) {
188
+ $('checkout-review').down('button').removeClassName('disabled');
189
+ $('checkout-review').down('button').writeAttribute("disabled", false);
190
+ } else if ($('onestepcheckout-button-place-order') !== null) {
191
+ $('onestepcheckout-button-place-order').removeClassName('disabled');
192
+ $('onestepcheckout-button-place-order').writeAttribute('disabled', false);
193
+ $('onestepcheckout-button-place-order').show()
194
+ createOnestepButtonPlaceholder();
195
+ buttonPlaceholderEl.hide();
196
+ }
197
 
198
+ // call the built-in function to move to the next step
199
+ if (typeof(payment.save) !== 'undefined') {
200
+ payment.save();
201
+ }
202
+ }
203
+ });
204
+ } else {
205
+ // not enough credit available
206
+ $('FP_applicationForm').update(FP_Messages['FPE00018']);
207
+ }
208
+ } else {
209
+ // fp didn't accept them - insert the error into $('FP_applicationForm')
210
+ // or maybe this is handled by FP.setValidationErrorCallback?
211
 
212
+ // sometimes, we'll get this error: The Initialization Token has expired
213
+ // we'll need to re-initialize FP
214
+ if (typeof(data.code) != 'undefined'
215
+ && (typeof(FP_Messages[data.code]) != 'undefined' || data.code == 'FPE00031')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
 
217
+ // if the error message is not a failed login
218
+ if (data.code != 'FPE00031') {
219
+ $('FP_applicationForm').update(FP_Messages[data.code]);
220
+ }
221
+ } else {
222
+ $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
223
+ }
224
 
225
+ if ($('fp-submit') !== null) {
226
+ $('fp-submit').removeAttribute('disabled');
227
+ }
228
+ if ($('fp-login') !== null) {
229
+ $('fp-login').removeAttribute('disabled');
230
+ }
 
 
231
 
232
+ }
233
+ };
 
234
 
235
+ FP.loadCompleteCallback = function () {
236
+
237
+ if (typeof($$(':input[name=billing\[firstname\]]')) === 'object'
238
+ && $$(':input[name=billing\[firstname\]]').length > 0) {
239
+ prePopulatedFields.first_name = $$(':input[name=billing\[firstname\]]')[0].value;
240
+ }
241
+ if (typeof($$(':input[name=billing\[lastname\]]')) === 'object'
242
+ && $$(':input[name=billing\[lastname\]]').length > 0) {
243
+ prePopulatedFields.last_name = $$(':input[name=billing\[lastname\]]')[0].value;
244
+ }
245
+ if (typeof($$(':input[name=billing\[postcode\]]')) === 'object'
246
+ && $$(':input[name=billing\[postcode\]]').length > 0) {
247
+ prePopulatedFields.zip = $$(':input[name=billing\[postcode\]]')[0].value;
248
+ }
249
+ if (typeof($$(':input[name^=billing\[street\]]')) === 'object'
250
+ && $$(':input[name^=billing\[street\]]').length > 0) {
251
+ prePopulatedFields.street_address = $$(':input[name^=billing\[street\]]')[0].value;
252
+ }
253
+ if (typeof($$(':input[name=billing\[telephone\]]')) === 'object'
254
+ && $$(':input[name=billing\[telephone\]]').length > 0) {
255
+ prePopulatedFields.phone = $$(':input[name=billing\[telephone\]]')[0].value;
256
+ }
257
+
258
+ FP.initializeFuturePay(prePopulatedFields);
259
+
260
+ // Adapt the futurepay HTML to fit the current magento style
261
+ try { $("fp-submit").addClassName("button") } catch (e) {};
262
+ try { $("fp-login").addClassName("button") } catch (e) {};
263
+
264
+ if ($('fp-submit') !== null) {
265
+ $('fp-submit').observe('click', function () {
266
+ if (FP.isValid()) {
267
+ $('fp-submit').setAttribute('disabled', 'disabled');
268
+ }
269
+ });
270
+ }
271
+ if ($('fp-login') !== null) {
272
+ $('fp-login').observe('click', function () {
273
+ if (FP.isValid()) {
274
+ $('fp-login').setAttribute('disabled', 'disabled');
275
+ }
276
+ });
277
+ }
278
+
279
+ if ($('fp-signup-form') !== null) {
280
+
281
+ FP.validateNumber();
282
+ FP.validateZip();
283
+ FP.validateEmail();
284
+ FP.displayErrors();
285
+
286
+ // hide fields already populated
287
+ $('fp-signup-form').select(':input[type=text]').each(function (el) {
288
+ // unless futurepay marked them with an error
289
+ if (el.value.length > 0 && !el.hasClassName('fp-error')) {
290
+ try { $$('label[for=' + el.name + ']')[0].hide(); } catch (e) {};
291
+ try { $$('.error_' + el.name)[0].hide(); } catch (e) {};
292
+ try { el.hide(); } catch (e) {};
293
+ }
294
+ });
295
+ }
296
+ };
297
+
298
+ FP.loadCompleteCallback();
299
+
300
+ } else {
301
+ $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
302
  }
303
+
304
+ } else {
305
+ // fp json error - insert the error into $('FP_applicationForm')
306
+ // disable the Continue button if futurepay is selected
307
+ if (response.responseText) {
308
+ var responseObj = response.responseText.evalJSON();
309
+ if (typeof(responseObj) == 'object') {
310
+ if (typeof(FP_Messages[responseObj.code]) != 'undefined') {
311
+ $('FP_applicationForm').update(FP_Messages[responseObj.code]);
312
+ } else {
313
+ $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
314
+ }
315
+ }
316
+ } else {
317
+ $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
 
 
 
 
 
318
  }
319
+ }
320
+ },
321
+ onException: function () {
322
+ // ajax error
323
+ $('FP_applicationForm').update('An error occurred, please try again or select another payment method.');
324
  }
325
+ });
 
 
 
 
326
  }
327
  });
328
  } else {
329
+ // ask the user to select another payment option
330
  $('FP_applicationForm').update('FuturePay is not available at this time. Please select another payment method.');
331
  }
332
  </script>
app/design/frontend/base/default/template/futurepay/info/futurepay.phtml CHANGED
@@ -1,13 +1,8 @@
1
- <?php /*?><p><?php echo $this->getMethod()->getTitle() ?></p>*/?>
 
 
 
 
 
2
  <img src="<?php echo $this->getSkinUrl('futurepay/fp_logo.png')?>" alt="FuturePay" title="FuturePay"/>
3
- <?php if($this->getInfo()->getAdditionalData()): ?>
4
- <?php if($this->getPayableTo()): ?>
5
- <p><strong><?php echo $this->__('Make Check payable to:') ?></strong> <?php echo $this->htmlEscape($this->getPayableTo()) ?></p>
6
- <?php endif; ?>
7
- <?php if($this->getMailingAddress()): ?>
8
- <p><strong><?php echo Mage::helper('payment')->__('Send to:') ?></strong></p>
9
- <address class="checkmo-mailing-address">
10
- <?php echo nl2br($this->htmlEscape($this->getMailingAddress())) ?>
11
- </address>
12
- <?php endif; ?>
13
- <?php endif; ?>
1
+ <?php
2
+ /**
3
+ * This template displays under the Payment Information section after FuturePay
4
+ * is selected during checkout.
5
+ */
6
+ ?>
7
  <img src="<?php echo $this->getSkinUrl('futurepay/fp_logo.png')?>" alt="FuturePay" title="FuturePay"/>
8
+
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/futurepay/process.phtml DELETED
@@ -1,49 +0,0 @@
1
- <script type="text/javascript" src="<?php echo $this->getCartIntegrationUrl().$this->getToken()?>"></script>
2
- <div class="futurepay-container">
3
- <div id="futurepay-form">
4
- </div>
5
- <div class="button-container futurepay-button-container">
6
- <button id="place_order" class="futurepay-placeorder"><span><span><?php echo $this->__('Pay with Futurepay')?></span></span></button>
7
- <a href="<?php echo $this->getCalcelUrl();?>"><?php echo $this->__('Cancel Order')?></a>
8
- </div>
9
- </div>
10
- <div class="fp-loading-indicator" id="fp-loading-validate-trans" style="display: none;"><label id="fp-loading-label" class="fp-loading-label"><?php echo $this->__('Validating the transaction ...')?>.</label></div>
11
- <script type="text/javascript">
12
- if(typeof(jQuery) != 'undefined'){
13
- jQuery.noConflict();
14
- }
15
- Event.observe(window,'load',function(){
16
- FP.CartIntegration();
17
- $('futurepay-form').update(FP.CartIntegration.getFormContent());
18
-
19
- FP.CartIntegration.displayFuturePay();
20
- /*Bind the Pages pay button to the FuturePay submit action*/
21
- $("place_order").observe('click' , function() {
22
- FP.CartIntegration();
23
- FP.CartIntegration.placeOrder();
24
- });
25
- });
26
-
27
-
28
- function FuturePayResponseHandler(response) {
29
- if (response.error) {
30
- error_code = response.code;
31
- error_reason = response.message;
32
- setLocation('<?php echo $this->getErrorUrl()?>error_code/'+error_code+'/error_reason/'+error_reason);
33
- } else {
34
- $('fp_lean_overlay').setStyle({display:'block'});
35
- $('fp-loading-validate-trans').setStyle({display:'block'});
36
- new Ajax.Request('<?php echo $this->getSuccessUrl();?>', {
37
- method: 'post',
38
- parameters: {transaction_id:response.transaction_id,status:response.status, code:response.code, message:response.message},
39
- onSuccess: function(response1) {
40
- var res = response1.responseText.evalJSON(true);
41
- var redirectUrl = res.url;
42
- setLocation(redirectUrl);
43
- /*$('fp_lean_overlay').setStyle({display:'none'});
44
- $('fp-loading-validate-trans').setStyle({display:'none'});*/
45
- }
46
- });
47
- }
48
- }
49
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Futurepay_Futurepay.xml CHANGED
@@ -4,7 +4,7 @@
4
  <FuturePay_FuturePay>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
- <version>2.0.0</version>
8
  </FuturePay_FuturePay>
9
  </modules>
10
  </config>
4
  <FuturePay_FuturePay>
5
  <active>true</active>
6
  <codePool>community</codePool>
7
+ <version>2.0.11</version>
8
  </FuturePay_FuturePay>
9
  </modules>
10
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FuturePayUS</name>
4
- <version>2.0.0</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>FuturePay Payment method</description>
11
  <notes>FuturePay Payment method</notes>
12
  <authors><author><name>FuturePay</name><user>FuturePay</user><email>support@futurepay.com</email></author></authors>
13
- <date>2015-11-06</date>
14
- <time>18:47:29</time>
15
- <contents><target name="magecommunity"><dir name="FuturePay"><dir name="FuturePay"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="2e5330cf56d9326e6494253a722fb6a7"/></dir></dir></dir></dir><dir name="Form"><file name="Futurepay.php" hash="928319d04c917d5ddaedb078b6ff0fee"/></dir><dir name="Info"><file name="Futurepay.php" hash="391d35864d9154262ebf0efaed106e1f"/></dir><file name="Process.php" hash="08e0f633af8a85a7dc4dfd9e7f2b79ca"/></dir><file name="Exception.php" hash="b6018c078ef8ab18d69870d7913af15d"/><dir name="Helper"><file name="Data.php" hash="d5f98fb53de31ba20db08fea1b768255"/></dir><dir name="Model"><dir name="Method"><file name="Futurepay.php" hash="9b3906fbdd811b938a811e567795fe85"/></dir><file name="Observer.php" hash="efcda6724346652b53373b291e4c7f8f"/><dir name="Resource"><file name="Setup.php" hash="7d4898dfed78dd7c1f68a7eb2b2c1c2c"/></dir><dir name="Source"><dir name="Order"><file name="Status.php" hash="66070c3c22f4e77485d066bcf42fba70"/></dir><dir name="Payment"><file name="Action.php" hash="f16728d656754b7ba3c39c928befdf9b"/></dir><dir name="Title"><file name="Custom.php" hash="42f67d7690fb51bb2be34754814460fb"/></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="bcbfeeb1f63f1dd0d933d61171946e8d"/></dir><dir name="data"><dir name="futurepay_setup"><file name="data-install-2.0.0.php" hash="2608fbf741292211099051a05ea955f1"/></dir></dir><dir name="etc"><file name="config.xml" hash="fd0393b8707005d28db4db7498e0cf60"/><file name="system.xml" hash="dfca12f7c2677e3813ca9f0dfac585ac"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="futurepay"><dir name="info"><file name="futurepay.phtml" hash="89a13ffc42f9748f540f1113fd211adb"/></dir></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="futurepay"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="dc7b5558d5c1c1daf66b40777263a7b6"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="futurepay.xml" hash="77794137dd0ca0f5a6303238ecf2f5fc"/></dir><dir name="template"><dir name="futurepay"><dir name="form"><file name="futurepay.phtml" hash="7213be83f4e9a57b75e8ceb98dea1672"/><file name="mark.phtml" hash="a32647fd6bd685a4a1f077e75a8b74a6"/><file name="redirect.phtml" hash="940a2366dd7d20db0a1d6f20ad0b73a5"/></dir><file name="getmerchantloginform.phtml" hash="07be55268c40cc7a9b38adb3fcc3e984"/><file name="getmerchantsignupform.phtml" hash="f19ea1db17a69235652e178fa9943815"/><file name="getsignuploginform.phtml" hash="d95ce46b1d8ea9b0946aa22452ef1352"/><dir name="info"><file name="futurepay.phtml" hash="d8c5411751e4584f1da371a52c5d68c2"/></dir><file name="process.phtml" hash="a753b7480e4e051a0d73d2d8a595755f"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Futurepay_Futurepay.xml" hash="aa4902e36c1fffd9e96095f6922e713d"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="futurepay"><file name="fp_logo.png" hash="60e4e682eef20864809ec3f926644949"/><file name="fp_logo2.png" hash="60e4e682eef20864809ec3f926644949"/><file name="futurepay-admin.js" hash="81d1e4d79a17c97767e689f1cd944e9c"/><file name="logoFuturePay.png" hash="abb71de2bc68b37977912e4080c989ec"/><file name="styles.css" hash="c02378ea658f89170c14a3cdc98ed051"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="futurepay"><file name="arrow.png" hash="d7a4d12c203f5ed5737d3f6a234c74d1"/><file name="fpButton.jpg" hash="f7df14b706e3b2a0b31f3d5c27f8935a"/><file name="fpButton18.jpg" hash="dbd3ef259fb82d32e44cf59614863b70"/><file name="fp_logo.png" hash="60e4e682eef20864809ec3f926644949"/><file name="fp_small_logo.png" hash="48f55b6d15211f8a3f9dfb1f235ef97b"/><file name="fplogo.png" hash="8a5b8bc294a0000e0a1e3fde72f27cbf"/><file name="icon-cart.png" hash="aa67b5e00c64c036a9a8afb52acd7298"/><file name="icon-fee.png" hash="e2febdcd148e61f150f3be0dff801e8c"/><file name="icon-secure.png" hash="56c126fdff3de22449bd056b58b31769"/><file name="styles.css" hash="fd5f32d6a9958da063233ba42f79d993"/><file name="styles18.css" hash="d0ba202a717e69ee8973c4a5369d666f"/><file name="styles19.css" hash="43b9ecac346f0fb1138c7af89e68f1ae"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>FuturePayUS</name>
4
+ <version>2.0.11</version>
5
  <stability>stable</stability>
6
  <license>OSL</license>
7
  <channel>community</channel>
10
  <description>FuturePay Payment method</description>
11
  <notes>FuturePay Payment method</notes>
12
  <authors><author><name>FuturePay</name><user>FuturePay</user><email>support@futurepay.com</email></author></authors>
13
+ <date>2016-02-19</date>
14
+ <time>21:15:26</time>
15
+ <contents><target name="magecommunity"><dir name="FuturePay"><dir name="FuturePay"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="2e5330cf56d9326e6494253a722fb6a7"/></dir></dir></dir></dir><dir name="Form"><file name="Futurepay.php" hash="8e648a82888bffa8e126fc8a5b614f6d"/></dir><dir name="Info"><file name="Futurepay.php" hash="0bd56d572de0a7caac361af77a4523d5"/></dir></dir><file name="Exception.php" hash="b6018c078ef8ab18d69870d7913af15d"/><dir name="Helper"><file name="Data.php" hash="801f054a8faf4a529e3bfa68fff8a1ed"/></dir><dir name="Model"><dir name="Method"><file name="Futurepay.php" hash="8b4427802fcbe2bb71d0fd6e29530d6c"/></dir><dir name="Resource"><file name="Setup.php" hash="24f825392a5c11fcf2ba9fe30344a18f"/></dir><dir name="Source"><dir name="Order"><file name="Status.php" hash="207765f2c921e9e8450c9b2685cf9c1f"/></dir><dir name="Payment"><file name="Action.php" hash="d7838e85e31e68a8f70c66494f70d448"/></dir><dir name="Title"><file name="Custom.php" hash="230f86ba256695b0610b87f963c176b2"/></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="af1d397445ce1cf03da84de99c52ca20"/></dir><dir name="data"><dir name="futurepay_setup"><file name="data-install-2.0.11.php" hash="d5e6641e935d6cb4c42c816bc24ebe25"/></dir></dir><dir name="etc"><file name="config.xml" hash="e2553de8381c4e2e7d697f4d52ed0660"/><file name="system.xml" hash="dfca12f7c2677e3813ca9f0dfac585ac"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="futurepay"><dir name="info"><file name="futurepay.phtml" hash="e2987d12a1c108fad0a0cd0538c84431"/></dir></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="futurepay"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="dc7b5558d5c1c1daf66b40777263a7b6"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="futurepay.xml" hash="cfe8a678265cb52aef1a6d84694b52de"/></dir><dir name="template"><dir name="futurepay"><dir name="form"><file name="futurepay.phtml" hash="7213be83f4e9a57b75e8ceb98dea1672"/><file name="mark.phtml" hash="952225dcc94e2cb88882ccfca3bbc6fc"/><file name="redirect.phtml" hash="4aa45be8736d51183b2ce7cd337d4859"/></dir><file name="getmerchantloginform.phtml" hash="07be55268c40cc7a9b38adb3fcc3e984"/><file name="getmerchantsignupform.phtml" hash="f19ea1db17a69235652e178fa9943815"/><file name="getsignuploginform.phtml" hash="d95ce46b1d8ea9b0946aa22452ef1352"/><dir name="info"><file name="futurepay.phtml" hash="e4354bf5873f099ef1009718e056b8a8"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Futurepay_Futurepay.xml" hash="fdba227195487a1aff8a27775a40f1f4"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="futurepay"><file name="fp_logo.png" hash="60e4e682eef20864809ec3f926644949"/><file name="fp_logo2.png" hash="60e4e682eef20864809ec3f926644949"/><file name="futurepay-admin.js" hash="81d1e4d79a17c97767e689f1cd944e9c"/><file name="logoFuturePay.png" hash="abb71de2bc68b37977912e4080c989ec"/><file name="styles.css" hash="c02378ea658f89170c14a3cdc98ed051"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="futurepay"><file name="arrow.png" hash="d7a4d12c203f5ed5737d3f6a234c74d1"/><file name="fpButton.jpg" hash="f7df14b706e3b2a0b31f3d5c27f8935a"/><file name="fpButton18.jpg" hash="dbd3ef259fb82d32e44cf59614863b70"/><file name="fp_logo.png" hash="60e4e682eef20864809ec3f926644949"/><file name="fp_small_logo.png" hash="48f55b6d15211f8a3f9dfb1f235ef97b"/><file name="fplogo.png" hash="8a5b8bc294a0000e0a1e3fde72f27cbf"/><file name="icon-cart.png" hash="aa67b5e00c64c036a9a8afb52acd7298"/><file name="icon-fee.png" hash="e2febdcd148e61f150f3be0dff801e8c"/><file name="icon-secure.png" hash="56c126fdff3de22449bd056b58b31769"/><file name="styles.css" hash="fd5f32d6a9958da063233ba42f79d993"/><file name="styles18.css" hash="d0ba202a717e69ee8973c4a5369d666f"/><file name="styles19.css" hash="43b9ecac346f0fb1138c7af89e68f1ae"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>