Version Notes
Removed the sending of shipping lines to the payment gateway.
Download this release
Release Info
Developer | Toby Rhodes |
Extension | chippinpayments |
Version | 0.1.3 |
Comparing to | |
See all releases |
Version 0.1.3
- app/code/community/Chippin/ChippinPayment/Block/Adminhtml/System/Config/Fieldset/Hint.php +38 -0
- app/code/community/Chippin/ChippinPayment/Block/Form/Payment.php +15 -0
- app/code/community/Chippin/ChippinPayment/Block/Info/Payment.php +27 -0
- app/code/community/Chippin/ChippinPayment/Block/Redirect.php +49 -0
- app/code/community/Chippin/ChippinPayment/Helper/Checkout.php +70 -0
- app/code/community/Chippin/ChippinPayment/Helper/Data.php +29 -0
- app/code/community/Chippin/ChippinPayment/Model/Autoloader.php +49 -0
- app/code/community/Chippin/ChippinPayment/Model/Config.php +47 -0
- app/code/community/Chippin/ChippinPayment/Model/Order.php +16 -0
- app/code/community/Chippin/ChippinPayment/Model/Payment/Method.php +145 -0
- app/code/community/Chippin/ChippinPayment/Model/Resource/Setup.php +5 -0
- app/code/community/Chippin/ChippinPayment/controllers/CheckoutController.php +35 -0
- app/code/community/Chippin/ChippinPayment/controllers/StandardController.php +335 -0
- app/code/community/Chippin/ChippinPayment/data/chippinpayment_setup/data-install-0.1.0.php +83 -0
- app/code/community/Chippin/ChippinPayment/etc/config.xml +86 -0
- app/code/community/Chippin/ChippinPayment/etc/system.xml +183 -0
- app/design/adminhtml/default/default/template/chippinpayment/system/config/fieldset/hint.phtml +18 -0
- app/design/frontend/base/default/layout/chippin.xml +21 -0
- app/design/frontend/base/default/template/chippinpayment/contributed.phtml +8 -0
- app/design/frontend/base/default/template/chippinpayment/declined.phtml +4 -0
- app/design/frontend/base/default/template/chippinpayment/form/mark.phtml +5 -0
- app/etc/modules/Chippin_ChippinPayment.xml +14 -0
- lib/Chippin/SDK/Chippin.php +81 -0
- lib/Chippin/SDK/Merchant.php +31 -0
- package.xml +22 -0
app/code/community/Chippin/ChippinPayment/Block/Adminhtml/System/Config/Fieldset/Hint.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Block_Adminhtml_System_Config_Fieldset_Hint
|
4 |
+
extends Mage_Adminhtml_Block_Abstract
|
5 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
6 |
+
{
|
7 |
+
protected $_template = 'chippinpayment/system/config/fieldset/hint.phtml';
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Render fieldset html
|
11 |
+
*
|
12 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
16 |
+
{
|
17 |
+
$oUrl = Mage::getModel('core/url');
|
18 |
+
$params = array('_secure' => true);
|
19 |
+
$integrationUrls = array(
|
20 |
+
'Canceled' => $oUrl->getUrl("chippin/standard/canceled", $params),
|
21 |
+
'Completed' => $oUrl->getUrl("chippin/standard/completed", $params),
|
22 |
+
'Contributed' => $oUrl->getUrl("chippin/standard/contributed", $params),
|
23 |
+
'Failed' => $oUrl->getUrl("chippin/standard/failed", $params),
|
24 |
+
'Invited' => $oUrl->getUrl("chippin/standard/invited", $params),
|
25 |
+
'Rejected' => $oUrl->getUrl("chippin/standard/rejected", $params),
|
26 |
+
'Timed Out' => $oUrl->getUrl("chippin/standard/timedout", $params)
|
27 |
+
);
|
28 |
+
|
29 |
+
$this->setIntegrationUrls($integrationUrls);
|
30 |
+
|
31 |
+
$elementOriginalData = $element->getOriginalData();
|
32 |
+
if (isset($elementOriginalData['signup_link'])) {
|
33 |
+
$this->setSignupLink($elementOriginalData['signup_link']);
|
34 |
+
}
|
35 |
+
|
36 |
+
return $this->toHtml();
|
37 |
+
}
|
38 |
+
}
|
app/code/community/Chippin/ChippinPayment/Block/Form/Payment.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Block_Form_Payment extends Mage_Payment_Block_Form
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
$mark = Mage::getConfig()->getBlockClassName('core/template');
|
8 |
+
$mark = new $mark;
|
9 |
+
$mark->setTemplate('chippinpayment/form/mark.phtml')
|
10 |
+
->setDescription(Mage::helper('chippinpayment')->getDescription())
|
11 |
+
->setRedirectMessage(Mage::helper('chippinpayment')->getRedirectMessage());
|
12 |
+
$this->setMethodLabelAfterHtml($mark->toHtml());
|
13 |
+
parent::_construct();
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Chippin/ChippinPayment/Block/Info/Payment.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Block_Info_Payment extends Mage_Payment_Block_Info
|
4 |
+
{
|
5 |
+
protected function _prepareSpecificInformation($transport = null)
|
6 |
+
{
|
7 |
+
if (null !== $this->_paymentSpecificInformation)
|
8 |
+
{
|
9 |
+
return $this->_paymentSpecificInformation;
|
10 |
+
}
|
11 |
+
|
12 |
+
$data = array();
|
13 |
+
if ($this->getInfo()->getCustomFieldOne())
|
14 |
+
{
|
15 |
+
$data[Mage::helper('payment')->__('Custom Field One')] = $this->getInfo()->getCustomFieldOne();
|
16 |
+
}
|
17 |
+
|
18 |
+
if ($this->getInfo()->getCustomFieldTwo())
|
19 |
+
{
|
20 |
+
$data[Mage::helper('payment')->__('Custom Field Two')] = $this->getInfo()->getCustomFieldTwo();
|
21 |
+
}
|
22 |
+
|
23 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
24 |
+
|
25 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
26 |
+
}
|
27 |
+
}
|
app/code/community/Chippin/ChippinPayment/Block/Redirect.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Block_Redirect extends Mage_Core_Block_Abstract
|
4 |
+
{
|
5 |
+
protected function _toHtml()
|
6 |
+
{
|
7 |
+
$method = Mage::getModel('chippinpayment/payment_method');
|
8 |
+
|
9 |
+
$form = new Varien_Data_Form();
|
10 |
+
$form->setAction($method->getConfig()->getEndpointUrl())
|
11 |
+
->setId('chippin_standard_checkout')
|
12 |
+
->setName('chippin_standard_checkout')
|
13 |
+
->setMethod('POST')
|
14 |
+
->setUseContainer(true);
|
15 |
+
|
16 |
+
foreach ($method->getCheckoutFormFields() as $field => $value) {
|
17 |
+
if (is_array($value)) {
|
18 |
+
foreach ($value as $index => $product) {
|
19 |
+
foreach ($product as $productLabel => $productValue) {
|
20 |
+
$productFieldId = sprintf("chippin-product-%s-%s", $index, $productLabel);
|
21 |
+
$productFieldName = sprintf("%s[][%s]", $field, $productLabel);
|
22 |
+
$form->addField($productFieldId, 'hidden', array('name' => $productFieldName, 'value' => $productValue));
|
23 |
+
}
|
24 |
+
}
|
25 |
+
} else {
|
26 |
+
$form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
|
27 |
+
}
|
28 |
+
}
|
29 |
+
|
30 |
+
$idSuffix = Mage::helper('core')->uniqHash();
|
31 |
+
$submitButton = new Varien_Data_Form_Element_Submit(array(
|
32 |
+
'value' => $this->__('Click here if you are not redirected within 10 seconds...'),
|
33 |
+
));
|
34 |
+
$buttonId = "submit_to_chippin_button_{$idSuffix}";
|
35 |
+
$submitButton->setId($buttonId);
|
36 |
+
|
37 |
+
$form->addElement($submitButton);
|
38 |
+
|
39 |
+
$html = '<html><body>';
|
40 |
+
$html.= $this->__('You will be redirected to the Chippin website in a few seconds.');
|
41 |
+
$html.= $form->toHtml();
|
42 |
+
if (Mage::getModel('core/cookie')->get('automated-testing') !== 'bitter-sequence-garment-serenity') {
|
43 |
+
$html.= '<script type="text/javascript">document.getElementById("chippin_standard_checkout").submit();</script>';
|
44 |
+
}
|
45 |
+
$html.= '</body></html>';
|
46 |
+
|
47 |
+
return $html;
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Chippin/ChippinPayment/Helper/Checkout.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Helper_Checkout extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Restore active quote based on order
|
7 |
+
*
|
8 |
+
* @param order Mage_Sales_Model_Order
|
9 |
+
*
|
10 |
+
* @return bool True if quote restored successfully, false otherwise
|
11 |
+
*/
|
12 |
+
public function restoreQuote($order)
|
13 |
+
{
|
14 |
+
if ($order->getId()) {
|
15 |
+
$quote = $this->_getQuote($order->getQuoteId());
|
16 |
+
if ($quote->getId()) {
|
17 |
+
$quote->setIsActive(1)
|
18 |
+
->setReservedOrderId(null)
|
19 |
+
->save();
|
20 |
+
$this->_getCheckoutSession()
|
21 |
+
->replaceQuote($quote)
|
22 |
+
->unsLastRealOrderId();
|
23 |
+
|
24 |
+
return true;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Cancel last placed order with specified comment message
|
33 |
+
*
|
34 |
+
* @param string $comment Comment appended to order history
|
35 |
+
*
|
36 |
+
* @return bool True if order canceled, false otherwise
|
37 |
+
*/
|
38 |
+
public function cancelCurrentOrder($comment)
|
39 |
+
{
|
40 |
+
$order = $this->_getCheckoutSession()->getLastRealOrder();
|
41 |
+
if ($order->getId() && $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
|
42 |
+
$order->registerCancellation($comment)->save();
|
43 |
+
|
44 |
+
return true;
|
45 |
+
}
|
46 |
+
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Return checkout session instance
|
52 |
+
*
|
53 |
+
* @return Mage_Checkout_Model_Session
|
54 |
+
*/
|
55 |
+
protected function _getCheckoutSession()
|
56 |
+
{
|
57 |
+
return Mage::getSingleton('checkout/session');
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Return sales quote instance for specified ID
|
62 |
+
*
|
63 |
+
* @param int $quoteId Quote identifier
|
64 |
+
* @return Mage_Sales_Model_Quote
|
65 |
+
*/
|
66 |
+
protected function _getQuote($quoteId)
|
67 |
+
{
|
68 |
+
return Mage::getModel('sales/quote')->load($quoteId);
|
69 |
+
}
|
70 |
+
}
|
app/code/community/Chippin/ChippinPayment/Helper/Data.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Chippin_ChippinPayment_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
private $_config;
|
5 |
+
|
6 |
+
public function getDescription()
|
7 |
+
{
|
8 |
+
return $this->__($this->getConfig()->getDescription());
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getRedirectMessage()
|
12 |
+
{
|
13 |
+
return $this->__($this->getConfig()->getRedirectMessage());
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Config instance getter
|
18 |
+
* @return Chippin_ChippinPayment_Model_Config
|
19 |
+
*/
|
20 |
+
private function getConfig()
|
21 |
+
{
|
22 |
+
if (null === $this->_config) {
|
23 |
+
$this->_config = Mage::getModel('chippinpayment/config');
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this->_config;
|
27 |
+
}
|
28 |
+
|
29 |
+
}
|
app/code/community/Chippin/ChippinPayment/Model/Autoloader.php
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Model_Autoloader
|
4 |
+
{
|
5 |
+
const SDK_LIB_PATH = 'Chippin';
|
6 |
+
const CONVERT_CLASS_TO_PATH_REGEX = '#\\\|_(?!.*\\\)#';
|
7 |
+
|
8 |
+
private $_originalAutoloaders;
|
9 |
+
|
10 |
+
public function register()
|
11 |
+
{
|
12 |
+
$this->_deregisterVarienAutoloaders();
|
13 |
+
$this->_registerSDKAutoloader();
|
14 |
+
$this->_reregisterVarienAutoloaders();
|
15 |
+
}
|
16 |
+
|
17 |
+
private function _registerSDKAutoloader()
|
18 |
+
{
|
19 |
+
spl_autoload_register(
|
20 |
+
function ($className) {
|
21 |
+
if(strpos($className, self::SDK_LIB_PATH . '\\') === 0) {
|
22 |
+
include_once preg_replace(self::CONVERT_CLASS_TO_PATH_REGEX, '/', $className) . '.php';
|
23 |
+
}
|
24 |
+
}
|
25 |
+
);
|
26 |
+
|
27 |
+
return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
private function _deregisterVarienAutoloaders()
|
32 |
+
{
|
33 |
+
$this->_originalAutoloaders = array();
|
34 |
+
|
35 |
+
foreach (spl_autoload_functions() as $callback) {
|
36 |
+
if (is_array($callback) && $callback[0] instanceof Varien_Autoload) {
|
37 |
+
$this->_originalAutoloaders[] = $callback;
|
38 |
+
spl_autoload_unregister($callback);
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
private function _reregisterVarienAutoloaders()
|
44 |
+
{
|
45 |
+
foreach ($this->_originalAutoloaders as $autoloader) {
|
46 |
+
spl_autoload_register($autoloader);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
app/code/community/Chippin/ChippinPayment/Model/Config.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Model_Config {
|
4 |
+
|
5 |
+
const METHOD_CODE = 'chippinpayment';
|
6 |
+
|
7 |
+
public function getEndpointUrl()
|
8 |
+
{
|
9 |
+
return (Mage::getStoreConfig('payment/chippinpayment/sandbox'))? Mage::getStoreConfig('payment/chippinpayment/sandbox_endpoint') : Mage::getStoreConfig('payment/chippinpayment/live_endpoint');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getMerchantId()
|
13 |
+
{
|
14 |
+
return Mage::getStoreConfig('payment/chippinpayment/merchant_id');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getSecret()
|
18 |
+
{
|
19 |
+
return Mage::getStoreConfig('payment/chippinpayment/secret');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getDuration()
|
23 |
+
{
|
24 |
+
return Mage::getStoreConfig('payment/chippinpayment/duration');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getGracePeriod()
|
28 |
+
{
|
29 |
+
return Mage::getStoreConfig('payment/chippinpayment/grace_period');
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getTitle()
|
33 |
+
{
|
34 |
+
return Mage::getStoreConfig('payment/chippinpayment/title');
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getDescription()
|
38 |
+
{
|
39 |
+
return Mage::getStoreConfig('payment/chippinpayment/description');
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getRedirectMessage()
|
43 |
+
{
|
44 |
+
return Mage::getStoreConfig('payment/chippinpayment/redirect_message');
|
45 |
+
}
|
46 |
+
|
47 |
+
}
|
app/code/community/Chippin/ChippinPayment/Model/Order.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Model_Order {
|
4 |
+
/**
|
5 |
+
* Order statuses
|
6 |
+
*/
|
7 |
+
const STATUS_NEW = 'chippin_new';
|
8 |
+
const STATUS_INVITED = 'chippin_invited';
|
9 |
+
const STATUS_CONTRIBUTED = 'chippin_contributed';
|
10 |
+
const STATUS_REJECTED = 'chippin_rejected';
|
11 |
+
const STATUS_COMPLETED = 'chippin_completed';
|
12 |
+
const STATUS_PAID = 'chippin_paid';
|
13 |
+
const STATUS_FAILED = 'chippin_failed';
|
14 |
+
const STATUS_CANCELED = 'chippin_canceled';
|
15 |
+
const STATUS_TIMEDOUT = 'chippin_timedout';
|
16 |
+
}
|
app/code/community/Chippin/ChippinPayment/Model/Payment/Method.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Chippin\SDK\Merchant;
|
4 |
+
use Chippin\SDK\Chippin;
|
5 |
+
|
6 |
+
class Chippin_ChippinPayment_Model_Payment_Method extends Mage_Payment_Model_Method_Abstract {
|
7 |
+
|
8 |
+
protected $_code = Chippin_ChippinPayment_Model_Config::METHOD_CODE;
|
9 |
+
protected $_formBlockType = 'chippinpayment/form_payment';
|
10 |
+
// protected $_infoBlockType = 'chippinpayment/info_payment';
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Payment Method features
|
14 |
+
* @var bool
|
15 |
+
*/
|
16 |
+
protected $_canUseInternal = false;
|
17 |
+
protected $_canUseCheckout = true;
|
18 |
+
protected $_canUseForMultishipping = false;
|
19 |
+
protected $_isInitializeNeeded = true;
|
20 |
+
protected $_canManageRecurringProfiles = false;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Config instance
|
24 |
+
* @var Chippin_ChippinPayment_Model_Config
|
25 |
+
*/
|
26 |
+
protected $_config = null;
|
27 |
+
|
28 |
+
protected $_chippin;
|
29 |
+
|
30 |
+
public function __construct($params = array())
|
31 |
+
{
|
32 |
+
parent::__construct($params);
|
33 |
+
$this->_chippin = new Chippin(new Merchant($this->getConfig()->getMerchantId(), $this->getConfig()->getSecret()));
|
34 |
+
}
|
35 |
+
/**
|
36 |
+
* Return Order place redirect url
|
37 |
+
*
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function getOrderPlaceRedirectUrl()
|
41 |
+
{
|
42 |
+
return Mage::getUrl('chippin/standard/redirect', array('_secure' => true));
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Instantiate state and set it to state object
|
47 |
+
* @param string $paymentAction
|
48 |
+
* @param Varien_Object
|
49 |
+
*
|
50 |
+
* @return Mage_Payment_Model_Abstract
|
51 |
+
*/
|
52 |
+
public function initialize($paymentAction, $stateObject)
|
53 |
+
{
|
54 |
+
$state = Mage_Sales_Model_Order::STATE_NEW;
|
55 |
+
$stateObject->setState($state);
|
56 |
+
$stateObject->setStatus(Chippin_ChippinPayment_Model_Order::STATUS_NEW);
|
57 |
+
$stateObject->setIsNotified(false);
|
58 |
+
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Config instance getter
|
65 |
+
* @return Chippin_ChippinPayment_Model_Config
|
66 |
+
*/
|
67 |
+
public function getConfig()
|
68 |
+
{
|
69 |
+
if (null === $this->_config) {
|
70 |
+
$params = array($this->_code);
|
71 |
+
if ($store = $this->getStore()) {
|
72 |
+
$params[] = is_object($store) ? $store->getId() : $store;
|
73 |
+
}
|
74 |
+
$this->_config = Mage::getModel('chippinpayment/config', $params);
|
75 |
+
}
|
76 |
+
|
77 |
+
return $this->_config;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get checkout session namespace
|
82 |
+
*
|
83 |
+
* @return Mage_Checkout_Model_Session
|
84 |
+
*/
|
85 |
+
public function getCheckout()
|
86 |
+
{
|
87 |
+
return Mage::getSingleton('checkout/session');
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Return form field array
|
92 |
+
*
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function getCheckoutFormFields()
|
96 |
+
{
|
97 |
+
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
|
98 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
99 |
+
|
100 |
+
$currencyCode = strtolower($order->getBaseCurrencyCode());
|
101 |
+
$isOrderVirtual = $order->getIsVirtual();
|
102 |
+
|
103 |
+
$orderGrandTotal = intval($order->getData('grand_total') * 100);
|
104 |
+
$subTotal = intval($order->getSubtotal() * 100);
|
105 |
+
$shippingHandling = $grandTotal - $subTotal;
|
106 |
+
|
107 |
+
$fields = $this->decorateWithHash(array(
|
108 |
+
'merchant_id' => $this->getConfig()->getMerchantId(),
|
109 |
+
'merchant_order_id' => $orderIncrementId,
|
110 |
+
'total_amount' => $orderGrandTotal,
|
111 |
+
'first_name' => $order->getCustomerFirstname(),
|
112 |
+
'last_name' => $order->getCustomerLastname(),
|
113 |
+
'email' => $order->getCustomerEmail(),
|
114 |
+
'duration' => $this->getConfig()->getDuration(),
|
115 |
+
'grace_period' => $this->getConfig()->getGracePeriod(),
|
116 |
+
'currency_code' => $currencyCode,
|
117 |
+
'hmac' => '',
|
118 |
+
'products' => array()
|
119 |
+
));
|
120 |
+
|
121 |
+
//Retrieve items from the quote.
|
122 |
+
$items = $order->getItemsCollection()->getItems();
|
123 |
+
foreach($items as $item) {
|
124 |
+
|
125 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
126 |
+
if ($product->getTypeId() == 'simple' ) {
|
127 |
+
array_push($fields['products'], array(
|
128 |
+
'label' => $item->getName(),
|
129 |
+
'image' => $product->getImageUrl(),
|
130 |
+
'amount' => intval($item->getRowTotal() * 100)
|
131 |
+
));
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
return $fields;
|
136 |
+
}
|
137 |
+
|
138 |
+
private function decorateWithHash($data)
|
139 |
+
{
|
140 |
+
$data['hmac'] = $this->_chippin->generateOrderHash($data);
|
141 |
+
|
142 |
+
return $data;
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
app/code/community/Chippin/ChippinPayment/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup
|
4 |
+
{
|
5 |
+
}
|
app/code/community/Chippin/ChippinPayment/controllers/CheckoutController.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Chippin_ChippinPayment_CheckoutController extends Mage_Core_Controller_Front_Action {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Config instance
|
7 |
+
* @var Chippin_ChippinPayment_Model_Config
|
8 |
+
*/
|
9 |
+
protected $_config = null;
|
10 |
+
|
11 |
+
public function contributedAction()
|
12 |
+
{
|
13 |
+
$this->loadLayout();
|
14 |
+
$this->renderLayout();
|
15 |
+
}
|
16 |
+
|
17 |
+
public function declinedAction()
|
18 |
+
{
|
19 |
+
$this->loadLayout();
|
20 |
+
$this->renderLayout();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Config instance getter
|
25 |
+
* @return Chippin_ChippinPayment_Model_Config
|
26 |
+
*/
|
27 |
+
private function getConfig()
|
28 |
+
{
|
29 |
+
if (null === $this->_config) {
|
30 |
+
$this->_config = Mage::getModel('chippinpayment/config');
|
31 |
+
}
|
32 |
+
|
33 |
+
return $this->_config;
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Chippin/ChippinPayment/controllers/StandardController.php
ADDED
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
use Chippin\SDK\Merchant;
|
4 |
+
use Chippin\SDK\Chippin;
|
5 |
+
|
6 |
+
class Chippin_ChippinPayment_StandardController extends Mage_Core_Controller_Front_Action {
|
7 |
+
|
8 |
+
protected $_chippin;
|
9 |
+
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_chippin = new Chippin(new Merchant($this->getConfig()->getMerchantId(), $this->getConfig()->getSecret()));
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Config instance
|
18 |
+
* @var Chippin_ChippinPayment_Model_Config
|
19 |
+
*/
|
20 |
+
protected $_config = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* When a customer chooses Paypal on Checkout/Payment page
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
public function redirectAction()
|
27 |
+
{
|
28 |
+
$session = Mage::getSingleton('checkout/session');
|
29 |
+
$session->setChippinQuoteId($session->getQuoteId());
|
30 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('chippinpayment/redirect')->toHtml());
|
31 |
+
$session->unsQuoteId();
|
32 |
+
$session->unsRedirectUrl();
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Happens one time at the point first invite(s) to contributors are sent.
|
37 |
+
* This is likely point you might wish to reserve stock.
|
38 |
+
*
|
39 |
+
* Callback Type: Background
|
40 |
+
*
|
41 |
+
* POST merchant_order_id
|
42 |
+
* POST hmac
|
43 |
+
*
|
44 |
+
* Trigered by: Instigator
|
45 |
+
*/
|
46 |
+
public function invitedAction()
|
47 |
+
{
|
48 |
+
$this->isHashValid('invited');
|
49 |
+
|
50 |
+
$order = $this->loadOrder();
|
51 |
+
|
52 |
+
$message = sprintf('Invite(s) sent to contributor(s)');
|
53 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_INVITED, $message)
|
54 |
+
->save();
|
55 |
+
|
56 |
+
$this->sendJsonResponse();
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Occurs after each contributor pages. This is the point to say thank you to the contributor and upsell.
|
61 |
+
* Contributor payment has been pre- authed at this point but not collected.
|
62 |
+
*
|
63 |
+
* Callback Type: Forground redirect
|
64 |
+
*
|
65 |
+
* POST merchant_order_id
|
66 |
+
* POST first_name
|
67 |
+
* POST last_name
|
68 |
+
* POST email
|
69 |
+
* POST hmac
|
70 |
+
*
|
71 |
+
* Trigered by: Contributor
|
72 |
+
*/
|
73 |
+
public function contributedAction()
|
74 |
+
{
|
75 |
+
$this->isContributorHashValid();
|
76 |
+
|
77 |
+
$message = sprintf('Contribution recieved from %s', $this->getEmail());
|
78 |
+
|
79 |
+
$order = $this->loadOrder();
|
80 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_CONTRIBUTED, $message)
|
81 |
+
->save();
|
82 |
+
|
83 |
+
$session = Mage::getSingleton('checkout/session');
|
84 |
+
$session->setQuoteId($order->getQuoteId());
|
85 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
86 |
+
|
87 |
+
$this->_redirect('chippin/checkout/contributed', array('_secure' => true));
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Occurs if a contributor rejects an invitation to contribute.
|
92 |
+
*
|
93 |
+
* Callback Type: Forground redirect
|
94 |
+
*
|
95 |
+
* POST merchant_order_id
|
96 |
+
* POST hmac
|
97 |
+
*
|
98 |
+
* Trigered by: Contributor
|
99 |
+
*/
|
100 |
+
public function rejectedAction()
|
101 |
+
{
|
102 |
+
$this->isHashValid('rejected');
|
103 |
+
|
104 |
+
$orderId = $this->getRequest()->getParam('merchant_order_id');
|
105 |
+
|
106 |
+
$order = $this->loadOrder($orderId);
|
107 |
+
$order->hold();
|
108 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true, "Chippin payment has been rejected.", true);
|
109 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_REJECTED, 'An unrecoverable error occured');
|
110 |
+
$order->save();
|
111 |
+
|
112 |
+
$session = Mage::getSingleton('checkout/session');
|
113 |
+
$session->setQuoteId($order->getQuoteId());
|
114 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
115 |
+
|
116 |
+
$this->_redirect('chippin/checkout/declined', array('_secure' => true));
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Occurs when instigator manually completes a chippin. This does not mean the money has been taken yet. Corresponding
|
121 |
+
* merchant page should say something along the lines of “Thank you for completing your chippin, we will email
|
122 |
+
* you order completion details shortly.”
|
123 |
+
*
|
124 |
+
* Callback Type: Forground redirect
|
125 |
+
*
|
126 |
+
* POST merchant_order_id
|
127 |
+
* POST hmac
|
128 |
+
*
|
129 |
+
* Trigered by: Instigator
|
130 |
+
*/
|
131 |
+
public function completedAction()
|
132 |
+
{
|
133 |
+
$this->isHashValid('completed');
|
134 |
+
|
135 |
+
$order = $this->loadOrder();
|
136 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_COMPLETED, 'All contributions accepted')
|
137 |
+
->save();
|
138 |
+
|
139 |
+
$session = Mage::getSingleton('checkout/session');
|
140 |
+
$session->setQuoteId($order->getQuoteId());
|
141 |
+
Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
|
142 |
+
$this->_redirect('checkout/onepage/success', array('_secure'=>true));
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* All payments have been taken, the order is complete and merchant should email user details of their order.
|
147 |
+
*
|
148 |
+
* Callback Type: Background
|
149 |
+
*
|
150 |
+
* POST merchant_order_id
|
151 |
+
* POST hmac
|
152 |
+
*
|
153 |
+
* Trigered by: n/a
|
154 |
+
*/
|
155 |
+
public function paidAction()
|
156 |
+
{
|
157 |
+
$this->isHashValid('paid');
|
158 |
+
|
159 |
+
$order = $this->loadOrder();
|
160 |
+
|
161 |
+
$payment = $order->getPayment();
|
162 |
+
$payment->registerCaptureNotification($order->getGrandTotal(), true);
|
163 |
+
$order->save();
|
164 |
+
$invoice = $payment->getCreatedInvoice();
|
165 |
+
if ($invoice) {
|
166 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_PAID, $message)
|
167 |
+
->save();
|
168 |
+
|
169 |
+
$order->queueNewOrderEmail()->addStatusHistoryComment(sprintf('Notified customer about invoice #%s.', $invoice->getIncrementId()))
|
170 |
+
->setIsCustomerNotified(true)
|
171 |
+
->save();
|
172 |
+
}
|
173 |
+
|
174 |
+
$this->sendJsonResponse();
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Occurs if there is an error that can not be recovered. All payments/pre-auths are refunded
|
179 |
+
* by Chippin. This should rarely happen, but if it does you should update user about order status
|
180 |
+
* and probably provide them an alternative payment method or suggest re- placing the order.
|
181 |
+
*
|
182 |
+
* Callback Type: Background
|
183 |
+
*
|
184 |
+
* POST merchant_order_id
|
185 |
+
* POST hmac
|
186 |
+
*
|
187 |
+
* Trigered by: n/a
|
188 |
+
*/
|
189 |
+
public function failedAction()
|
190 |
+
{
|
191 |
+
$this->isHashValid('failed');
|
192 |
+
|
193 |
+
$order = $this->loadOrder();
|
194 |
+
if (!$order) {
|
195 |
+
throw new Exception('Unable to load the order');
|
196 |
+
}
|
197 |
+
$message = sprintf('Chippin payment failed.');
|
198 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_FAILED, $message)
|
199 |
+
->registerCancellation($message, false)
|
200 |
+
->save();
|
201 |
+
|
202 |
+
$this->sendJsonResponse();
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Occurs if the instigator chooses to cancel the ‘chippin’. At this point you should probably indicate order has
|
207 |
+
* not been completed and probably provide them an alternative payment method or suggest re- placing the order.
|
208 |
+
*
|
209 |
+
* Callback Type: Forground redirect
|
210 |
+
*
|
211 |
+
* POST merchant_order_id
|
212 |
+
* POST hmac
|
213 |
+
*
|
214 |
+
* Trigered by: Instigator
|
215 |
+
*/
|
216 |
+
public function canceledAction()
|
217 |
+
{
|
218 |
+
$this->isHashValid('cancelled');
|
219 |
+
|
220 |
+
$session = Mage::getSingleton('checkout/session');
|
221 |
+
$order = $this->loadOrder();
|
222 |
+
$message = sprintf('Chippin payment cancelled by Instigator');
|
223 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_CANCELED, $message)
|
224 |
+
->save();
|
225 |
+
Mage::helper('chippinpayment/checkout')->restoreQuote($order);
|
226 |
+
|
227 |
+
$this->_redirect('checkout/cart');
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Occurs if the ‘chippin’ times out (the duration of time allowed to complete has passed). At this point,
|
232 |
+
* you should probably release stock and email the customer to inform them to re- place the order.
|
233 |
+
*
|
234 |
+
* Callback Type: Background
|
235 |
+
*
|
236 |
+
* POST merchant_order_id
|
237 |
+
* POST hmac
|
238 |
+
*
|
239 |
+
* Trigered by: n/a
|
240 |
+
*/
|
241 |
+
public function timedoutAction()
|
242 |
+
{
|
243 |
+
$this->isHashValid('timed_out');
|
244 |
+
|
245 |
+
$order = $this->loadOrder();
|
246 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true, 'Chippin payment has been rejected.', true);
|
247 |
+
$order->addStatusToHistory(Chippin_ChippinPayment_Model_Order::STATUS_TIMEDOUT, 'The Chippin payment timed out', true)
|
248 |
+
->save();
|
249 |
+
|
250 |
+
$order->cancel()->save();
|
251 |
+
|
252 |
+
$this->sendJsonResponse();
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Config instance getter
|
257 |
+
* @return Chippin_ChippinPayment_Model_Config
|
258 |
+
*/
|
259 |
+
private function getConfig()
|
260 |
+
{
|
261 |
+
if (null === $this->_config) {
|
262 |
+
$this->_config = Mage::getModel('chippinpayment/config');
|
263 |
+
}
|
264 |
+
|
265 |
+
return $this->_config;
|
266 |
+
}
|
267 |
+
|
268 |
+
private function sendJsonResponse($message = 'Success')
|
269 |
+
{
|
270 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
271 |
+
$this->getResponse()->setBody(sprintf('{"response":"%s"}', $message));
|
272 |
+
}
|
273 |
+
|
274 |
+
private function getHmac()
|
275 |
+
{
|
276 |
+
return $this->getRequest()->getParam('hmac');
|
277 |
+
}
|
278 |
+
|
279 |
+
private function getOrderId()
|
280 |
+
{
|
281 |
+
return $this->getRequest()->getParam('merchant_order_id');
|
282 |
+
}
|
283 |
+
|
284 |
+
private function getFirstName()
|
285 |
+
{
|
286 |
+
return $this->getRequest()->getParam('first_name');
|
287 |
+
}
|
288 |
+
|
289 |
+
private function getLastName()
|
290 |
+
{
|
291 |
+
return $this->getRequest()->getParam('last_name');
|
292 |
+
}
|
293 |
+
|
294 |
+
private function getEmail()
|
295 |
+
{
|
296 |
+
return $this->getRequest()->getParam('email');
|
297 |
+
}
|
298 |
+
|
299 |
+
private function loadOrder()
|
300 |
+
{
|
301 |
+
$orderId = $this->getOrderId();
|
302 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
303 |
+
if (!$order->getId()) {
|
304 |
+
throw new Exception(sprintf('Unable to retrieve order with increment_id: %s', $orderId));
|
305 |
+
}
|
306 |
+
|
307 |
+
return $order;
|
308 |
+
}
|
309 |
+
|
310 |
+
private function isHashValid($callbackKey)
|
311 |
+
{
|
312 |
+
$orderId = $this->getOrderId();
|
313 |
+
$hash = $this->_chippin->generateCallbackHash($callbackKey, $orderId);
|
314 |
+
|
315 |
+
if($hash !== $this->getHmac()) {
|
316 |
+
Mage::logException(new Exception(sprintf('HMAC validation failed for order: %s hmac:%s !== hash:%s', $orderId, $hmac, $hash)));
|
317 |
+
throw new Exception('HMAC validation failed');
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
protected function isContributorHashValid()
|
322 |
+
{
|
323 |
+
$orderId = $this->getOrderId();
|
324 |
+
$first_name = $this->getFirstName();
|
325 |
+
$last_name = $this->getLastName();
|
326 |
+
$email = $this->getEmail();
|
327 |
+
$hmac = $this->getHmac();
|
328 |
+
$hash = $this->_chippin->generateContributionHash($orderId, $first_name, $last_name, $email);
|
329 |
+
|
330 |
+
if($hash !== $hmac) {
|
331 |
+
Mage::logException(new Exception(sprintf('HMAC validation failed for order: %s hmac:%s !== hash:%s', $orderId, $hmac, $hash)));
|
332 |
+
throw new Exception('HMAC validation failed');
|
333 |
+
}
|
334 |
+
}
|
335 |
+
}
|
app/code/community/Chippin/ChippinPayment/data/chippinpayment_setup/data-install-0.1.0.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer = $this;
|
3 |
+
$connection = $installer->getConnection();
|
4 |
+
$installer->startSetup();
|
5 |
+
|
6 |
+
$data = array(
|
7 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_NEW, 'label' => 'Chippin New'),
|
8 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_INVITED, 'label' => 'Chippin Invited'),
|
9 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_CONTRIBUTED, 'label' => 'Chippin Contributed'),
|
10 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_REJECTED, 'label' => 'Chippin Rejected'),
|
11 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_COMPLETED, 'label' => 'Chippin Completed'),
|
12 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_PAID, 'label' => 'Chippin Paid'),
|
13 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_FAILED, 'label' => 'Chippin Failed'),
|
14 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_CANCELED, 'label' => 'Chippin Canceled'),
|
15 |
+
array('status' => Chippin_ChippinPayment_Model_Order::STATUS_TIMEDOUT, 'label' => 'Chippin Timed Out')
|
16 |
+
);
|
17 |
+
|
18 |
+
$mappingData = array(
|
19 |
+
array(
|
20 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_NEW,
|
21 |
+
'state' => Mage_Sales_Model_Order::STATE_NEW,
|
22 |
+
'is_default' => 0
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_INVITED,
|
26 |
+
'state' => Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
|
27 |
+
'is_default' => 0
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_CONTRIBUTED,
|
31 |
+
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
32 |
+
'is_default' => 0
|
33 |
+
),
|
34 |
+
array(
|
35 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_REJECTED,
|
36 |
+
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
37 |
+
'is_default' => 0
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_COMPLETED,
|
41 |
+
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
42 |
+
'is_default' => 0
|
43 |
+
),
|
44 |
+
array(
|
45 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_PAID,
|
46 |
+
'state' => Mage_Sales_Model_Order::STATE_PROCESSING,
|
47 |
+
'is_default' => 0
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_FAILED,
|
51 |
+
'state' => Mage_Sales_Model_Order::STATE_HOLDED,
|
52 |
+
'is_default' => 0
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_CANCELED,
|
56 |
+
'state' => Mage_Sales_Model_Order::STATE_CANCELED,
|
57 |
+
'is_default' => 0
|
58 |
+
),
|
59 |
+
array(
|
60 |
+
'status' => Chippin_ChippinPayment_Model_Order::STATUS_TIMEDOUT,
|
61 |
+
'state' => Mage_Sales_Model_Order::STATE_CANCELED,
|
62 |
+
'is_default' => 0
|
63 |
+
)
|
64 |
+
);
|
65 |
+
|
66 |
+
$statusTable = $installer->getTable('sales/order_status');
|
67 |
+
$statusStateTable = $installer->getTable('sales/order_status_state');
|
68 |
+
|
69 |
+
// Insert statuses
|
70 |
+
$installer->getConnection()->insertArray(
|
71 |
+
$statusTable,
|
72 |
+
array('status', 'label'),
|
73 |
+
$data
|
74 |
+
);
|
75 |
+
|
76 |
+
// Insert states and mapping of statuses to states
|
77 |
+
$installer->getConnection()->insertArray(
|
78 |
+
$statusStateTable,
|
79 |
+
array('status', 'state', 'is_default'),
|
80 |
+
$mappingData
|
81 |
+
);
|
82 |
+
|
83 |
+
$installer->endSetup();
|
app/code/community/Chippin/ChippinPayment/etc/config.xml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Chippin_ChippinPayment>
|
5 |
+
<version>0.1.3</version>
|
6 |
+
</Chippin_ChippinPayment>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<secure_url>
|
10 |
+
<chippin_standard>/chippin/standard</chippin_standard>
|
11 |
+
<chippin_checkout>/chippin/checkout</chippin_checkout>
|
12 |
+
</secure_url>
|
13 |
+
<routers>
|
14 |
+
<chippinpayment>
|
15 |
+
<use>standard</use>
|
16 |
+
<args>
|
17 |
+
<module>Chippin_ChippinPayment</module>
|
18 |
+
<frontName>chippin</frontName>
|
19 |
+
</args>
|
20 |
+
</chippinpayment>
|
21 |
+
</routers>
|
22 |
+
<layout>
|
23 |
+
<updates>
|
24 |
+
<chippinpayment>
|
25 |
+
<file>chippin.xml</file>
|
26 |
+
</chippinpayment>
|
27 |
+
</updates>
|
28 |
+
</layout>
|
29 |
+
</frontend>
|
30 |
+
<global>
|
31 |
+
<events>
|
32 |
+
<resource_get_tablename>
|
33 |
+
<observers>
|
34 |
+
<chippinpayment>
|
35 |
+
<class>chippinpayment/autoloader</class>
|
36 |
+
<method>register</method>
|
37 |
+
</chippinpayment>
|
38 |
+
</observers>
|
39 |
+
</resource_get_tablename>
|
40 |
+
</events>
|
41 |
+
<models>
|
42 |
+
<chippinpayment>
|
43 |
+
<class>Chippin_ChippinPayment_Model</class>
|
44 |
+
</chippinpayment>
|
45 |
+
</models>
|
46 |
+
<resources>
|
47 |
+
<chippinpayment_setup>
|
48 |
+
<setup>
|
49 |
+
<module>Chippin_ChippinPayment</module>
|
50 |
+
<class>Chippin_ChippinPayment_Model_Resource_Setup</class>
|
51 |
+
</setup>
|
52 |
+
</chippinpayment_setup>
|
53 |
+
</resources>
|
54 |
+
<helpers>
|
55 |
+
<chippinpayment>
|
56 |
+
<class>Chippin_ChippinPayment_Helper</class>
|
57 |
+
</chippinpayment>
|
58 |
+
</helpers>
|
59 |
+
<blocks>
|
60 |
+
<chippinpayment>
|
61 |
+
<class>Chippin_ChippinPayment_Block</class>
|
62 |
+
</chippinpayment>
|
63 |
+
</blocks>
|
64 |
+
<payment>
|
65 |
+
<groups>
|
66 |
+
<chippinpayment>ChippinPayment</chippinpayment>
|
67 |
+
</groups>
|
68 |
+
</payment>
|
69 |
+
</global>
|
70 |
+
<default>
|
71 |
+
<payment>
|
72 |
+
<chippinpayment>
|
73 |
+
<active>0</active>
|
74 |
+
<model>chippinpayment/payment_method</model>
|
75 |
+
<sandbox>1</sandbox>
|
76 |
+
<sandbox_endpoint>https://chippin.co.uk/sandbox/new</sandbox_endpoint>
|
77 |
+
<live_endpoint>https://chippin.co.uk/new</live_endpoint>
|
78 |
+
<title>Pay by Chippin to share the cost with others</title>
|
79 |
+
<description>You can share the cost of this purchase with others if you choose to pay by Chippin.</description>
|
80 |
+
<redirect_message>You will be redirected to the Chippin website when you place the order.</redirect_message>
|
81 |
+
<duration>48</duration>
|
82 |
+
<grace_period>48</grace_period>
|
83 |
+
</chippinpayment>
|
84 |
+
</payment>
|
85 |
+
</default>
|
86 |
+
</config>
|
app/code/community/Chippin/ChippinPayment/etc/system.xml
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<chippinpayment translate="label" module="chippinpayment">
|
7 |
+
<label>Chippin</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<expanded>1</expanded>
|
10 |
+
<sort_order>2000</sort_order>
|
11 |
+
<show_in_default>1</show_in_default>
|
12 |
+
<show_in_website>1</show_in_website>
|
13 |
+
<show_in_store>1</show_in_store>
|
14 |
+
<fields>
|
15 |
+
<active translate="label">
|
16 |
+
<label>Enabled</label>
|
17 |
+
<frontend_type>select</frontend_type>
|
18 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
19 |
+
<sort_order>10</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>1</show_in_store>
|
23 |
+
</active>
|
24 |
+
<merchant_id translate="label comment">
|
25 |
+
<label>Merchant ID</label>
|
26 |
+
<frontend_type>text</frontend_type>
|
27 |
+
<sort_order>20</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
<comment>Your unique merchant ID</comment>
|
32 |
+
</merchant_id>
|
33 |
+
<secret translate="label comment">
|
34 |
+
<label>Secret</label>
|
35 |
+
<frontend_type>password</frontend_type>
|
36 |
+
<sort_order>30</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>1</show_in_website>
|
39 |
+
<show_in_store>1</show_in_store>
|
40 |
+
<comment>Your unique secret token</comment>
|
41 |
+
</secret>
|
42 |
+
<sandbox translate="label">
|
43 |
+
<label>Use Sandbox</label>
|
44 |
+
<frontend_type>select</frontend_type>
|
45 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
46 |
+
<sort_order>40</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
</sandbox>
|
51 |
+
<sandbox_endpoint translate="label comment">
|
52 |
+
<label>Sandbox API URL</label>
|
53 |
+
<comment>[Default: https://chippin.co.uk/sandbox/new ] Only change this value if directed by your Chippin account manager</comment>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<sort_order>50</sort_order>
|
56 |
+
<show_in_default>1</show_in_default>
|
57 |
+
<show_in_website>1</show_in_website>
|
58 |
+
<show_in_store>0</show_in_store>
|
59 |
+
<!-- <depends><sandbox>1</sandbox></depends> -->
|
60 |
+
</sandbox_endpoint>
|
61 |
+
<live_endpoint translate="label comment">
|
62 |
+
<label>Live API URL</label>
|
63 |
+
<comment>[Default: https://chippin.co.uk/new ] Only change this value if directed by your Chippin account manager</comment>
|
64 |
+
<frontend_type>text</frontend_type>
|
65 |
+
<sort_order>60</sort_order>
|
66 |
+
<show_in_default>1</show_in_default>
|
67 |
+
<show_in_website>1</show_in_website>
|
68 |
+
<show_in_store>0</show_in_store>
|
69 |
+
<!-- <depends><sandbox>0</sandbox></depends> -->
|
70 |
+
</live_endpoint>
|
71 |
+
<!-- <order_status translate="label">
|
72 |
+
<label>New Order Status</label>
|
73 |
+
<frontend_type>select</frontend_type>
|
74 |
+
<source_model>adminhtml/system_config_source_order_status_processing</source_model>
|
75 |
+
<sort_order>70</sort_order>
|
76 |
+
<show_in_default>1</show_in_default>
|
77 |
+
<show_in_website>1</show_in_website>
|
78 |
+
<show_in_store>0</show_in_store>
|
79 |
+
</order_status> -->
|
80 |
+
<sort_order translate="label">
|
81 |
+
<label>Sort Order</label>
|
82 |
+
<frontend_type>text</frontend_type>
|
83 |
+
<sort_order>80</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
<show_in_website>1</show_in_website>
|
86 |
+
<show_in_store>1</show_in_store>
|
87 |
+
<frontend_class>validate-number</frontend_class>
|
88 |
+
</sort_order>
|
89 |
+
<title translate="label">
|
90 |
+
<label>Title</label>
|
91 |
+
<frontend_type>text</frontend_type>
|
92 |
+
<sort_order>90</sort_order>
|
93 |
+
<show_in_default>1</show_in_default>
|
94 |
+
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>1</show_in_store>
|
96 |
+
</title>
|
97 |
+
<description translate="label">
|
98 |
+
<label>Description</label>
|
99 |
+
<frontend_type>text</frontend_type>
|
100 |
+
<sort_order>91</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
</description>
|
105 |
+
<redirect_message translate="label">
|
106 |
+
<label>Redirection message</label>
|
107 |
+
<frontend_type>text</frontend_type>
|
108 |
+
<sort_order>92</sort_order>
|
109 |
+
<show_in_default>1</show_in_default>
|
110 |
+
<show_in_website>1</show_in_website>
|
111 |
+
<show_in_store>1</show_in_store>
|
112 |
+
</redirect_message>
|
113 |
+
<duration translate="label comment">
|
114 |
+
<label>Duration (hours)</label>
|
115 |
+
<frontend_type>text</frontend_type>
|
116 |
+
<sort_order>100</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>1</show_in_website>
|
119 |
+
<show_in_store>0</show_in_store>
|
120 |
+
<frontend_class>validate-number</frontend_class>
|
121 |
+
<comment>This is the number of hours you wish the 'chippin' to last before it times out.</comment>
|
122 |
+
</duration>
|
123 |
+
<grace_period translate="label comment">
|
124 |
+
<label>Grace Period (hours)</label>
|
125 |
+
<frontend_type>text</frontend_type>
|
126 |
+
<sort_order>105</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>1</show_in_website>
|
129 |
+
<show_in_store>0</show_in_store>
|
130 |
+
<frontend_class>validate-number</frontend_class>
|
131 |
+
<comment>This is the number of hours you wish to give the user to complete a chippin after the timeout period.</comment>
|
132 |
+
</grace_period>
|
133 |
+
<allowspecific translate="label">
|
134 |
+
<label>Payment from Applicable Countries</label>
|
135 |
+
<frontend_type>allowspecific</frontend_type>
|
136 |
+
<sort_order>110</sort_order>
|
137 |
+
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
|
138 |
+
<show_in_default>1</show_in_default>
|
139 |
+
<show_in_website>1</show_in_website>
|
140 |
+
<show_in_store>0</show_in_store>
|
141 |
+
</allowspecific>
|
142 |
+
<specificcountry translate="label">
|
143 |
+
<label>Payment from Specific Countries</label>
|
144 |
+
<frontend_type>multiselect</frontend_type>
|
145 |
+
<sort_order>120</sort_order>
|
146 |
+
<source_model>adminhtml/system_config_source_country</source_model>
|
147 |
+
<show_in_default>1</show_in_default>
|
148 |
+
<show_in_website>1</show_in_website>
|
149 |
+
<show_in_store>0</show_in_store>
|
150 |
+
<can_be_empty>1</can_be_empty>
|
151 |
+
</specificcountry>
|
152 |
+
<min_order_total translate="label comment">
|
153 |
+
<label>Minimum Order Total</label>
|
154 |
+
<frontend_type>text</frontend_type>
|
155 |
+
<sort_order>130</sort_order>
|
156 |
+
<show_in_default>1</show_in_default>
|
157 |
+
<show_in_website>1</show_in_website>
|
158 |
+
<show_in_store>0</show_in_store>
|
159 |
+
<comment>Minimum order value for Chippin to be available as a payment option.</comment>
|
160 |
+
</min_order_total>
|
161 |
+
<max_order_total translate="label comment">
|
162 |
+
<label>Maximum Order Total</label>
|
163 |
+
<frontend_type>text</frontend_type>
|
164 |
+
<sort_order>140</sort_order>
|
165 |
+
<show_in_default>1</show_in_default>
|
166 |
+
<show_in_website>1</show_in_website>
|
167 |
+
<show_in_store>0</show_in_store>
|
168 |
+
<comment>Maximum order value for Chippin to be available as a payment option.</comment>
|
169 |
+
</max_order_total>
|
170 |
+
<chippin_notice translate="label" module="chippinpayment">
|
171 |
+
<frontend_model>chippinpayment/adminhtml_system_config_fieldset_hint</frontend_model>
|
172 |
+
<signup_link>https://chippin.co.uk</signup_link>
|
173 |
+
<sort_order>150</sort_order>
|
174 |
+
<show_in_default>1</show_in_default>
|
175 |
+
<show_in_website>1</show_in_website>
|
176 |
+
<show_in_store>1</show_in_store>
|
177 |
+
</chippin_notice>
|
178 |
+
</fields>
|
179 |
+
</chippinpayment>
|
180 |
+
</groups>
|
181 |
+
</payment>
|
182 |
+
</sections>
|
183 |
+
</config>
|
app/design/adminhtml/default/default/template/chippinpayment/system/config/fieldset/hint.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ($this->getSignupLink()):
|
3 |
+
?>
|
4 |
+
<div class="chippin-payment-notice">
|
5 |
+
<?php echo Mage::helper('chippinpayment')->__('Not yet got a Chippin account? Click <a href="%s" target="_blank">here</a> to register.', $this->getSignupLink()); ?>
|
6 |
+
</div>
|
7 |
+
<?php
|
8 |
+
endif;
|
9 |
+
?>
|
10 |
+
<ul>
|
11 |
+
<li>
|
12 |
+
<strong>Integrtion Urls</strong><br/>
|
13 |
+
Enter these into the Chippin configuration screen.
|
14 |
+
</li>
|
15 |
+
<?php foreach ($this->getIntegrationUrls() as $label => $url) { ?>
|
16 |
+
<li><?php echo $label; ?>: <?php echo $url; ?></li>
|
17 |
+
<?php } ?>
|
18 |
+
</ul>
|
app/design/frontend/base/default/layout/chippin.xml
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<chippinpayment_checkout_contributed translate="label">
|
4 |
+
<label>Chippin Contributed</label>
|
5 |
+
<reference name="root">
|
6 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
7 |
+
</reference>
|
8 |
+
<reference name="content">
|
9 |
+
<block type="checkout/onepage_success" name="chippin.contributed" template="chippinpayment/contributed.phtml"/>
|
10 |
+
</reference>
|
11 |
+
</chippinpayment_checkout_contributed>
|
12 |
+
<chippinpayment_checkout_declined translate="label">
|
13 |
+
<label>Chippin Declined</label>
|
14 |
+
<reference name="root">
|
15 |
+
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
|
16 |
+
</reference>
|
17 |
+
<reference name="content">
|
18 |
+
<block type="checkout/onepage_failure" name="chippin.declined" template="chippinpayment/declined.phtml"/>
|
19 |
+
</reference>
|
20 |
+
</chippinpayment_checkout_declined>
|
21 |
+
</layout>
|
app/design/frontend/base/default/template/chippinpayment/contributed.phtml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="page-title">
|
2 |
+
<h1><?php echo $this->__('Thanks for chipping in.') ?></h1>
|
3 |
+
</div>
|
4 |
+
<?php echo $this->getMessagesBlock()->toHtml() ?>
|
5 |
+
|
6 |
+
<div class="buttons-set">
|
7 |
+
<button type="button" class="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue Shopping')) ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
8 |
+
</div>
|
app/design/frontend/base/default/template/chippinpayment/declined.phtml
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<div class="page-title">
|
2 |
+
<h1><?php echo $this->__('Sorry you weren’t able to chip in') ?></h1>
|
3 |
+
</div>
|
4 |
+
<p><?php echo $this->__('Click <a href="%s">here</a> to continue shopping.', Mage::helper('core')->quoteEscape($this->getContinueShoppingUrl())) ?></p>
|
app/design/frontend/base/default/template/chippinpayment/form/mark.phtml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div>
|
2 |
+
<p><?php echo $this->getDescription() ?></p>
|
3 |
+
<p class="form-alt"><?php echo $this->getRedirectMessage() ?></p>
|
4 |
+
<img class="v-middle" width="70" src="https://s3-eu-west-1.amazonaws.com/chippin-assets/chippin.png" alt="Chippin">
|
5 |
+
</div>
|
app/etc/modules/Chippin_ChippinPayment.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Chippin_ChippinPayment>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Core />
|
9 |
+
<Mage_Payment />
|
10 |
+
</depends>
|
11 |
+
<version>0.1.3</version>
|
12 |
+
</Chippin_ChippinPayment>
|
13 |
+
</modules>
|
14 |
+
</config>
|
lib/Chippin/SDK/Chippin.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Chippin\SDK;
|
4 |
+
|
5 |
+
class Chippin
|
6 |
+
{
|
7 |
+
private $merchant;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Interface for chippin creation specific fields
|
11 |
+
* @var array
|
12 |
+
*/
|
13 |
+
protected $_orderFields = array(
|
14 |
+
'merchant_id', 'merchant_order_id', 'total_amount', 'first_name', 'last_name', 'email', 'duration', 'grace_period', 'currency_code', 'hmac'
|
15 |
+
);
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Interface for chippin hash specific fields
|
19 |
+
* @var array
|
20 |
+
*/
|
21 |
+
protected $_orderHashFields = array(
|
22 |
+
'merchant_order_id', 'total_amount', 'duration', 'grace_period', 'currency_code'
|
23 |
+
);
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Interface for chippin product specific fields
|
28 |
+
* @var array
|
29 |
+
*/
|
30 |
+
protected $_chippinProductFields = array(
|
31 |
+
'label', 'image', 'amount'
|
32 |
+
);
|
33 |
+
|
34 |
+
|
35 |
+
public function __construct(Merchant $merchant)
|
36 |
+
{
|
37 |
+
$this->merchant = $merchant;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function generateContributionHash($merchant_order_id, $first_name, $last_name, $email)
|
41 |
+
{
|
42 |
+
return $this->generateHash(sprintf(
|
43 |
+
'contributed%s%s%s%s%s',
|
44 |
+
$this->merchant->getId(),
|
45 |
+
$merchant_order_id,
|
46 |
+
$first_name,
|
47 |
+
$last_name,
|
48 |
+
$email
|
49 |
+
));
|
50 |
+
}
|
51 |
+
|
52 |
+
public function generateCallbackHash($callbackKey = 'invited', $merchant_order_id)
|
53 |
+
{
|
54 |
+
return $this->generateHash(sprintf('%s%s%s', $callbackKey, $this->merchant->getId(), $merchant_order_id));
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Generate a hash from the required query params to authenticate the order
|
59 |
+
*
|
60 |
+
* @return String
|
61 |
+
*
|
62 |
+
*/
|
63 |
+
public function generateOrderHash($data)
|
64 |
+
{
|
65 |
+
$hashParts = array();
|
66 |
+
$hashParts[] = $this->merchant->getId();
|
67 |
+
foreach ($this->_orderHashFields as $field) {
|
68 |
+
if (empty($data[$field])) {
|
69 |
+
throw new \Exception(sprintf('The value for %s must be passed to generate the hmac hash', $field));
|
70 |
+
}
|
71 |
+
$hashParts[] = $data[$field];
|
72 |
+
}
|
73 |
+
|
74 |
+
return $this->generateHash(join($hashParts));
|
75 |
+
}
|
76 |
+
|
77 |
+
private function generateHash($string)
|
78 |
+
{
|
79 |
+
return hash_hmac('sha256', $string, $this->merchant->getSecret());
|
80 |
+
}
|
81 |
+
}
|
lib/Chippin/SDK/Merchant.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Chippin\SDK;
|
4 |
+
|
5 |
+
class Merchant
|
6 |
+
{
|
7 |
+
private $id;
|
8 |
+
private $secret;
|
9 |
+
|
10 |
+
public function __construct($id = null, $secret = null)
|
11 |
+
{
|
12 |
+
if (is_null($id)) {
|
13 |
+
throw new \InvalidArgumentException('Missing required parameter Merchant ID');
|
14 |
+
}
|
15 |
+
if (is_null($secret)) {
|
16 |
+
throw new \InvalidArgumentException('Missing required parameter Merchant Secret');
|
17 |
+
}
|
18 |
+
$this->id = $id;
|
19 |
+
$this->secret = $secret;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getId()
|
23 |
+
{
|
24 |
+
return $this->id;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getSecret()
|
28 |
+
{
|
29 |
+
return $this->secret;
|
30 |
+
}
|
31 |
+
}
|
package.xml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>chippinpayments</name>
|
4 |
+
<version>0.1.3</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="https://raw.githubusercontent.com/Chippin/magento-chippin/master/LICENSE">MIT</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Chippin is a shared payment gateway that allows you, the merchant, the ability to offer group buying for a single order. This means that a customer can split the cost of a purchase with their friends/family.</summary>
|
10 |
+
<description>Chippin is a shared payment gateway that allows you, the merchant, the ability to offer group buying for a single order. This means that a customer can split the cost of a purchase with their friends/family.
|
11 |
+

|
12 |
+
At the end of your checkout process, you redirect to Chippin with the basic details of the customer and your own unique order reference. At this point, the customer can invite their friends and family to ‘chippin’ for the item(s) they are purchasing.
|
13 |
+

|
14 |
+
Chippin is a simple ‘plug-in’ that integrates quickly and seamlessly into any merchant’s online checkout. It enables consumers to easily split the cost of an online transaction safely and securely to their own and the merchant’s benefit.</description>
|
15 |
+
<notes>Removed the sending of shipping lines to the payment gateway.</notes>
|
16 |
+
<authors><author><name>Toby Rhodes</name><user>chippin</user><email>alistair_stead+chippin@me.com</email></author><author><name>Alistair Stead</name><user>astead</user><email>alistair_stead@me.com</email></author></authors>
|
17 |
+
<date>2016-08-09</date>
|
18 |
+
<time>08:25:32</time>
|
19 |
+
<contents><target name="magecommunity"><dir name="Chippin"><dir name="ChippinPayment"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="d41a385341ed46cfc3985dd16feba85e"/></dir></dir></dir></dir><dir name="Form"><file name="Payment.php" hash="3a0271b81e0f2e4462d62bfdb25ca9b1"/></dir><dir name="Info"><file name="Payment.php" hash="dabf48fb246889ec342489ef8d1cede7"/></dir><file name="Redirect.php" hash="c0993c4c8b742f47b2e50cb4e8a79a82"/></dir><dir name="Helper"><file name="Checkout.php" hash="9d926f78da4debf034066f8e0909787c"/><file name="Data.php" hash="45c247e4644e5d947fd22f82f2298ca3"/></dir><dir name="Model"><file name="Autoloader.php" hash="3feb122acae6983aba3e1fd2987ec06e"/><file name="Config.php" hash="4eaf3cad0239f78cc32568626dd5ccd5"/><file name="Order.php" hash="3a85255dfc216e5c7f11dcb09832f04b"/><dir name="Payment"><file name="Method.php" hash="fc80bbd7cbd274a7e545895bb7617269"/></dir><dir name="Resource"><file name="Setup.php" hash="86818d277788c5ba4a6b00656aaf9b0e"/></dir></dir><dir name="controllers"><file name="CheckoutController.php" hash="20dd2caff614689b5fe253b427e4939a"/><file name="StandardController.php" hash="0f1a3c7a9f603326711be377a704e8f0"/></dir><dir name="data"><dir name="chippinpayment_setup"><file name="data-install-0.1.0.php" hash="70a757cb1d3c5a740a6751c8bb5ba229"/></dir></dir><dir name="etc"><file name="config.xml" hash="90354ec90e2ca99e0223ecc5396ee5fa"/><file name="system.xml" hash="a5045c351c97fddc10fe07e914b5ccc0"/></dir></dir></dir></target><target name="magelib"><dir name="Chippin"><dir name="SDK"><file name="Chippin.php" hash="8153aa6f7711b3e584eb15b922b8a6e3"/><file name="Merchant.php" hash="37bf825d41f2e6302bbee702c6171deb"/></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="chippinpayment"><file name="contributed.phtml" hash="1052c0346d429ffe0132c2f44f51b8b9"/><file name="declined.phtml" hash="789367eaac0e485e7526db9511eabfec"/><dir name="form"><file name="mark.phtml" hash="96911c10bf80f2eca89245ee575d628a"/></dir></dir></dir><dir name="layout"><file name="chippin.xml" hash="10deabd178d52fe3d3016c997a6fd2f8"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="chippinpayment"><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="c547f89744eaabb0cf05b849e359e04a"/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Chippin_ChippinPayment.xml" hash="fb9387544f7ea2ec147bdde89d5b7b6f"/></dir></target></contents>
|
20 |
+
<compatible/>
|
21 |
+
<dependencies><required><php><min>5.5.0</min><max>7.0.0</max></php></required></dependencies>
|
22 |
+
</package>
|