Version Notes
First release.
Download this release
Release Info
Developer | Apruve |
Extension | Apruve_B2B_Payment_Gateway |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Apruve/ApruvePayment/Block/Admin/Webhook.php +29 -0
- app/code/community/Apruve/ApruvePayment/Block/Payment/Form.php +40 -0
- app/code/community/Apruve/ApruvePayment/Block/Review.php +47 -0
- app/code/community/Apruve/ApruvePayment/Block/Review/Billing.php +28 -0
- app/code/community/Apruve/ApruvePayment/Block/Review/Details.php +32 -0
- app/code/community/Apruve/ApruvePayment/Block/Review/Result.php +13 -0
- app/code/community/Apruve/ApruvePayment/Block/Review/Shipping.php +22 -0
- app/code/community/Apruve/ApruvePayment/Helper/Data.php +23 -0
- app/code/community/Apruve/ApruvePayment/Model/Api/Abstract.php +94 -0
- app/code/community/Apruve/ApruvePayment/Model/Api/PaymentRequest.php +233 -0
- app/code/community/Apruve/ApruvePayment/Model/Api/Rest.php +113 -0
- app/code/community/Apruve/ApruvePayment/Model/Mysql4/Setup.php +6 -0
- app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php +94 -0
- app/code/community/Apruve/ApruvePayment/Model/Session.php +9 -0
- app/code/community/Apruve/ApruvePayment/controllers/PaymentController.php +175 -0
- app/code/community/Apruve/ApruvePayment/controllers/WebhookController.php +108 -0
- app/code/community/Apruve/ApruvePayment/etc/config.xml +74 -0
- app/code/community/Apruve/ApruvePayment/etc/system.xml +77 -0
- app/design/frontend/default/default/layout/apruvepayment.xml +48 -0
- app/design/frontend/default/default/template/apruvepayment/head.phtml +6 -0
- app/design/frontend/default/default/template/apruvepayment/payment/form.phtml +4 -0
- app/design/frontend/default/default/template/apruvepayment/payment/mark.phtml +13 -0
- app/design/frontend/default/default/template/apruvepayment/review.phtml +70 -0
- app/design/frontend/default/default/template/apruvepayment/review/address.phtml +398 -0
- app/design/frontend/default/default/template/apruvepayment/review/details.phtml +64 -0
- app/design/frontend/default/default/template/apruvepayment/review/result.phtml +1 -0
- app/design/frontend/default/default/template/apruvepayment/review/shipping/method.phtml +53 -0
- app/design/frontend/default/default/template/apruvepayment/review/shipping_method.phtml +17 -0
- app/design/frontend/default/default/template/apruvepayment/shortcut.phtml +11 -0
- app/etc/modules/Apruve_ApruvePayment.xml +8 -0
- js/Apruve/ApruvePayment.js +88 -0
- package.xml +18 -0
app/code/community/Apruve/ApruvePayment/Block/Admin/Webhook.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: Saa
|
5 |
+
* Date: 14.10.13
|
6 |
+
* Time: 12:08
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Apruve_ApruvePayment_Block_Admin_Webhook extends Mage_Adminhtml_Block_System_Config_Form_Field
|
11 |
+
{
|
12 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
13 |
+
{
|
14 |
+
$merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
|
15 |
+
$apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
|
16 |
+
$baseFrontUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
17 |
+
$moduleControllerAction = 'apruvepayment/webhook/updateOrderStatus?';
|
18 |
+
if(!is_null($merchantKey) && !is_null($apiKey)) {
|
19 |
+
$data = $apiKey.$merchantKey;
|
20 |
+
$q = hash('sha256', $data);
|
21 |
+
$url = $baseFrontUrl.$moduleControllerAction.$q;
|
22 |
+
return $url;
|
23 |
+
} else {
|
24 |
+
|
25 |
+
$message = 'Please, specify merchant and api key';
|
26 |
+
return $message;
|
27 |
+
}
|
28 |
+
}
|
29 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Payment/Form.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: Saa
|
5 |
+
* Date: 24.09.13
|
6 |
+
* Time: 13:37
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Apruve_ApruvePayment_Block_Payment_Form extends Mage_Payment_Block_Form
|
11 |
+
{
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('apruvepayment/payment/form.phtml');
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Check if payment method has title
|
20 |
+
* @return bool
|
21 |
+
*/
|
22 |
+
public function hasMethodTitle()
|
23 |
+
{
|
24 |
+
return true;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Set Mark template
|
29 |
+
*/
|
30 |
+
public function getMethodTitle()
|
31 |
+
{
|
32 |
+
$locale = Mage::app()->getLocale();
|
33 |
+
|
34 |
+
$mark = Mage::getConfig()->getBlockClassName('core/template');
|
35 |
+
$mark = new $mark;
|
36 |
+
$mark->setTemplate('apruvepayment/payment/mark.phtml');
|
37 |
+
|
38 |
+
$this->setMethodLabelAfterHtml($mark->toHtml());
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Review.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: Saa
|
5 |
+
* Date: 01.10.13
|
6 |
+
* Time: 13:09
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Apruve_ApruvePayment_Block_Review extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Get url for place order action
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function getPlaceOrderUrl()
|
17 |
+
{
|
18 |
+
return $this->getUrl('apruvepayment/payment/placeOrder');
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
private function _getCheckoutSession()
|
23 |
+
{
|
24 |
+
return Mage::getSingleton('checkout/session');
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Get error
|
29 |
+
* @return mixed
|
30 |
+
*/
|
31 |
+
public function getErrors()
|
32 |
+
{
|
33 |
+
$errors = $this->getApruveSession()->getErrors();
|
34 |
+
$this->getApruveSession()->unsetData('errors');
|
35 |
+
return $errors;
|
36 |
+
}
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* @return Apruve_ApruvePayment_Model_Session
|
41 |
+
*/
|
42 |
+
public function getApruveSession()
|
43 |
+
{
|
44 |
+
return Mage::getSingleton('apruvepayment/session');
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Review/Billing.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Block_Review_Billing extends Mage_Checkout_Block_Onepage_Billing
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Return Sales Quote Address model
|
7 |
+
*
|
8 |
+
* @return Mage_Sales_Model_Quote_Address
|
9 |
+
*/
|
10 |
+
public function getAddress()
|
11 |
+
{
|
12 |
+
if (is_null($this->_address)) {
|
13 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) {
|
14 |
+
$this->_address = $this->getQuote()->getBillingAddress();
|
15 |
+
if (!$this->_address->getFirstname()) {
|
16 |
+
$this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname());
|
17 |
+
}
|
18 |
+
if (!$this->_address->getLastname()) {
|
19 |
+
$this->_address->setLastname($this->getQuote()->getCustomer()->getLastname());
|
20 |
+
}
|
21 |
+
} else {
|
22 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this->_address;
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Review/Details.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Block_Review_Details extends Mage_Checkout_Block_Cart_Totals
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @var Mage_Sales_Model_Order_Address
|
7 |
+
*/
|
8 |
+
protected $_address;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Return review shipping address
|
12 |
+
*
|
13 |
+
* @return Mage_Sales_Model_Order_Address
|
14 |
+
*/
|
15 |
+
public function getAddress()
|
16 |
+
{
|
17 |
+
if (empty($this->_address)) {
|
18 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
19 |
+
}
|
20 |
+
return $this->_address;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Return review quote totals
|
25 |
+
*
|
26 |
+
* @return array
|
27 |
+
*/
|
28 |
+
public function getTotals()
|
29 |
+
{
|
30 |
+
return $this->getQuote()->getTotals();
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Review/Result.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: Saa
|
5 |
+
* Date: 02.10.13
|
6 |
+
* Time: 18:06
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Apruve_ApruvePayment_Block_Review_Result extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
|
13 |
+
}
|
app/code/community/Apruve/ApruvePayment/Block/Review/Shipping.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Block_Review_Shipping extends Mage_Checkout_Block_Onepage_Shipping
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Return Sales Quote Address model (shipping address)
|
7 |
+
*
|
8 |
+
* @return Mage_Sales_Model_Quote_Address
|
9 |
+
*/
|
10 |
+
public function getAddress()
|
11 |
+
{
|
12 |
+
if (is_null($this->_address)) {
|
13 |
+
if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) {
|
14 |
+
$this->_address = $this->getQuote()->getShippingAddress();
|
15 |
+
} else {
|
16 |
+
$this->_address = Mage::getModel('sales/quote_address');
|
17 |
+
}
|
18 |
+
}
|
19 |
+
|
20 |
+
return $this->_address;
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Apruve/ApruvePayment/Helper/Data.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Apruve_ApruvePayment_Helper_Data extends Mage_Core_Helper_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @return Apruve_ApruvePayment_Model_Api_PaymentRequest
|
8 |
+
*/
|
9 |
+
public function getPaymentRequestApiModel()
|
10 |
+
{
|
11 |
+
return Mage::getModel('apruvepayment/api_PaymentRequest');
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return string url
|
17 |
+
*/
|
18 |
+
public function getAjaxAddressUpdatedUrl()
|
19 |
+
{
|
20 |
+
$secure = Mage::app()->getStore()->isCurrentlySecure() ? true : false;
|
21 |
+
return Mage::getUrl('apruvepayment/payment/ajaxSetAddressUpdated', array('_secure' => $secure));
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Apruve/ApruvePayment/Model/Api/Abstract.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
abstract class Apruve_ApruvePayment_Model_Api_Abstract
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* @var string
|
8 |
+
*/
|
9 |
+
protected $_version = 'v3';
|
10 |
+
//protected $_testMode;
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Generate headers for rest request
|
15 |
+
* @return array
|
16 |
+
*/
|
17 |
+
protected function _getHeaders()
|
18 |
+
{
|
19 |
+
return array(
|
20 |
+
'Content-type: application/json',
|
21 |
+
'Apruve-Api-Key: ' . $this->_getApiKey(),
|
22 |
+
);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Get Merchant key from module configuration
|
27 |
+
* @return string|null
|
28 |
+
*/
|
29 |
+
protected function _getMerchantKey()
|
30 |
+
{
|
31 |
+
$id = Mage::getStoreConfig('payment/apruvepayment/merchant');
|
32 |
+
return $id ? $id : null;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Get Api key from module configuration
|
37 |
+
* @return string|null
|
38 |
+
*/
|
39 |
+
protected function _getApiKey()
|
40 |
+
{
|
41 |
+
$api = Mage::getStoreConfig('payment/apruvepayment/api');
|
42 |
+
return $api ? $api : null;
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Check whether payment works in test mode
|
49 |
+
* @return bool
|
50 |
+
*/
|
51 |
+
protected function _getIsTestMode()
|
52 |
+
{
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Get Apruve base url based on mode
|
59 |
+
* @param bool $secure
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getBaseUrl($secure = false)
|
63 |
+
{
|
64 |
+
$http = $secure ? 'https://' : 'http://';
|
65 |
+
if($this->_getIsTestMode()) {
|
66 |
+
return $http.'test.apruve.com/';
|
67 |
+
} else {
|
68 |
+
return $http.'apruve.com/';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get api url part based on version
|
75 |
+
* @return string
|
76 |
+
*/
|
77 |
+
protected function _getApiUrl()
|
78 |
+
{
|
79 |
+
return 'api/'.$this->_version.'/';
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Convert price to needed value
|
85 |
+
* As current version supports only USD, convert price to cents
|
86 |
+
* @param float $price
|
87 |
+
* @return float
|
88 |
+
*/
|
89 |
+
protected function _convertPrice($price)
|
90 |
+
{
|
91 |
+
return $price * 100;
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
app/code/community/Apruve/ApruvePayment/Model/Api/PaymentRequest.php
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Apruve_ApruvePayment_Model_Api_PaymentRequest
|
4 |
+
* Provide methods to build paymentRequest
|
5 |
+
* @see https://apruvit.atlassian.net/wiki/display/DOCCO/payment_request
|
6 |
+
*/
|
7 |
+
class Apruve_ApruvePayment_Model_Api_PaymentRequest extends Apruve_ApruvePayment_Model_Api_Abstract
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* Post request general fields
|
11 |
+
* @var array
|
12 |
+
*/
|
13 |
+
protected $_postFields = array(
|
14 |
+
//required
|
15 |
+
'merchant_id',
|
16 |
+
'amount_cents',
|
17 |
+
'line_items' => array(),
|
18 |
+
//optional
|
19 |
+
'tax_cents',
|
20 |
+
'shipping_cents',
|
21 |
+
'currency', // current only USD
|
22 |
+
);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Line Items Fields
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
protected $_lineItemFields = array(
|
29 |
+
//required
|
30 |
+
'title',
|
31 |
+
'amount_cents', // if qty -> should chanfe
|
32 |
+
'description',
|
33 |
+
'variant_info',
|
34 |
+
'sku',
|
35 |
+
'vendor',
|
36 |
+
'price_ea_cents',
|
37 |
+
'view_product_url',
|
38 |
+
);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @var array
|
42 |
+
*/
|
43 |
+
protected $_paymentRequest;
|
44 |
+
|
45 |
+
|
46 |
+
public function __construct()
|
47 |
+
{
|
48 |
+
$this->_paymentRequest = $this->_setPaymentRequest();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get json encoded payment request
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function getPaymentRequestJSON()
|
56 |
+
{
|
57 |
+
return json_encode($this->_paymentRequest);
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get secure hash
|
62 |
+
* @see https://apruvit.atlassian.net/wiki/display/DOCCO/Checkout+Page+Tutorial#CheckoutPageTutorial-1b:CreatingaSecureHash
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function getSecureHash()
|
66 |
+
{
|
67 |
+
$concatString = $this->_getApiKey();
|
68 |
+
|
69 |
+
foreach ($this->_paymentRequest as $val) {
|
70 |
+
if(!is_array($val)) {
|
71 |
+
$concatString .= $val;
|
72 |
+
} else {
|
73 |
+
foreach($val as $v) {
|
74 |
+
foreach ($v as $s) {
|
75 |
+
$concatString .= $s;
|
76 |
+
}
|
77 |
+
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return hash('sha256', $concatString);
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Build Payment Request Array
|
88 |
+
* @return array
|
89 |
+
*/
|
90 |
+
protected function _setPaymentRequest()
|
91 |
+
{
|
92 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
93 |
+
$paymentRequest = array(
|
94 |
+
'merchant_id' => $this->_getMerchantKey(),
|
95 |
+
'amount_cents' => $this->_convertPrice($quote->getGrandTotal()),
|
96 |
+
'currency' => 'USD',
|
97 |
+
'tax_cents' => $this->_convertPrice($quote->getShippingAddress()->getTaxAmount()),
|
98 |
+
'shipping_cents' => $this->_convertPrice($quote->getShippingAddress()->getShippingAmount()),
|
99 |
+
'line_items' => $this->_getLineItems($quote),
|
100 |
+
);
|
101 |
+
|
102 |
+
return $paymentRequest;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Build Line items array
|
107 |
+
* @param Mage_Sales_Model_Quote $quote
|
108 |
+
* @return array
|
109 |
+
*/
|
110 |
+
protected function _getLineItems($quote)
|
111 |
+
{
|
112 |
+
$line_items = array();
|
113 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
114 |
+
$qty = $item->getQty();
|
115 |
+
$title = $item->getName();
|
116 |
+
$amount_cents = $this->_convertPrice($item->getPrice()) * $qty;
|
117 |
+
$shortDescription = $item->getShortDescription();
|
118 |
+
$viewUrl = $item->getProduct()->getProductUrl(false);
|
119 |
+
$priceEaCents = $this->_convertPrice($item->getPrice());
|
120 |
+
|
121 |
+
$line_item = array(
|
122 |
+
'title' => $title,
|
123 |
+
'amount_cents' => $amount_cents,
|
124 |
+
'description' => $shortDescription,
|
125 |
+
'view_product_url' => $viewUrl,
|
126 |
+
'price_ea_cents' => $priceEaCents,
|
127 |
+
'quantity' => $qty,
|
128 |
+
|
129 |
+
);
|
130 |
+
|
131 |
+
$variantInfo = $this->_getVariantInfo($item);
|
132 |
+
if($variantInfo) {
|
133 |
+
$line_item['variant_info'] = $variantInfo;
|
134 |
+
}
|
135 |
+
|
136 |
+
$line_items[] = $line_item;
|
137 |
+
}
|
138 |
+
|
139 |
+
return $line_items;
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Get Product configuration if exits
|
145 |
+
* @param Mage_Sales_Model_Quote_Item $item
|
146 |
+
* @return string
|
147 |
+
*/
|
148 |
+
protected function _getVariantInfo($item)
|
149 |
+
{
|
150 |
+
$result = '';
|
151 |
+
$variantInfo = array();
|
152 |
+
$options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());
|
153 |
+
if(isset($options['options'])) {
|
154 |
+
$opt = $this->_getProductCustomOptions($options['options']);
|
155 |
+
$variantInfo = array_merge($variantInfo, $opt);
|
156 |
+
}
|
157 |
+
if(isset($options['attributes_info'])) {
|
158 |
+
$opt = $this->_getConfigurableOptions($options['attributes_info']);
|
159 |
+
$variantInfo = array_merge($variantInfo, $opt);
|
160 |
+
}
|
161 |
+
|
162 |
+
if(isset($options['bundle_options'])) {
|
163 |
+
$opt = $this->_getBundleOptions($options['bundle_options']);
|
164 |
+
$variantInfo = array_merge($variantInfo, $opt);
|
165 |
+
}
|
166 |
+
|
167 |
+
if(!empty($variantInfo)) {
|
168 |
+
$result = $this->_getFormatedVariantInfo($variantInfo);
|
169 |
+
}
|
170 |
+
|
171 |
+
return $result;
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* @param array $options
|
177 |
+
* @return array
|
178 |
+
*/
|
179 |
+
protected function _getProductCustomOptions($options)
|
180 |
+
{
|
181 |
+
$arr = array();
|
182 |
+
foreach ($options as $option) {
|
183 |
+
$arr[] = $option['label'].': '.$option['value'];
|
184 |
+
}
|
185 |
+
|
186 |
+
return $arr;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @param array $attributesInfo
|
191 |
+
* @return array
|
192 |
+
*/
|
193 |
+
protected function _getConfigurableOptions($attributesInfo)
|
194 |
+
{
|
195 |
+
$arr = array();
|
196 |
+
foreach ($attributesInfo as $option) {
|
197 |
+
$arr[] = $option['label'].': '.$option['value'];
|
198 |
+
}
|
199 |
+
return $arr;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @param array $bundleOptions
|
204 |
+
* @return array
|
205 |
+
*/
|
206 |
+
protected function _getBundleOptions($bundleOptions)
|
207 |
+
{
|
208 |
+
$arr = array();
|
209 |
+
foreach($bundleOptions as $option) {
|
210 |
+
$arr[] = $option['label'].': '.$option['value'][0]['title'];
|
211 |
+
}
|
212 |
+
return $arr;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* Concatenate all options to string
|
217 |
+
* @param array $arr
|
218 |
+
* @return string
|
219 |
+
*/
|
220 |
+
//todo: new line symbol
|
221 |
+
protected function _getFormatedVariantInfo($arr)
|
222 |
+
{
|
223 |
+
if(count($arr) == 1) {
|
224 |
+
$result = $arr[0];
|
225 |
+
} else {
|
226 |
+
$result = implode(', ', $arr);
|
227 |
+
}
|
228 |
+
|
229 |
+
return $result;
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
233 |
+
|
app/code/community/Apruve/ApruvePayment/Model/Api/Rest.php
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Class Apruve_ApruvePayment_Model_Api_Rest
|
4 |
+
*
|
5 |
+
* Provide rest methods to communicate with apruve
|
6 |
+
*/
|
7 |
+
|
8 |
+
class Apruve_ApruvePayment_Model_Api_Rest extends Apruve_ApruvePayment_Model_Api_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Send Payment object
|
12 |
+
* @param string $paymentRequestId
|
13 |
+
* @param float $amount
|
14 |
+
* @return bool
|
15 |
+
*/
|
16 |
+
public function postPayment($paymentRequestId, $amount)
|
17 |
+
{
|
18 |
+
$data = json_encode(array('amount_cents' => $this->_convertPrice($amount)));
|
19 |
+
|
20 |
+
$c = curl_init($this->_getPaymentUrl($paymentRequestId));
|
21 |
+
|
22 |
+
curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
|
23 |
+
curl_setopt($c, CURLOPT_POST, true);
|
24 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
|
25 |
+
curl_setopt($c, CURLOPT_HEADER, true);
|
26 |
+
curl_setopt($c, CURLOPT_POSTFIELDS, $data );
|
27 |
+
$response = curl_exec($c);
|
28 |
+
$http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
|
29 |
+
curl_close($c);
|
30 |
+
|
31 |
+
if($http_status == '201') {
|
32 |
+
return true;
|
33 |
+
} else {
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Update paymentRequest object
|
41 |
+
* Availible fields to update are: amount_cents, shipping_cents, tax_cents
|
42 |
+
* @param string $paymentRequestId
|
43 |
+
* @param float $amount
|
44 |
+
* @param float $shipping
|
45 |
+
* @param float $tax
|
46 |
+
* @return bool
|
47 |
+
*/
|
48 |
+
public function updatePaymentRequest($paymentRequestId, $amount, $shipping, $tax)
|
49 |
+
{
|
50 |
+
$data = json_encode(array(
|
51 |
+
'amount_cents' => $this->_convertPrice($amount),
|
52 |
+
'shipping_cents' => $this->_convertPrice($shipping),
|
53 |
+
'tax_cents' => $this->_convertPrice($tax),
|
54 |
+
));
|
55 |
+
|
56 |
+
$c = curl_init($this->_getUpdatePaymentRequestUrl($paymentRequestId));
|
57 |
+
|
58 |
+
curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
|
59 |
+
curl_setopt($c, CURLOPT_CUSTOMREQUEST, "PUT");
|
60 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
|
61 |
+
curl_setopt($c, CURLOPT_HEADER, true);
|
62 |
+
curl_setopt($c, CURLOPT_POSTFIELDS, $data );
|
63 |
+
$response = curl_exec($c);
|
64 |
+
$http_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
|
65 |
+
curl_close($c);
|
66 |
+
|
67 |
+
|
68 |
+
if($http_status == '200') {
|
69 |
+
return true;
|
70 |
+
} else {
|
71 |
+
return false;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* GET Apruve Payment Status
|
77 |
+
* Check whether given status is same as in Apruve.com
|
78 |
+
* @param $status
|
79 |
+
* @param $apiUrl
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public function getApruveOrderStatus($apiUrl, $status)
|
83 |
+
{
|
84 |
+
$c = curl_init($apiUrl);
|
85 |
+
curl_setopt($c, CURLOPT_HTTPHEADER, $this->_getHeaders());
|
86 |
+
curl_setopt($c, CURLOPT_CUSTOMREQUEST, "GET");
|
87 |
+
curl_setopt($c, CURLOPT_RETURNTRANSFER, true );
|
88 |
+
curl_setopt($c, CURLOPT_HEADER, true);
|
89 |
+
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Get url for send payment
|
95 |
+
* @param string $paymentRequestId
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
protected function _getPaymentUrl($paymentRequestId)
|
99 |
+
{
|
100 |
+
return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId.'/payments';
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Get url for update paymentRequest
|
106 |
+
* @param string $paymentRequestId
|
107 |
+
* @return string
|
108 |
+
*/
|
109 |
+
protected function _getUpdatePaymentRequestUrl($paymentRequestId)
|
110 |
+
{
|
111 |
+
return $this->getBaseUrl(true).$this->_getApiUrl().'payment_requests/'.$paymentRequestId;
|
112 |
+
}
|
113 |
+
}
|
app/code/community/Apruve/ApruvePayment/Model/Mysql4/Setup.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Model_Mysql4_Setup extends Mage_Catalog_Model_Resource_Eav_Mysql4_Setup
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/community/Apruve/ApruvePayment/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
|
4 |
+
{
|
5 |
+
protected $_code = 'apruvepayment';
|
6 |
+
protected $_formBlockType = 'apruvepayment/payment_form';
|
7 |
+
|
8 |
+
protected $_isGateway = false;
|
9 |
+
protected $_canOrder = true;
|
10 |
+
protected $_canAuthorize = true;
|
11 |
+
protected $_canCapture = true;
|
12 |
+
protected $_canCapturePartial = false;
|
13 |
+
protected $_canRefund = false;
|
14 |
+
protected $_canRefundInvoicePartial = false;
|
15 |
+
protected $_canVoid = true;
|
16 |
+
protected $_canUseInternal = false;
|
17 |
+
protected $_canUseCheckout = true;
|
18 |
+
protected $_canUseForMultishipping = false;
|
19 |
+
protected $_canFetchTransactionInfo = true;
|
20 |
+
protected $_canCreateBillingAgreement = true;
|
21 |
+
protected $_canReviewPayment = true;
|
22 |
+
|
23 |
+
public function getCheckoutRedirectUrl()
|
24 |
+
{
|
25 |
+
return Mage::getUrl('apruvepayment/payment/review');
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Assign data to info model instance
|
31 |
+
*
|
32 |
+
* @param mixed $data
|
33 |
+
* @return Mage_Payment_Model_Info
|
34 |
+
*/
|
35 |
+
public function assignData($data)
|
36 |
+
{
|
37 |
+
//$result = parent::assignData($data);
|
38 |
+
if (is_array($data)) {
|
39 |
+
$this->getInfoInstance()->setAdditionalInformation('aprt', isset($data['aprt']) ? $data['aprt'] : null);
|
40 |
+
}
|
41 |
+
elseif ($data instanceof Varien_Object) {
|
42 |
+
$aprt = $data->getAprt();
|
43 |
+
$this->getInfoInstance()->setAdditionalInformation('aprt', isset($aprt) ? $aprt : null);
|
44 |
+
}
|
45 |
+
return $this;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Check whether apruve payment request id(aprt) is exitst
|
50 |
+
* @return Mage_Payment_Model_Abstract|void
|
51 |
+
*/
|
52 |
+
public function validate()
|
53 |
+
{
|
54 |
+
if(!$this->getInfoInstance()->getAdditionalInformation('aprt')) {
|
55 |
+
Mage::throwException('Smth going wrong, try again to post order with apruve');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getConfigPaymentAction()
|
63 |
+
{
|
64 |
+
return 'order';
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get token and create transaction
|
69 |
+
* @param Varien_Object $payment
|
70 |
+
* @param float $amount
|
71 |
+
* @return Mage_Payment_Model_Abstract|void
|
72 |
+
*/
|
73 |
+
public function order(Varien_Object $payment, $amount)
|
74 |
+
{
|
75 |
+
$additionalInformation = $payment->getAdditionalInformation();
|
76 |
+
$token = $additionalInformation['aprt'];
|
77 |
+
|
78 |
+
//$amount = $payment->getBaseAmountOrdered() * 100; //cents
|
79 |
+
//$rest = Mage::getModel('apruvepayment/api_rest');
|
80 |
+
//$rest->postPayment($token, $amount); //return true or false
|
81 |
+
//$payment->setSkipOrderProcessing(true);
|
82 |
+
//echo 1;exit;
|
83 |
+
|
84 |
+
$payment->setTransactionId($token);
|
85 |
+
$payment->setIsTransactionClosed(0);
|
86 |
+
$payment->resetTransactionAdditionalInfo();
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
public function capture(Varien_Object $payment, $amount)
|
91 |
+
{
|
92 |
+
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Apruve/ApruvePayment/Model/Session.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_Model_Session extends Mage_Core_Model_Session_Abstract
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->init('apruvepayment');
|
8 |
+
}
|
9 |
+
}
|
app/code/community/Apruve/ApruvePayment/controllers/PaymentController.php
ADDED
@@ -0,0 +1,175 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apruve_ApruvePayment_PaymentController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
public function reviewAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->renderLayout();
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Return checkout session object
|
13 |
+
*
|
14 |
+
* @return Mage_Checkout_Model_Session
|
15 |
+
*/
|
16 |
+
private function _getCheckoutSession()
|
17 |
+
{
|
18 |
+
return Mage::getSingleton('checkout/session');
|
19 |
+
}
|
20 |
+
|
21 |
+
|
22 |
+
public function placeOrderAction()
|
23 |
+
{
|
24 |
+
$checkoutSession = $this->_getCheckoutSession();
|
25 |
+
$errors = array();
|
26 |
+
//call rest api and get result if its ok, proceed
|
27 |
+
$quote = $checkoutSession->getQuote();
|
28 |
+
|
29 |
+
$payment = $quote->getPayment();
|
30 |
+
$method = $payment->getMethodInstance();
|
31 |
+
$infoIstance = $method->getInfoInstance();
|
32 |
+
|
33 |
+
$token = $infoIstance->getAdditionalInformation('aprt');
|
34 |
+
$amount = $quote->getBaseGrandTotal();
|
35 |
+
|
36 |
+
$rest = Mage::getModel('apruvepayment/api_rest');
|
37 |
+
|
38 |
+
$session = Mage::getSingleton('apruvepayment/session');
|
39 |
+
if($session->getAddressUpdated()) {
|
40 |
+
$tax = $quote->getShippingAddress()->getTaxAmount();
|
41 |
+
$shipping = $quote->getShippingAddress()->getShippingAmount();
|
42 |
+
if(!$rest->updatePaymentRequest($token, $amount, $shipping, $tax))
|
43 |
+
{
|
44 |
+
//show errors
|
45 |
+
$errors['couldnt_update'] = 'Couldn\'t update order totals to Apruve';
|
46 |
+
$session->setErrors($errors);
|
47 |
+
return $this->_redirect("*/*/review");
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
if(!$rest->postPayment($token, $amount)) {
|
52 |
+
//show errors
|
53 |
+
$errors['couldnt_rest_payment'] = 'Apruve couldn\'t process order information';
|
54 |
+
$session->setErrors($errors);
|
55 |
+
return $this->_redirect("*/*/review");
|
56 |
+
}
|
57 |
+
|
58 |
+
$quote = $checkoutSession->getQuote();
|
59 |
+
$quote->collectTotals();
|
60 |
+
|
61 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
62 |
+
$service->submitAll();
|
63 |
+
|
64 |
+
$quote->save();
|
65 |
+
|
66 |
+
$checkoutSession->clearHelperData();
|
67 |
+
|
68 |
+
// last successful quote
|
69 |
+
$quoteId = $quote->getId();
|
70 |
+
|
71 |
+
$checkoutSession->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
|
72 |
+
|
73 |
+
$order = $service->getOrder();
|
74 |
+
if ($order) {
|
75 |
+
$checkoutSession->setLastOrderId($order->getId())
|
76 |
+
->setLastRealOrderId($order->getIncrementId());
|
77 |
+
} else {
|
78 |
+
//error
|
79 |
+
}
|
80 |
+
|
81 |
+
$session->unsetData('address_updated');
|
82 |
+
return $this->_redirect('checkout/onepage/success');
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/*public function detailsAction()
|
87 |
+
{
|
88 |
+
$session = $this->_getCheckoutSession();
|
89 |
+
if (!$session->getLastSuccessQuoteId()) {
|
90 |
+
$this->_redirect('checkout/cart');
|
91 |
+
return;
|
92 |
+
}
|
93 |
+
|
94 |
+
$lastQuoteId = $session->getLastQuoteId();
|
95 |
+
$lastOrderId = $session->getLastOrderId();
|
96 |
+
$lastRecurringProfiles = $session->getLastRecurringProfileIds();
|
97 |
+
if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
|
98 |
+
$this->_redirect('checkout/cart');
|
99 |
+
return;
|
100 |
+
}
|
101 |
+
|
102 |
+
//$session->clear();
|
103 |
+
$this->loadLayout();
|
104 |
+
//$this->_initLayoutMessages('checkout/session');
|
105 |
+
$this->renderLayout();
|
106 |
+
}*/
|
107 |
+
|
108 |
+
|
109 |
+
public function updateBillingAddressAction()
|
110 |
+
{
|
111 |
+
$data = $this->getRequest()->getPost('billing', array());
|
112 |
+
$customerAddressId = '';//$data['address_id'];
|
113 |
+
|
114 |
+
if (isset($data['email'])) {
|
115 |
+
$data['email'] = trim($data['email']);
|
116 |
+
}
|
117 |
+
$onePage = Mage::getSingleton('checkout/type_onepage');
|
118 |
+
$result = $onePage->saveBilling($data, $customerAddressId);
|
119 |
+
|
120 |
+
if(!empty($result)) {
|
121 |
+
Mage::getSingleton('apruvepayment/session')->setErrors($result['message']);
|
122 |
+
} else {
|
123 |
+
$this->_setAddressUpdated();
|
124 |
+
}
|
125 |
+
|
126 |
+
$this->_redirect('*/*/review');
|
127 |
+
}
|
128 |
+
|
129 |
+
public function updateShippingAddressAction()
|
130 |
+
{
|
131 |
+
$data = $this->getRequest()->getPost('shipping', array());
|
132 |
+
$customerAddressId = '';//$data['address_id'];
|
133 |
+
$onePage = Mage::getSingleton('checkout/type_onepage');
|
134 |
+
|
135 |
+
$result = $onePage->saveShipping($data, $customerAddressId);
|
136 |
+
|
137 |
+
if(!empty($result)) {
|
138 |
+
Mage::getSingleton('apruvepayment/session')->setErrors($result['message']);
|
139 |
+
} else {
|
140 |
+
$this->_setAddressUpdated();
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
$this->_redirect('*/*/review');
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
public function updateShippingMethodAction()
|
149 |
+
{
|
150 |
+
if ($this->getRequest()->isPost()) {
|
151 |
+
$data = $this->getRequest()->getPost('shipping_method', '');
|
152 |
+
$onePage = Mage::getSingleton('checkout/type_onepage');
|
153 |
+
$result = $onePage->saveShippingMethod($data);
|
154 |
+
$onePage->getQuote()->collectTotals()->save();
|
155 |
+
}
|
156 |
+
|
157 |
+
$this->_setAddressUpdated();
|
158 |
+
$this->_redirect('*/*/review');
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
private function _setAddressUpdated()
|
163 |
+
{
|
164 |
+
$session = Mage::getSingleton('apruvepayment/session');
|
165 |
+
$session->setAddressUpdated(1);
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
public function ajaxSetAddressUpdatedAction()
|
170 |
+
{
|
171 |
+
$this->_setAddressUpdated();
|
172 |
+
die(true);
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
app/code/community/Apruve/ApruvePayment/controllers/WebhookController.php
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by JetBrains PhpStorm.
|
4 |
+
* User: Saa
|
5 |
+
* Date: 14.10.13
|
6 |
+
* Time: 13:07
|
7 |
+
* To change this template use File | Settings | File Templates.
|
8 |
+
*/
|
9 |
+
|
10 |
+
class Apruve_ApruvePayment_WebhookController extends Mage_Core_Controller_Front_Action
|
11 |
+
{
|
12 |
+
public function updateOrderStatusAction()
|
13 |
+
{
|
14 |
+
$q = $this->_getHashedQueryString();
|
15 |
+
|
16 |
+
if(!isset($_GET[$q])) {
|
17 |
+
//do nothing
|
18 |
+
header("HTTP/1.1 404 Not Found");
|
19 |
+
exit;
|
20 |
+
}
|
21 |
+
|
22 |
+
$input = file_get_contents('php://input');
|
23 |
+
$data = json_decode($input);
|
24 |
+
|
25 |
+
$status = $data->status;
|
26 |
+
$paymentRequestId = $data->payment_request_id; //transaciton id
|
27 |
+
|
28 |
+
//todo: compare status by rest request
|
29 |
+
if($status == 'rejected') {
|
30 |
+
if(!$this->_cancelOrder($paymentRequestId)) {
|
31 |
+
header("HTTP/1.1 404 Not Found");
|
32 |
+
exit;
|
33 |
+
};
|
34 |
+
} elseif($status == 'captured' ) {
|
35 |
+
if(!$this->_addPayed($paymentRequestId)) {
|
36 |
+
header("HTTP/1.1 404 Not Found");
|
37 |
+
exit;
|
38 |
+
};
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
header("HTTP/1.1 200");
|
43 |
+
exit;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
protected function _addPayed($paymentRequestId)
|
48 |
+
{
|
49 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
|
50 |
+
->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
|
51 |
+
->getFirstItem();
|
52 |
+
if(!$transaction->getId()) {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
$order = $transaction->getOrder();
|
57 |
+
if(!$order->getId()) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
$payment = $transaction->getOrder()->getPayment();
|
62 |
+
if(!$payment->getId()) {
|
63 |
+
exit;
|
64 |
+
}
|
65 |
+
$payment->capture(null);
|
66 |
+
$order->save();
|
67 |
+
|
68 |
+
$transaction->setOrderPaymentObject($payment);
|
69 |
+
$transaction->setIsClosed(true);
|
70 |
+
$transaction->save();
|
71 |
+
return true;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
protected function _cancelOrder($paymentRequestId)
|
76 |
+
{
|
77 |
+
$transaction = Mage::getModel('sales/order_payment_transaction')->getCollection()
|
78 |
+
->addAttributeToFilter('txn_id', array('eq' => $paymentRequestId))
|
79 |
+
->getFirstItem();
|
80 |
+
if(!$transaction->getId()) {
|
81 |
+
return false;
|
82 |
+
}
|
83 |
+
|
84 |
+
//todo: add customer notification
|
85 |
+
$order = $transaction->getOrder();
|
86 |
+
if(!$order->getId()) {
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
$order->cancel();
|
90 |
+
$order->save();
|
91 |
+
|
92 |
+
$payment = $transaction->getOrder()->getPayment();
|
93 |
+
$transaction->setOrderPaymentObject($payment);
|
94 |
+
$transaction->setIsClosed(true);
|
95 |
+
$transaction->save();
|
96 |
+
return true;
|
97 |
+
}
|
98 |
+
|
99 |
+
|
100 |
+
protected function _getHashedQueryString()
|
101 |
+
{
|
102 |
+
$merchantKey = Mage::getStoreConfig('payment/apruvepayment/merchant');
|
103 |
+
$apiKey = Mage::getStoreConfig('payment/apruvepayment/api');
|
104 |
+
$data = $apiKey.$merchantKey;
|
105 |
+
$q = hash('sha256', $data);
|
106 |
+
return $q;
|
107 |
+
}
|
108 |
+
}
|
app/code/community/Apruve/ApruvePayment/etc/config.xml
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Apruve_ApruvePayment>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Apruve_ApruvePayment>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<apruvepayment>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Apruve_ApruvePayment</module>
|
14 |
+
<frontName>apruvepayment</frontName>
|
15 |
+
</args>
|
16 |
+
</apruvepayment>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<apruvepayment>
|
21 |
+
<file>apruvepayment.xml</file>
|
22 |
+
</apruvepayment>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<global>
|
27 |
+
<blocks>
|
28 |
+
<apruvepayment>
|
29 |
+
<class>Apruve_ApruvePayment_Block</class>
|
30 |
+
</apruvepayment>
|
31 |
+
</blocks>
|
32 |
+
<models>
|
33 |
+
<apruvepayment>
|
34 |
+
<class>Apruve_ApruvePayment_Model</class>
|
35 |
+
</apruvepayment>
|
36 |
+
</models>
|
37 |
+
<resources>
|
38 |
+
<apruvepayment_setup>
|
39 |
+
<setup>
|
40 |
+
<module>Apruve_ApruvePayment</module>
|
41 |
+
<class>Apruve_ApruvePayment_Model_Mysql4_Setup</class>
|
42 |
+
</setup>
|
43 |
+
<connection>
|
44 |
+
<use>core_setup</use>
|
45 |
+
</connection>
|
46 |
+
</apruvepayment_setup>
|
47 |
+
<apruvepayment_write>
|
48 |
+
<connection>
|
49 |
+
<use>core_write</use>
|
50 |
+
</connection>
|
51 |
+
</apruvepayment_write>
|
52 |
+
<apruvepayment_read>
|
53 |
+
<connection>
|
54 |
+
<use>core_read</use>
|
55 |
+
</connection>
|
56 |
+
</apruvepayment_read>
|
57 |
+
</resources>
|
58 |
+
<helpers>
|
59 |
+
<apruvepayment>
|
60 |
+
<class>Apruve_ApruvePayment_Helper</class>
|
61 |
+
</apruvepayment>
|
62 |
+
</helpers>
|
63 |
+
</global>
|
64 |
+
<default>
|
65 |
+
<payment>
|
66 |
+
<apruvepayment>
|
67 |
+
<active>1</active>
|
68 |
+
<model>apruvepayment/paymentMethod</model>
|
69 |
+
<order_status>pending_payment</order_status>
|
70 |
+
<title>Apruve</title>
|
71 |
+
</apruvepayment>
|
72 |
+
</payment>
|
73 |
+
</default>
|
74 |
+
</config>
|
app/code/community/Apruve/ApruvePayment/etc/system.xml
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<apruvepayment translate="label">
|
7 |
+
<label>Apruve Payment</label>
|
8 |
+
<sort_order>670</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
<fields>
|
13 |
+
<active translate="label">
|
14 |
+
<label>Enabled</label>
|
15 |
+
<frontend_type>select</frontend_type>
|
16 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
17 |
+
<sort_order>1</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>0</show_in_store>
|
21 |
+
</active>
|
22 |
+
<testmode translate="label">
|
23 |
+
<label>Test Mode</label>
|
24 |
+
<frontend_type>select</frontend_type>
|
25 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>0</show_in_store>
|
30 |
+
</testmode>
|
31 |
+
<order_status translate="label">
|
32 |
+
<label>New order status</label>
|
33 |
+
<frontend_type>select</frontend_type>
|
34 |
+
<source_model>adminhtml/system_config_source_order_status_new</source_model>
|
35 |
+
<sort_order>6</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>0</show_in_store>
|
39 |
+
</order_status>
|
40 |
+
<title translate="label">
|
41 |
+
<label>Title</label>
|
42 |
+
<frontend_type>text</frontend_type>
|
43 |
+
<sort_order>3</sort_order>
|
44 |
+
<show_in_default>1</show_in_default>
|
45 |
+
<show_in_website>1</show_in_website>
|
46 |
+
<show_in_store>0</show_in_store>
|
47 |
+
</title>
|
48 |
+
<merchant translate="label">
|
49 |
+
<label>Merchant Key</label>
|
50 |
+
<frontend_type>text</frontend_type>
|
51 |
+
<sort_order>4</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>0</show_in_store>
|
55 |
+
</merchant>
|
56 |
+
<api translate="label">
|
57 |
+
<label>API Key</label>
|
58 |
+
<frontend_type>text</frontend_type>
|
59 |
+
<sort_order>5</sort_order>
|
60 |
+
<show_in_default>1</show_in_default>
|
61 |
+
<show_in_website>1</show_in_website>
|
62 |
+
<show_in_store>0</show_in_store>
|
63 |
+
</api>
|
64 |
+
<webhook_url translate="label">
|
65 |
+
<label>Webhook Url</label>
|
66 |
+
<frontend_model>apruvepayment/admin_webhook</frontend_model>
|
67 |
+
<sort_order>10</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>1</show_in_website>
|
70 |
+
<show_in_store>0</show_in_store>
|
71 |
+
</webhook_url>
|
72 |
+
</fields>
|
73 |
+
</apruvepayment>
|
74 |
+
</groups>
|
75 |
+
</payment>
|
76 |
+
</sections>
|
77 |
+
</config>
|
app/design/frontend/default/default/layout/apruvepayment.xml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<layout version="0.1.0">
|
2 |
+
<default>
|
3 |
+
<reference name="head">
|
4 |
+
<block type="core/template" name="apruve_js" template="apruvepayment/head.phtml" output="toHtml" />
|
5 |
+
</reference>
|
6 |
+
</default>
|
7 |
+
|
8 |
+
<apruvepayment_payment_review translate="label">
|
9 |
+
<label>Apruve Express Order Review Form</label>
|
10 |
+
<remove name="right"/>
|
11 |
+
<remove name="left"/>
|
12 |
+
|
13 |
+
<reference name="root">
|
14 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
15 |
+
</reference>
|
16 |
+
|
17 |
+
<reference name="content">
|
18 |
+
<block type="apruvepayment/review" name="apruvepayment.review" template="apruvepayment/review.phtml">
|
19 |
+
<block type="apruvepayment/review_billing" name="apruve.review.billing" as="billing" template="apruvepayment/review/address.phtml"/>
|
20 |
+
<block type="apruvepayment/review_shipping" name="apruve.review.shipping" as="shipping" template="apruvepayment/review/address.phtml"/>
|
21 |
+
<!--<block type="paypal/express_review_shipping" name="express.review.shipping" as="shipping" template="paypal/express/review/address.phtml"/>-->
|
22 |
+
<block type="checkout/onepage_shipping_method" name="checkout.onepage.shipping_method" as="shipping_method" template="apruvepayment/review/shipping_method.phtml">
|
23 |
+
<block type="checkout/onepage_shipping_method_available" name="checkout.onepage.shipping_method.available" as="available" template="checkout/onepage/shipping_method/available.phtml"/>
|
24 |
+
<block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
|
25 |
+
</block>
|
26 |
+
<block type="apruvepayment/review_details" name="apruvepayment.review.details" as="details" template="apruvepayment/review/details.phtml">
|
27 |
+
<action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action>
|
28 |
+
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action>
|
29 |
+
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action>
|
30 |
+
<block type="checkout/cart_totals" name="apruvepayment.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
|
31 |
+
</block>
|
32 |
+
<block type="checkout/agreements" name="apruvepayment.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/>
|
33 |
+
</block>
|
34 |
+
</reference>
|
35 |
+
</apruvepayment_payment_review>
|
36 |
+
|
37 |
+
<apruvepayment_payment_details>
|
38 |
+
<label>One Page Checkout Success</label>
|
39 |
+
<reference name="root">
|
40 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
41 |
+
</reference>
|
42 |
+
<reference name="content">
|
43 |
+
<block type="checkout/onepage_success" name="checkout.success" template="checkout/success.phtml"/>
|
44 |
+
</reference>
|
45 |
+
</apruvepayment_payment_details>
|
46 |
+
|
47 |
+
|
48 |
+
</layout>
|
app/design/frontend/default/default/template/apruvepayment/head.phtml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if(Mage::getStoreConfig('payment/apruvepayment/testmode')):?>
|
2 |
+
<script type="text/javascript" src="https://test.apruve.com/js/apruve.js"></script>
|
3 |
+
<?php else: ?>
|
4 |
+
<script type="text/javascript" src="https://www.apruve.com/js/apruve.js"></script>
|
5 |
+
<?php endif; ?>
|
6 |
+
<script type="text/javascript" src="/js/Apruve/ApruvePayment.js"></script>
|
app/design/frontend/default/default/template/apruvepayment/payment/form.phtml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<div id="payment_form_apruvepayment">
|
2 |
+
Press continue to review order.
|
3 |
+
<input type="hidden" id="aprt" value="" name="payment[aprt]"/>
|
4 |
+
</div>
|
app/design/frontend/default/default/template/apruvepayment/payment/mark.phtml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$helper = Mage::helper('apruvepayment');
|
3 |
+
$paymentRequestModel = $helper->getPaymentRequestApiModel();
|
4 |
+
?>
|
5 |
+
|
6 |
+
<div id="apruveDiv" style="display: inline-block;"></div>
|
7 |
+
|
8 |
+
<script type="test/javascript">
|
9 |
+
var sh = '<?php echo $paymentRequestModel->getSecureHash();?>';
|
10 |
+
var pr = <?php echo $paymentRequestModel->getPaymentRequestJSON();?>;
|
11 |
+
var updatedShippingUrl = '<?php echo $helper->getAjaxAddressUpdatedUrl() ?>'
|
12 |
+
var oApruvePayment = new ApruvePayment(sh, pr, updatedShippingUrl);
|
13 |
+
</script>
|
app/design/frontend/default/default/template/apruvepayment/review.phtml
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $errors = $this->getErrors();?>
|
2 |
+
<div class="page-title">
|
3 |
+
<h1><?php echo $this->__('Review Order') ?></h1>
|
4 |
+
</div>
|
5 |
+
<?php if($errors): ?>
|
6 |
+
<div class="error-msg">
|
7 |
+
<?php foreach($errors as $error) {
|
8 |
+
echo $error.'<br/>';
|
9 |
+
}
|
10 |
+
?>
|
11 |
+
|
12 |
+
</div>
|
13 |
+
<br/>
|
14 |
+
<?php endif;?>
|
15 |
+
<script type="text/javascript">
|
16 |
+
var form = new VarienForm('order_review_form');
|
17 |
+
</script>
|
18 |
+
|
19 |
+
<div class="addresses" style="width: 100%; text-align: left;">
|
20 |
+
<div class="col-1 info-set" style="width:45%; display: inline-block; float: left;">
|
21 |
+
<h2 class="legend"> Billing Info</h2>
|
22 |
+
<?php echo $this->getChild('billing')->setFieldNamePrefix('billing')->toHtml(); ?>
|
23 |
+
</div>
|
24 |
+
<div class="col-2 info-set" style="width:45%; display: inline-block; float: right;">
|
25 |
+
<h2 class="legend"> Shipping Info</h2>
|
26 |
+
<?php echo $this->getChild('shipping')->setFieldNamePrefix('shipping')->toHtml(); ?>
|
27 |
+
</div>
|
28 |
+
</div>
|
29 |
+
<div style="clear: both;"></div>
|
30 |
+
|
31 |
+
<div><?php echo $this->getChildHtml('shipping_method'); ?></div>
|
32 |
+
|
33 |
+
|
34 |
+
<?php //echo $this->getChildHtml('shipping_method');?>
|
35 |
+
<div class="apruve-review-order">
|
36 |
+
<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>">
|
37 |
+
<div class="info-set">
|
38 |
+
<h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2>
|
39 |
+
<div id="details-reload">
|
40 |
+
<?php echo $this->getChildHtml('details') ?>
|
41 |
+
</div>
|
42 |
+
</div>
|
43 |
+
<?php echo $this->getChildHtml('agreements'); ?>
|
44 |
+
<div class="buttons-set buttons-set-order" id="review-buttons-container">
|
45 |
+
<button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="form.submit();"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
|
46 |
+
<span class="please-wait" id="review-please-wait" style="display:none;">
|
47 |
+
<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Submitting order information...') ?>" title="<?php echo $this->__('Submitting order information...') ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?>
|
48 |
+
</span>
|
49 |
+
</div>
|
50 |
+
</form>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<script type="text/javascript">
|
54 |
+
//<![CDATA[
|
55 |
+
function switchAddressBlockView(prefix) {
|
56 |
+
var idAddressForm = prefix+'-address-form';
|
57 |
+
var idAddressInfo = prefix+'-address-info';
|
58 |
+
var form = $(idAddressForm);
|
59 |
+
|
60 |
+
if(!form.visible()) {
|
61 |
+
form.show();
|
62 |
+
$(idAddressInfo).hide();
|
63 |
+
} else {
|
64 |
+
form.hide();
|
65 |
+
$(idAddressInfo).show();
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
//]]>
|
70 |
+
</script>
|
app/design/frontend/default/default/template/apruvepayment/review/address.phtml
ADDED
@@ -0,0 +1,398 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
$prefix = $this->getFieldNamePrefix();
|
29 |
+
$actionUrl = $this->getUrl('apruvepayment/payment/update' . $prefix . 'address');
|
30 |
+
|
31 |
+
?>
|
32 |
+
<?php if (Mage::getVersion() >= '1.7.0.0') : ?>
|
33 |
+
<div class="<?php echo $prefix; ?>-address-info" id="<?php echo $prefix; ?>-address-info">
|
34 |
+
<?php echo $this->getAddress()->getFormated(true); ?>
|
35 |
+
<br/>
|
36 |
+
<a href="#" title="Edit Billing Information" onclick="switchAddressBlockView('<?php echo $prefix; ?>')">Edit</a>
|
37 |
+
</div>
|
38 |
+
|
39 |
+
<form method="post" action="<?php echo $actionUrl; ?>" class="address-form" style="display: none;"
|
40 |
+
id="<?php echo $prefix . '-address-form'; ?>">
|
41 |
+
<ul class="form-list form-list-narrow">
|
42 |
+
<li id="<?php echo $prefix ?>-address-form" class="address-form">
|
43 |
+
<fieldset>
|
44 |
+
<input type="hidden" name="<?php echo $prefix ?>[address_id]"
|
45 |
+
value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id"/>
|
46 |
+
<ul>
|
47 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li>
|
48 |
+
<li class="fields">
|
49 |
+
<div class="field">
|
50 |
+
<label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
|
51 |
+
|
52 |
+
<div class="input-box">
|
53 |
+
<input type="text" id="<?php echo $prefix ?>:company"
|
54 |
+
name="<?php echo $prefix ?>[company]"
|
55 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>"
|
56 |
+
title="<?php echo $this->__('Company') ?>"
|
57 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>"/>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
<?php if (!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
|
61 |
+
<div class="field">
|
62 |
+
<label for="<?php echo $prefix ?>:email"
|
63 |
+
class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
64 |
+
|
65 |
+
<div class="input-box">
|
66 |
+
<input type="text" name="<?php echo $prefix ?>[email]"
|
67 |
+
id="<?php echo $prefix ?>:email"
|
68 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>"
|
69 |
+
title="<?php echo $this->__('Email Address') ?>"
|
70 |
+
class="input-text validate-email required-entry"/>
|
71 |
+
</div>
|
72 |
+
</div>
|
73 |
+
<?php endif; ?>
|
74 |
+
</li>
|
75 |
+
<?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
|
76 |
+
<li class="wide">
|
77 |
+
<label for="<?php echo $prefix ?>:street1"
|
78 |
+
class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
79 |
+
|
80 |
+
<div class="input-box">
|
81 |
+
<input type="text" title="<?php echo $this->__('Street Address') ?>"
|
82 |
+
name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1"
|
83 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>"
|
84 |
+
class="input-text <?php echo $_streetValidationClass ?>"/>
|
85 |
+
</div>
|
86 |
+
</li>
|
87 |
+
<?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
|
88 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
89 |
+
<li class="add-field">
|
90 |
+
<div class="input-box">
|
91 |
+
<input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>"
|
92 |
+
name="<?php echo $prefix ?>[street][]"
|
93 |
+
id="<?php echo $prefix ?>:street<?php echo $_i ?>"
|
94 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>"
|
95 |
+
class="input-text <?php echo $_streetValidationClass ?>"/>
|
96 |
+
</div>
|
97 |
+
</li>
|
98 |
+
<?php endfor; ?>
|
99 |
+
<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
|
100 |
+
<li class="wide">
|
101 |
+
<label for="<?php echo $prefix ?>:vat_id"><?php echo $this->__('VAT Number') ?></label>
|
102 |
+
|
103 |
+
<div class="input-box">
|
104 |
+
<input type="text" id="<?php echo $prefix ?>:vat_id"
|
105 |
+
name="<?php echo $prefix ?>[vat_id]"
|
106 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>"
|
107 |
+
title="<?php echo $this->__('VAT Number') ?>"
|
108 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>"/>
|
109 |
+
</div>
|
110 |
+
</li>
|
111 |
+
<?php endif; ?>
|
112 |
+
<li class="fields">
|
113 |
+
<div class="field">
|
114 |
+
<label for="<?php echo $prefix ?>:city"
|
115 |
+
class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
116 |
+
|
117 |
+
<div class="input-box">
|
118 |
+
<input type="text" title="<?php echo $this->__('City') ?>"
|
119 |
+
name="<?php echo $prefix ?>[city]"
|
120 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
|
121 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>"
|
122 |
+
id="<?php echo $prefix ?>:city"/>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
<div class="field">
|
126 |
+
<label for="<?php echo $prefix ?>:region_id"
|
127 |
+
class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
128 |
+
|
129 |
+
<div class="input-box">
|
130 |
+
<select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]"
|
131 |
+
title="<?php echo $this->__('State/Province') ?>" class="validate-select"
|
132 |
+
style="display:none;">
|
133 |
+
<option
|
134 |
+
value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
135 |
+
</select>
|
136 |
+
<script type="text/javascript">
|
137 |
+
//<![CDATA[
|
138 |
+
$('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
139 |
+
//]]>
|
140 |
+
</script>
|
141 |
+
<input type="text" id="<?php echo $prefix ?>:region"
|
142 |
+
name="<?php echo $prefix ?>[region]"
|
143 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"
|
144 |
+
title="<?php echo $this->__('State/Province') ?>"
|
145 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>"
|
146 |
+
style="display:none;"/>
|
147 |
+
</div>
|
148 |
+
</div>
|
149 |
+
</li>
|
150 |
+
<li class="fields">
|
151 |
+
<div class="field">
|
152 |
+
<label for="<?php echo $prefix ?>:postcode"
|
153 |
+
class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
154 |
+
|
155 |
+
<div class="input-box">
|
156 |
+
<input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>"
|
157 |
+
name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode"
|
158 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>"
|
159 |
+
class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>"/>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
+
<div class="field">
|
163 |
+
<label for="<?php echo $prefix ?>:country_id"
|
164 |
+
class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
165 |
+
|
166 |
+
<div class="input-box">
|
167 |
+
<?php echo $this->getCountryHtmlSelect($prefix) ?>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
+
</li>
|
171 |
+
<li class="fields">
|
172 |
+
<div class="field">
|
173 |
+
<label for="<?php echo $prefix ?>:telephone"
|
174 |
+
class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
175 |
+
|
176 |
+
<div class="input-box">
|
177 |
+
<input type="text" name="<?php echo $prefix ?>[telephone]"
|
178 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>"
|
179 |
+
title="<?php echo $this->__('Telephone') ?>"
|
180 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>"
|
181 |
+
id="<?php echo $prefix ?>:telephone"/>
|
182 |
+
</div>
|
183 |
+
</div>
|
184 |
+
<div class="field">
|
185 |
+
<label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
|
186 |
+
|
187 |
+
<div class="input-box">
|
188 |
+
<input type="text" name="<?php echo $prefix ?>[fax]"
|
189 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>"
|
190 |
+
title="<?php echo $this->__('Fax') ?>"
|
191 |
+
class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>"
|
192 |
+
id="<?php echo $prefix ?>:fax"/>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
</li>
|
196 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
197 |
+
<?php if ($this->getShowAsShippingCheckbox()): ?>
|
198 |
+
<li class="control">
|
199 |
+
<div class="field">
|
200 |
+
<div class="input-box">
|
201 |
+
<input type="checkbox" name="<?php echo $prefix ?>[as_shipping]"
|
202 |
+
class="checkbox" value="1"
|
203 |
+
title="<?php echo $this->__('Same as shipping') ?>"
|
204 |
+
id="<?php echo $prefix ?>:as_shipping"
|
205 |
+
<?php if ($this->getAddress()->getSameAsBilling()): ?>checked="checked"<?php endif; ?>/>
|
206 |
+
</div>
|
207 |
+
<label
|
208 |
+
for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
|
209 |
+
</div>
|
210 |
+
</li>
|
211 |
+
<?php endif; ?>
|
212 |
+
</ul>
|
213 |
+
</fieldset>
|
214 |
+
</li>
|
215 |
+
</ul>
|
216 |
+
|
217 |
+
<button type="submit" class="button" style="float: left; margin-top: 10px;"><span><span>Update</span></span>
|
218 |
+
</button>
|
219 |
+
<button type="button" class="button" style="float: left; margin-top: 10px; margin-left: 10px;"
|
220 |
+
onclick="switchAddressBlockView('<?php echo $prefix; ?>')"><span><span>Cancel</span></span></button>
|
221 |
+
</form>
|
222 |
+
<?php else : ?>
|
223 |
+
<div class="<?php echo $prefix; ?>-address-info" id="<?php echo $prefix; ?>-address-info">
|
224 |
+
<?php echo $this->getAddress()->getFormated(true); ?>
|
225 |
+
<br/>
|
226 |
+
<a href="#" title="Edit Billing Information" onclick="switchAddressBlockView('<?php echo $prefix; ?>')">Edit</a>
|
227 |
+
</div>
|
228 |
+
|
229 |
+
<form method="post" action="<?php echo $actionUrl; ?>" class="address-form" style="display: none;"
|
230 |
+
id="<?php echo $prefix . '-address-form'; ?>">
|
231 |
+
<ul class="form-list form-list-narrow">
|
232 |
+
<li id="<?php echo $prefix ?>-address-form" class="address-form">
|
233 |
+
<fieldset>
|
234 |
+
<input type="hidden" name="<?php echo $prefix ?>[address_id]"
|
235 |
+
value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id"/>
|
236 |
+
<ul>
|
237 |
+
<li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li>
|
238 |
+
<li class="fields">
|
239 |
+
<div class="field">
|
240 |
+
<label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label>
|
241 |
+
|
242 |
+
<div class="input-box">
|
243 |
+
<input type="text" id="<?php echo $prefix ?>:company"
|
244 |
+
name="<?php echo $prefix ?>[company]"
|
245 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>"
|
246 |
+
title="<?php echo $this->__('Company') ?>" class="input-text"/>
|
247 |
+
</div>
|
248 |
+
</div>
|
249 |
+
<?php if (!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?>
|
250 |
+
<div class="field">
|
251 |
+
<label for="<?php echo $prefix ?>:email"
|
252 |
+
class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
|
253 |
+
|
254 |
+
<div class="input-box">
|
255 |
+
<input type="text" name="<?php echo $prefix ?>[email]"
|
256 |
+
id="<?php echo $prefix ?>:email"
|
257 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>"
|
258 |
+
title="<?php echo $this->__('Email Address') ?>"
|
259 |
+
class="input-text validate-email required-entry"/>
|
260 |
+
</div>
|
261 |
+
</div>
|
262 |
+
<?php endif; ?>
|
263 |
+
</li>
|
264 |
+
<li class="field">
|
265 |
+
<label for="<?php echo $prefix ?>:street1"
|
266 |
+
class="required"><em>*</em><?php echo $this->__('Address') ?></label>
|
267 |
+
|
268 |
+
<div class="input-box">
|
269 |
+
<input type="text" title="<?php echo $this->__('Street Address') ?>"
|
270 |
+
name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1"
|
271 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>"
|
272 |
+
class="input-text required-entry"/>
|
273 |
+
</div>
|
274 |
+
</li>
|
275 |
+
<?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
|
276 |
+
<li class="add-field">
|
277 |
+
<div class="input-box">
|
278 |
+
<input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>"
|
279 |
+
name="<?php echo $prefix ?>[street][]"
|
280 |
+
id="<?php echo $prefix ?>:street<?php echo $_i ?>"
|
281 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>"
|
282 |
+
class="input-text"/>
|
283 |
+
</div>
|
284 |
+
</li>
|
285 |
+
<?php endfor; ?>
|
286 |
+
<li class="fields">
|
287 |
+
<div class="field">
|
288 |
+
<label for="<?php echo $prefix ?>:city"
|
289 |
+
class="required"><em>*</em><?php echo $this->__('City') ?></label>
|
290 |
+
|
291 |
+
<div class="input-box">
|
292 |
+
<input type="text" title="<?php echo $this->__('City') ?>"
|
293 |
+
name="<?php echo $prefix ?>[city]"
|
294 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>"
|
295 |
+
class="input-text required-entry" id="<?php echo $prefix ?>:city"/>
|
296 |
+
</div>
|
297 |
+
</div>
|
298 |
+
<div class="field">
|
299 |
+
<label for="<?php echo $prefix ?>:region_id"
|
300 |
+
class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
|
301 |
+
|
302 |
+
<div class="input-box">
|
303 |
+
<select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]"
|
304 |
+
title="<?php echo $this->__('State/Province') ?>" class="validate-select"
|
305 |
+
style="display:none;">
|
306 |
+
<option
|
307 |
+
value=""><?php echo $this->__('Please select region, state or province') ?></option>
|
308 |
+
</select>
|
309 |
+
<script type="text/javascript">
|
310 |
+
//<![CDATA[
|
311 |
+
$('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
|
312 |
+
//]]>
|
313 |
+
</script>
|
314 |
+
<input type="text" id="<?php echo $prefix ?>:region"
|
315 |
+
name="<?php echo $prefix ?>[region]"
|
316 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>"
|
317 |
+
title="<?php echo $this->__('State/Province') ?>" class="input-text"
|
318 |
+
style="display:none;"/>
|
319 |
+
</div>
|
320 |
+
</div>
|
321 |
+
</li>
|
322 |
+
<li class="fields">
|
323 |
+
<div class="field">
|
324 |
+
<label for="<?php echo $prefix ?>:postcode"
|
325 |
+
class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
|
326 |
+
|
327 |
+
<div class="input-box">
|
328 |
+
<input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>"
|
329 |
+
name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode"
|
330 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>"
|
331 |
+
class="input-text validate-zip-international"/>
|
332 |
+
</div>
|
333 |
+
</div>
|
334 |
+
<div class="field">
|
335 |
+
<label for="<?php echo $prefix ?>:country_id"
|
336 |
+
class="required"><em>*</em><?php echo $this->__('Country') ?></label>
|
337 |
+
|
338 |
+
<div class="input-box">
|
339 |
+
<?php echo $this->getCountryHtmlSelect($prefix) ?>
|
340 |
+
</div>
|
341 |
+
</div>
|
342 |
+
</li>
|
343 |
+
<li class="fields">
|
344 |
+
<div class="field">
|
345 |
+
<label for="<?php echo $prefix ?>:telephone"
|
346 |
+
class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
|
347 |
+
|
348 |
+
<div class="input-box">
|
349 |
+
<input type="text" name="<?php echo $prefix ?>[telephone]"
|
350 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>"
|
351 |
+
title="<?php echo $this->__('Telephone') ?>" class="input-text"
|
352 |
+
id="<?php echo $prefix ?>:telephone"/>
|
353 |
+
</div>
|
354 |
+
</div>
|
355 |
+
<div class="field">
|
356 |
+
<label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label>
|
357 |
+
|
358 |
+
<div class="input-box">
|
359 |
+
<input type="text" name="<?php echo $prefix ?>[fax]"
|
360 |
+
value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>"
|
361 |
+
title="<?php echo $this->__('Fax') ?>" class="input-text"
|
362 |
+
id="<?php echo $prefix ?>:fax"/>
|
363 |
+
</div>
|
364 |
+
</div>
|
365 |
+
</li>
|
366 |
+
<?php echo $this->getChildHtml('form.additional.info'); ?>
|
367 |
+
<?php if ($this->getShowAsShippingCheckbox()): ?>
|
368 |
+
<li class="control">
|
369 |
+
<div class="field">
|
370 |
+
<div class="input-box">
|
371 |
+
<input type="checkbox" name="<?php echo $prefix ?>[as_shipping]"
|
372 |
+
class="checkbox" value="1"
|
373 |
+
title="<?php echo $this->__('Same as shipping') ?>"
|
374 |
+
id="<?php echo $prefix ?>:as_shipping"
|
375 |
+
<?php if ($this->getAddress()->getSameAsBilling()): ?>checked="checked"<?php endif; ?>/>
|
376 |
+
</div>
|
377 |
+
<label
|
378 |
+
for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label>
|
379 |
+
</div>
|
380 |
+
</li>
|
381 |
+
<?php endif; ?>
|
382 |
+
</ul>
|
383 |
+
</fieldset>
|
384 |
+
</li>
|
385 |
+
</ul>
|
386 |
+
|
387 |
+
<button type="submit" class="button" style="float: left; margin-top: 10px;"><span><span>Update</span></span>
|
388 |
+
</button>
|
389 |
+
<button type="button" class="button" style="float: left; margin-top: 10px; margin-left: 10px;"
|
390 |
+
onclick="switchAddressBlockView('<?php echo $prefix; ?>')"><span><span>Cancel</span></span></button>
|
391 |
+
</form>
|
392 |
+
<?php endif; ?>
|
393 |
+
<script type="text/javascript">
|
394 |
+
//<![CDATA[
|
395 |
+
var <?php echo $prefix ?>RegionUpdater = new RegionUpdater('<?php echo $prefix ?>:country_id', '<?php echo $prefix ?>:region', '<?php echo $prefix ?>:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, '<?php echo $prefix ?>:postcode');
|
396 |
+
<?php echo $prefix ?>RegionUpdater.update();
|
397 |
+
//]]>
|
398 |
+
</script>
|
app/design/frontend/default/default/template/apruvepayment/review/details.phtml
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @see Mage_Paypal_Block_Express_Review_Details
|
29 |
+
*/
|
30 |
+
?>
|
31 |
+
<table id="details-table" class="data-table">
|
32 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
|
33 |
+
<col />
|
34 |
+
<col width="1" />
|
35 |
+
<col width="1" />
|
36 |
+
<col width="1" />
|
37 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
38 |
+
<col width="1" />
|
39 |
+
<col width="1" />
|
40 |
+
<?php endif; ?>
|
41 |
+
<thead>
|
42 |
+
<tr>
|
43 |
+
<th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
|
44 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
|
45 |
+
<th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
|
46 |
+
<th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
|
47 |
+
</tr>
|
48 |
+
<?php if ($this->helper('tax')->displayCartBothPrices()): ?>
|
49 |
+
<tr>
|
50 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
51 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
52 |
+
<th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
|
53 |
+
<th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
|
54 |
+
</tr>
|
55 |
+
<?php endif; ?>
|
56 |
+
</thead>
|
57 |
+
<?php echo $this->getChildHtml('totals'); ?>
|
58 |
+
<tbody>
|
59 |
+
<?php foreach($this->getItems() as $_item): ?>
|
60 |
+
<?php echo $this->getItemHtml($_item) ?>
|
61 |
+
<?php endforeach ?>
|
62 |
+
</tbody>
|
63 |
+
</table>
|
64 |
+
<script type="text/javascript">decorateTable('details-table');</script>
|
app/design/frontend/default/default/template/apruvepayment/review/result.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Thank you for your order.
|
app/design/frontend/default/default/template/apruvepayment/review/shipping/method.phtml
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
/** @var $this Mage_Paypal_Block_Express_Review */
|
27 |
+
?>
|
28 |
+
<fieldset id="shipping-method-container">
|
29 |
+
<?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?>
|
30 |
+
<?php if ($groups = $this->getShippingRateGroups()):?>
|
31 |
+
<?php $currentRate = $this->getCurrentShippingRate(); ?>
|
32 |
+
<select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry">
|
33 |
+
<?php if (!$currentRate):?>
|
34 |
+
<option value=""><?php echo $this->__('Please select a shipping method...') ?></option>
|
35 |
+
<?php endif;?>
|
36 |
+
<?php foreach ($groups as $code => $rates):?>
|
37 |
+
<optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;">
|
38 |
+
<?php foreach ($rates as $rate):?>
|
39 |
+
<option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>>
|
40 |
+
<?php echo $this->renderShippingRateOption($rate)?>
|