Version Notes
change api
Download this release
Release Info
Developer | taply |
Extension | taply |
Version | 1.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1.1 to 1.1.2
- app/code/local/Taply/Order/controllers/Taply/OrderController.php +7 -0
- app/code/local/Taply/Order/etc/config.xml +39 -0
- app/code/local/Taply/Order/etc/system_.xml +52 -0
- app/code/local/Taply/Paybutton/Block/Adminhtml/Sales/Order/View.php +73 -0
- app/code/local/Taply/Paybutton/Model/Payment.php +122 -19
- app/code/local/Taply/Paybutton/controllers/Adminhtml/Taply/OrderController.php +27 -0
- app/code/local/Taply/Paybutton/controllers/OrderController.php +7 -0
- app/code/local/Taply/Paybutton/controllers/SuccessController.php +73 -28
- app/code/local/Taply/Paybutton/etc/adminhtml.xml +14 -0
- app/code/local/Taply/Paybutton/etc/config.xml +6 -0
- js/taply/taply.1.1.js +1 -455
- package.xml +5 -5
app/code/local/Taply/Order/controllers/Taply/OrderController.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Taply_TaplyOrder_OrderController extends Mage_Core_Controller_Front_Action{
|
3 |
+
|
4 |
+
public function refundAction($payment){
|
5 |
+
echo "TEST";
|
6 |
+
}
|
7 |
+
}
|
app/code/local/Taply/Order/etc/config.xml
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Taply_Order>
|
5 |
+
<version>1.1.1</version>
|
6 |
+
</Taply_Order>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<admin>
|
10 |
+
<routers>
|
11 |
+
<admintaply>
|
12 |
+
<args>
|
13 |
+
<use>admintaply</use>
|
14 |
+
<module>Taply_Order</module>
|
15 |
+
</args>
|
16 |
+
</admintaply>
|
17 |
+
</routers>
|
18 |
+
</admin>
|
19 |
+
|
20 |
+
<!-- <admin>
|
21 |
+
<routers>
|
22 |
+
<taply_paybutton_adminhtml>
|
23 |
+
<use>taply</use>
|
24 |
+
<args>
|
25 |
+
<module>Taply_Paybutton_Adminhtml</module>
|
26 |
+
<frontName>taply</frontName>
|
27 |
+
</args>
|
28 |
+
</taply_paybutton_adminhtml>
|
29 |
+
</routers>
|
30 |
+
</admin>-->
|
31 |
+
<!-- <default>
|
32 |
+
<payment>
|
33 |
+
<taply>
|
34 |
+
<active>1</active>
|
35 |
+
<model>paybutton/payment</model>
|
36 |
+
</taply>
|
37 |
+
</payment>
|
38 |
+
</default>-->
|
39 |
+
</config>
|
app/code/local/Taply/Order/etc/system_.xml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<taply translate="label">
|
7 |
+
<label>Pay By Taply</label>
|
8 |
+
<sort_order>770</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</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>100</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 |
+
<merchant_id>
|
23 |
+
<label>Taply Store ID</label>
|
24 |
+
<frontend_type>text</frontend_type>
|
25 |
+
<sort_order>101</sort_order>
|
26 |
+
<show_in_default>1</show_in_default>
|
27 |
+
<show_in_website>1</show_in_website>
|
28 |
+
<show_in_store>0</show_in_store>
|
29 |
+
</merchant_id>
|
30 |
+
<description>
|
31 |
+
<label>Description</label>
|
32 |
+
<frontend_type>text</frontend_type>
|
33 |
+
<sort_order>102</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>0</show_in_store>
|
37 |
+
</description>
|
38 |
+
<view_type>
|
39 |
+
<label>View Type</label>
|
40 |
+
<frontend_type>select</frontend_type>
|
41 |
+
<source_model>paybutton/viewtype</source_model>
|
42 |
+
<sort_order>103</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>0</show_in_store>
|
46 |
+
</view_type>
|
47 |
+
</fields>
|
48 |
+
</taply>
|
49 |
+
</groups>
|
50 |
+
</payment>
|
51 |
+
</sections>
|
52 |
+
</config>
|
app/code/local/Taply/Paybutton/Block/Adminhtml/Sales/Order/View.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Taply_Paybutton_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
|
3 |
+
{
|
4 |
+
const TAPLY_API_URL = "http://rc-api.paybytaply.com/payment/";
|
5 |
+
|
6 |
+
public function __construct() {
|
7 |
+
//parent constructor
|
8 |
+
parent::__construct();
|
9 |
+
$paymentMethod = $this->getOrder()->getPayment()->getMethodInstance()->getCode();
|
10 |
+
$config = Mage::getStoreConfig('payment/taply');
|
11 |
+
|
12 |
+
if($paymentMethod === 'taply'){
|
13 |
+
|
14 |
+
$headBlock = Mage::app()->getLayout()->getBlock('head');
|
15 |
+
$items = $headBlock->getItems();
|
16 |
+
$items['skin_css/admin_taply.css'] = Array (
|
17 |
+
'type' => 'skin_css',
|
18 |
+
'name' => 'admin_taply.css',
|
19 |
+
'params' => "media=all",
|
20 |
+
'if' => null,
|
21 |
+
'cond' => null
|
22 |
+
);
|
23 |
+
$headBlock->setItems($items);
|
24 |
+
|
25 |
+
$url = self::TAPLY_API_URL . 'get-order-payment';
|
26 |
+
$process = curl_init($url);
|
27 |
+
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
|
28 |
+
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
29 |
+
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
|
30 |
+
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
|
31 |
+
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
32 |
+
curl_setopt($process, CURLOPT_POST, 1);
|
33 |
+
curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query(array("order_id" => $this->getOrder()->getId(), "merchantid" => $config['merchant_id'] )));
|
34 |
+
$strResponseJson = curl_exec( $process );
|
35 |
+
curl_close($process);
|
36 |
+
|
37 |
+
if($strResponseJson){
|
38 |
+
$arrResponse = json_decode( $strResponseJson, TRUE );
|
39 |
+
}
|
40 |
+
if($arrResponse['status'] === 'success'){
|
41 |
+
|
42 |
+
if($arrResponse['result']['tp_status'] === 1){
|
43 |
+
if(!$arrResponse['result']['tp_captured']){
|
44 |
+
$this->addButtons(['capture', 'void'], $arrResponse['result']['tp_id']);
|
45 |
+
}else{
|
46 |
+
$this->addButtons(['refund'], $arrResponse['result']['tp_id']);
|
47 |
+
}
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
protected function addButtons($arrButtons, $strPaymentId){
|
58 |
+
foreach ($arrButtons as $strButton){
|
59 |
+
|
60 |
+
$url = Mage::helper("adminhtml")->getUrl(
|
61 |
+
"adminhtml/taply_order/" . $strButton,
|
62 |
+
array('payment_id'=> $strPaymentId, 'order_id' => $this->getOrder()->getId())
|
63 |
+
);
|
64 |
+
$this->_addButton('cygtest_' . $strButton, array(
|
65 |
+
'label' => Mage::helper('sales')->__(ucfirst($strButton)),
|
66 |
+
'onclick' => 'setLocation(\'' . $url . '\')',
|
67 |
+
'class' => $strButton
|
68 |
+
));
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
}
|
73 |
+
|
app/code/local/Taply/Paybutton/Model/Payment.php
CHANGED
@@ -1,25 +1,8 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Magento
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-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@magento.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.magento.com for more information.
|
20 |
-
*
|
21 |
-
* @category Mage
|
22 |
-
* @package Mage_Adminhtml
|
23 |
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
24 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
25 |
*/
|
@@ -30,9 +13,129 @@
|
|
30 |
*/
|
31 |
class Taply_Paybutton_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
32 |
{
|
|
|
|
|
33 |
protected $_code = 'taply';
|
34 |
|
|
|
35 |
public function getTitle(){
|
36 |
return 'Taply';
|
37 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
}
|
1 |
<?php
|
2 |
/**
|
3 |
* Magento
|
4 |
+
* @category Taply
|
5 |
+
* @package Taply_Paybutton
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
|
7 |
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
*/
|
13 |
*/
|
14 |
class Taply_Paybutton_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
15 |
{
|
16 |
+
const TAPLY_API_URL = "http://rc-api.paybytaply.com/payment/";
|
17 |
+
|
18 |
protected $_code = 'taply';
|
19 |
|
20 |
+
|
21 |
public function getTitle(){
|
22 |
return 'Taply';
|
23 |
}
|
24 |
+
|
25 |
+
protected function _callApiMethod($strMethod, $arrParams = array()){
|
26 |
+
|
27 |
+
$arrResponse = array();
|
28 |
+
|
29 |
+
$process = curl_init(self::TAPLY_API_URL . $strMethod);
|
30 |
+
|
31 |
+
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
|
32 |
+
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
33 |
+
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
|
34 |
+
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
|
35 |
+
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
36 |
+
|
37 |
+
if (!empty($arrParams)){
|
38 |
+
$config = Mage::getStoreConfig('payment/taply');
|
39 |
+
$arrParams['merchant'] = $config['merchant_id'];
|
40 |
+
print_r($arrParams);
|
41 |
+
curl_setopt($process, CURLOPT_POST, 1);
|
42 |
+
curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($arrParams));
|
43 |
+
}
|
44 |
+
$strResponseJson = curl_exec( $process );
|
45 |
+
curl_close($process);
|
46 |
+
|
47 |
+
if($strResponseJson){
|
48 |
+
$arrResponse = json_decode( $strResponseJson, TRUE );
|
49 |
+
|
50 |
+
}
|
51 |
+
return $arrResponse;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Capture payment
|
56 |
+
*
|
57 |
+
* @param Mage_Sales_Model_Order_Payment $objPayment
|
58 |
+
* @param String $orderId
|
59 |
+
* @return Taply_Paybutton_Model_Payment
|
60 |
+
*/
|
61 |
+
public function capture(Varien_Object $objOrder)
|
62 |
+
{
|
63 |
+
$objPayment = $objOrder->getPayment();
|
64 |
+
$paymentId = $objPayment->getAdditionalInformation('payment_id');
|
65 |
+
$arrResponse = $this->_callApiMethod('capture', array('payment' => $paymentId));
|
66 |
+
if($arrResponse && !isset($arrResponse['error'])){
|
67 |
+
Mage::getSingleton('core/session')->addSuccess("Payment has been processed");
|
68 |
+
$this->createInvoice($objOrder);
|
69 |
+
$objOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
70 |
+
|
71 |
+
}else{
|
72 |
+
Mage::getSingleton('core/session')->addError('Taply Error: ' . $arrResponse['error']);
|
73 |
+
}
|
74 |
+
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $objOrder->getId())));
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Void payment
|
79 |
+
*
|
80 |
+
* @param Mage_Sales_Model_Order_Payment $objPayment
|
81 |
+
* @param String $orderId
|
82 |
+
* @return Taply_Paybutton_Model_Payment
|
83 |
+
*/
|
84 |
+
public function void(Varien_Object $objOrder)
|
85 |
+
{
|
86 |
+
$objPayment = $objOrder->getPayment();
|
87 |
+
$paymentId = $objPayment->getAdditionalInformation('payment_id');
|
88 |
+
$arrResponse = $this->_callApiMethod('void', array('payment' => $paymentId));
|
89 |
+
if($arrResponse && !isset($arrResponse['error'])){
|
90 |
+
Mage::getSingleton('core/session')->addSuccess("Payment has been voided");
|
91 |
+
}else{
|
92 |
+
Mage::getSingleton('core/session')->addError('Taply Error: ' . $arrResponse['error']);
|
93 |
+
}
|
94 |
+
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $objOrder->getId())));
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Refund payment
|
99 |
+
*
|
100 |
+
* @param Mage_Sales_Model_Order_Payment $objPayment
|
101 |
+
* @param String $orderId
|
102 |
+
* @return Taply_Paybutton_Model_Payment
|
103 |
+
*/
|
104 |
+
public function refund(Varien_Object $objOrder)
|
105 |
+
{
|
106 |
+
$objPayment = $objOrder->getPayment();
|
107 |
+
$paymentId = $objPayment->getAdditionalInformation('payment_id');
|
108 |
+
$arrResponse = $this->_callApiMethod('refund', array('payment' => $paymentId));
|
109 |
+
if($arrResponse && !isset($arrResponse['error'])){
|
110 |
+
Mage::getSingleton('core/session')->addSuccess("Payment has been refunded");
|
111 |
+
}else{
|
112 |
+
Mage::getSingleton('core/session')->addError('Taply Error: ' . $arrResponse['error']);
|
113 |
+
}
|
114 |
+
Mage::app()->getResponse()->setRedirect(Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $objOrder->getId())));
|
115 |
+
}
|
116 |
+
|
117 |
+
public function createInvoice($objOrder){
|
118 |
+
try {
|
119 |
+
if(!$objOrder->canInvoice()){
|
120 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
|
121 |
+
}
|
122 |
+
|
123 |
+
$invoice = Mage::getModel('sales/service_order', $objOrder)->prepareInvoice();
|
124 |
+
|
125 |
+
if (!$invoice->getTotalQty()) {
|
126 |
+
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
|
127 |
+
}
|
128 |
+
|
129 |
+
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
|
130 |
+
$invoice->register();
|
131 |
+
// $transactionSave = Mage::getModel('core/resource_transaction')
|
132 |
+
// ->addObject($invoice)
|
133 |
+
// ->addObject($invoice->getOrder());
|
134 |
+
//
|
135 |
+
// $transactionSave->save();
|
136 |
+
|
137 |
+
}catch (Mage_Core_Exception $e) {
|
138 |
+
|
139 |
+
}
|
140 |
+
}
|
141 |
}
|
app/code/local/Taply/Paybutton/controllers/Adminhtml/Taply/OrderController.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Taply_Paybutton_Adminhtml_Taply_OrderController extends Mage_Adminhtml_Controller_Action{
|
3 |
+
protected $_orderId = 0;
|
4 |
+
protected function getOrder(){
|
5 |
+
$this->orderId = $this->getRequest()->getParam('order_id');
|
6 |
+
$objOrder = Mage::getModel('sales/order')->load($this->orderId);
|
7 |
+
return $objOrder;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function captureAction(){
|
11 |
+
$objOrder = $this->getOrder();
|
12 |
+
$objOrder->getPayment()->getMethodInstance()->capture($objOrder);
|
13 |
+
|
14 |
+
}
|
15 |
+
|
16 |
+
public function voidAction(){
|
17 |
+
$objOrder = $this->getOrder();
|
18 |
+
$objOrder->getPayment()->getMethodInstance()->void($objOrder);
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
public function refundAction(){
|
23 |
+
$objOrder = $this->getOrder();
|
24 |
+
$objOrder->getPayment()->getMethodInstance()->refund($objOrder);
|
25 |
+
|
26 |
+
}
|
27 |
+
}
|
app/code/local/Taply/Paybutton/controllers/OrderController.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Taply_Paybutton_OrderController extends Mage_Core_Controller_Front_Action{
|
3 |
+
|
4 |
+
public function refundAction($payment){
|
5 |
+
// echo "TEST";
|
6 |
+
}
|
7 |
+
}
|
app/code/local/Taply/Paybutton/controllers/SuccessController.php
CHANGED
@@ -8,7 +8,8 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
8 |
protected function _callApiMethod($strMethod, $arrParams = array()){
|
9 |
|
10 |
$arrResponse = array();
|
11 |
-
$process = curl_init(self::TAPLY_API_URL . $strMethod);
|
|
|
12 |
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
|
13 |
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
14 |
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
|
@@ -26,22 +27,19 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
26 |
}
|
27 |
return $arrResponse;
|
28 |
}
|
29 |
-
|
30 |
-
|
31 |
public function indexAction()
|
32 |
-
{
|
33 |
$_params = $this->getRequest()->getParams();
|
34 |
$config = Mage::getStoreConfig('payment/taply');
|
35 |
-
$arrResponse = $this->_callApiMethod('get-payment-info', array('payment' => $_params['payment'], 'merchantid' => $config['merchant_id'] ));
|
36 |
-
|
37 |
-
if(!isset($arrResponse['result']['cart'])){
|
38 |
-
echo json_encode(array('error' => 'Carts not matched'));
|
39 |
-
exit();
|
40 |
-
}
|
41 |
$sOrderCartJson = $arrResponse['result']['cart'];
|
42 |
$sOrderTransaction = $arrResponse['result']['transaction'];
|
43 |
$arrOrderCart = is_string($sOrderCartJson)? json_decode($sOrderCartJson, TRUE) : $sOrderCartJson;
|
44 |
$arrOrderTransaction = is_string($sOrderTransaction)? json_decode( $sOrderTransaction, TRUE) : $sOrderTransaction;
|
|
|
45 |
if(isset($arrResponse['result']['order_id']) && $arrResponse['result']['order_id']){
|
46 |
$order = Mage::getModel('sales/order')->load($arrResponse['result']['order_id']);
|
47 |
|
@@ -70,12 +68,50 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
70 |
$product->addCustomOption('attributes', serialize($item['item_prod_attr']));
|
71 |
$request->setSuperAttribute($item['item_prod_attr']);
|
72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
if ($product->getId()) {
|
74 |
// Add product to card
|
75 |
$result = $quote->addProduct($product, $request);
|
76 |
if (is_string($result)) {
|
77 |
// Error of adding product to card
|
78 |
// @todo Log exception into DB and skip
|
|
|
79 |
throw new Exception($result);
|
80 |
}
|
81 |
} else {
|
@@ -88,20 +124,14 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
88 |
$objCustomer->loadByEmail($aUser['billingAddress']['email']);
|
89 |
if (!$objCustomer->getId()){
|
90 |
$objCustomer->setFirstname($aUser['billingAddress']['firstName'])
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
try{
|
97 |
$objCustomer->save();
|
98 |
$objCustomer->setConfirmation(null); //confirmation needed to register
|
99 |
$objCustomer->save(); //yes, this is also needed
|
100 |
$objCustomer->sendNewAccountEmail(); //send confirmation email to customer
|
101 |
-
|
102 |
-
// $newResetPasswordLinkToken = Mage::helper('customer')->generateResetPasswordLinkToken();
|
103 |
-
// $objCustomer->changeResetPasswordLinkToken($newResetPasswordLinkToken);
|
104 |
-
// $objCustomer->sendPasswordResetConfirmationEmail();
|
105 |
}
|
106 |
catch (Exception $e) {
|
107 |
Zend_Debug::dump($e->getMessage());
|
@@ -116,7 +146,7 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
116 |
'firstname' => $aUser['billingAddress']['firstName'],
|
117 |
'lastname' => $aUser['billingAddress']['lastName'],
|
118 |
'email' => $aUser['billingAddress']['email'],
|
119 |
-
'country_id' => $aUser['billingAddress']['country'],
|
120 |
'region' => $aUser['billingAddress']['state'],
|
121 |
'postcode' => $aUser['billingAddress']['zip'],
|
122 |
'street' => $aUser['billingAddress']['street1'], //array( $aUser['billingAddress']['street1'], $aUser['billingAddress']['street2'] ),
|
@@ -136,7 +166,6 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
136 |
'telephone' => $aUser['shippingAddress']['phone'],
|
137 |
'save_in_address_book' => 0,
|
138 |
);
|
139 |
-
//var_dump($arrOrderTransaction['shipping']['identifier']);die;
|
140 |
if(isset($arrOrderTransaction['shipping']['identifier']) && strpos(strtolower($arrResponse['result']['shipping']['identifier']), "free") === FALSE){
|
141 |
$shippingMethod = $arrOrderTransaction['shipping']['identifier'];
|
142 |
}else{
|
@@ -149,14 +178,21 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
149 |
->setPaymentMethod($this->_methodType)
|
150 |
->setCollectShippingRates(true)
|
151 |
->collectTotals();
|
152 |
-
$quote->getPayment()
|
|
|
|
|
153 |
$quote->collectTotals()->save();
|
154 |
$service = Mage::getModel('sales/service_quote', $quote);
|
155 |
$service->submitAll();
|
156 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
unset($quote);
|
159 |
-
unset($objCustomer);
|
160 |
unset($service);
|
161 |
echo json_encode( array('order_id' => $lastOrderId, 'redirect_url' => Mage::getUrl() . '/taply/success/thanks/order/' . $lastOrderId) );
|
162 |
|
@@ -166,12 +202,21 @@ class Taply_Paybutton_SuccessController extends Mage_Core_Controller_Front_Actio
|
|
166 |
}
|
167 |
|
168 |
}
|
169 |
-
|
170 |
public function thanksAction()
|
171 |
{
|
172 |
-
|
173 |
$_params = $this->getRequest()->getParams();
|
174 |
-
$
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
}
|
8 |
protected function _callApiMethod($strMethod, $arrParams = array()){
|
9 |
|
10 |
$arrResponse = array();
|
11 |
+
$process = curl_init(self::TAPLY_API_URL . $strMethod);
|
12 |
+
|
13 |
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
|
14 |
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
|
15 |
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, false);
|
27 |
}
|
28 |
return $arrResponse;
|
29 |
}
|
30 |
+
|
31 |
+
|
32 |
public function indexAction()
|
33 |
+
{
|
34 |
$_params = $this->getRequest()->getParams();
|
35 |
$config = Mage::getStoreConfig('payment/taply');
|
36 |
+
$arrResponse = $this->_callApiMethod('get-payment-info', array('payment' => $_params['payment'], 'merchantid' => $config['merchant_id'] ));
|
37 |
+
|
|
|
|
|
|
|
|
|
38 |
$sOrderCartJson = $arrResponse['result']['cart'];
|
39 |
$sOrderTransaction = $arrResponse['result']['transaction'];
|
40 |
$arrOrderCart = is_string($sOrderCartJson)? json_decode($sOrderCartJson, TRUE) : $sOrderCartJson;
|
41 |
$arrOrderTransaction = is_string($sOrderTransaction)? json_decode( $sOrderTransaction, TRUE) : $sOrderTransaction;
|
42 |
+
|
43 |
if(isset($arrResponse['result']['order_id']) && $arrResponse['result']['order_id']){
|
44 |
$order = Mage::getModel('sales/order')->load($arrResponse['result']['order_id']);
|
45 |
|
68 |
$product->addCustomOption('attributes', serialize($item['item_prod_attr']));
|
69 |
$request->setSuperAttribute($item['item_prod_attr']);
|
70 |
}
|
71 |
+
$links = Mage::getModel('downloadable/product_type')->getLinks( $product );
|
72 |
+
// if ($product->getTypeId() == 'simple') {
|
73 |
+
// $product->addProduct($product , 1);
|
74 |
+
// // for downloadable product
|
75 |
+
// } else
|
76 |
+
if ($product->getTypeId() == 'downloadable') {
|
77 |
+
$params = array();
|
78 |
+
$links = Mage::getModel('downloadable/product_type')->getLinks( $product );
|
79 |
+
$linkId = 0;
|
80 |
+
foreach ($links as $link) {
|
81 |
+
$linkId = $link->getId();
|
82 |
+
}
|
83 |
+
$params['product'] = $item['item_prod_id'];
|
84 |
+
$params['qty'] = $item['item_qty'];
|
85 |
+
$params['links'] = array($linkId);
|
86 |
+
$request = new Varien_Object();
|
87 |
+
$request->setData($params);
|
88 |
+
$product->processBuyRequest($product , $request);
|
89 |
+
// $product->addProduct($product , $request);
|
90 |
+
}
|
91 |
+
// if($links){
|
92 |
+
// $preparedLinks = array();
|
93 |
+
// foreach ($links as $link) {
|
94 |
+
// $preparedLinks[] = $link->getId();
|
95 |
+
// }
|
96 |
+
// if ($preparedLinks) {
|
97 |
+
//
|
98 |
+
// file_put_contents('/tmp/taply.log', print_r($preparedLinks, true));
|
99 |
+
// $product->addCustomOption('downloadable_link_ids', implode(',', $preparedLinks));
|
100 |
+
// }
|
101 |
+
//
|
102 |
+
//
|
103 |
+
//
|
104 |
+
//
|
105 |
+
//
|
106 |
+
// $request->setLinks($links);
|
107 |
+
// }
|
108 |
if ($product->getId()) {
|
109 |
// Add product to card
|
110 |
$result = $quote->addProduct($product, $request);
|
111 |
if (is_string($result)) {
|
112 |
// Error of adding product to card
|
113 |
// @todo Log exception into DB and skip
|
114 |
+
file_put_contents('/tmp/taply.log', print_r($result, true), 8);
|
115 |
throw new Exception($result);
|
116 |
}
|
117 |
} else {
|
124 |
$objCustomer->loadByEmail($aUser['billingAddress']['email']);
|
125 |
if (!$objCustomer->getId()){
|
126 |
$objCustomer->setFirstname($aUser['billingAddress']['firstName'])
|
127 |
+
->setLastname($aUser['billingAddress']['lastName'])
|
128 |
+
->setEmail($aUser['billingAddress']['email'])
|
129 |
+
->setPassword($objCustomer->generatePassword(7));
|
|
|
|
|
130 |
try{
|
131 |
$objCustomer->save();
|
132 |
$objCustomer->setConfirmation(null); //confirmation needed to register
|
133 |
$objCustomer->save(); //yes, this is also needed
|
134 |
$objCustomer->sendNewAccountEmail(); //send confirmation email to customer
|
|
|
|
|
|
|
|
|
135 |
}
|
136 |
catch (Exception $e) {
|
137 |
Zend_Debug::dump($e->getMessage());
|
146 |
'firstname' => $aUser['billingAddress']['firstName'],
|
147 |
'lastname' => $aUser['billingAddress']['lastName'],
|
148 |
'email' => $aUser['billingAddress']['email'],
|
149 |
+
'country_id' => $aUser['billingAddress']['country'] ? $aUser['billingAddress']['country'] : 'US',
|
150 |
'region' => $aUser['billingAddress']['state'],
|
151 |
'postcode' => $aUser['billingAddress']['zip'],
|
152 |
'street' => $aUser['billingAddress']['street1'], //array( $aUser['billingAddress']['street1'], $aUser['billingAddress']['street2'] ),
|
166 |
'telephone' => $aUser['shippingAddress']['phone'],
|
167 |
'save_in_address_book' => 0,
|
168 |
);
|
|
|
169 |
if(isset($arrOrderTransaction['shipping']['identifier']) && strpos(strtolower($arrResponse['result']['shipping']['identifier']), "free") === FALSE){
|
170 |
$shippingMethod = $arrOrderTransaction['shipping']['identifier'];
|
171 |
}else{
|
178 |
->setPaymentMethod($this->_methodType)
|
179 |
->setCollectShippingRates(true)
|
180 |
->collectTotals();
|
181 |
+
$objPayment = $quote->getPayment();
|
182 |
+
$objPayment->importData(array('method' => $this->_methodType));
|
183 |
+
$objPayment->setAdditionalInformation('payment_id',$_params['payment']);
|
184 |
$quote->collectTotals()->save();
|
185 |
$service = Mage::getModel('sales/service_quote', $quote);
|
186 |
$service->submitAll();
|
187 |
+
$objOrder = $service->getOrder();
|
188 |
+
if($arrResponse['result']['captured']){
|
189 |
+
$objPayment->getMethodInstance()->createInvoice($objOrder);
|
190 |
+
$objOrder->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
|
191 |
+
}
|
192 |
+
$lastOrderId = $objOrder->getId();
|
193 |
+
$objOrder->sendNewOrderEmail();
|
194 |
|
195 |
unset($quote);
|
|
|
196 |
unset($service);
|
197 |
echo json_encode( array('order_id' => $lastOrderId, 'redirect_url' => Mage::getUrl() . '/taply/success/thanks/order/' . $lastOrderId) );
|
198 |
|
202 |
}
|
203 |
|
204 |
}
|
205 |
+
|
206 |
public function thanksAction()
|
207 |
{
|
208 |
+
try{
|
209 |
$_params = $this->getRequest()->getParams();
|
210 |
+
$order = Mage::getModel('sales/order')->load( $_params['order']);
|
211 |
+
|
212 |
+
$objChecoutSession = Mage::getSingleton('checkout/session');
|
213 |
+
$objChecoutSession->setLastQuoteId($order->getQuoteId())->setLastSuccessQuoteId($order->getQuoteId())
|
214 |
+
->setLastOrderId($order->getId())->setLastRealOrderId($order->getIncrementId());
|
215 |
+
|
216 |
+
Mage::getSingleton('checkout/cart')->truncate()->save();
|
217 |
+
$this->_redirect('checkout/onepage/success');
|
218 |
+
} catch (Exception $e){
|
219 |
+
echo $e->getMessage();
|
220 |
+
}
|
221 |
}
|
222 |
}
|
app/code/local/Taply/Paybutton/etc/adminhtml.xml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<admin>
|
3 |
+
<routers>
|
4 |
+
<adminhtml>
|
5 |
+
<args>
|
6 |
+
<modules>
|
7 |
+
<taply>Taply_Paybutton_Adminhtml</taply>
|
8 |
+
</modules>
|
9 |
+
</args>
|
10 |
+
</adminhtml>
|
11 |
+
</routers>
|
12 |
+
</admin>
|
13 |
+
|
14 |
+
</config>
|
app/code/local/Taply/Paybutton/etc/config.xml
CHANGED
@@ -36,8 +36,14 @@
|
|
36 |
<paybutton>
|
37 |
<class>Taply_Paybutton_Block</class>
|
38 |
</paybutton>
|
|
|
|
|
|
|
|
|
|
|
39 |
</blocks>
|
40 |
</global>
|
|
|
41 |
<default>
|
42 |
<payment>
|
43 |
<taply>
|
36 |
<paybutton>
|
37 |
<class>Taply_Paybutton_Block</class>
|
38 |
</paybutton>
|
39 |
+
<adminhtml>
|
40 |
+
<rewrite>
|
41 |
+
<sales_order_view>Taply_Paybutton_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
42 |
+
</rewrite>
|
43 |
+
</adminhtml>
|
44 |
</blocks>
|
45 |
</global>
|
46 |
+
|
47 |
<default>
|
48 |
<payment>
|
49 |
<taply>
|
js/taply/taply.1.1.js
CHANGED
@@ -1,455 +1 @@
|
|
1 |
-
(function(w,d) {
|
2 |
-
function transitionSelect() {
|
3 |
-
var el = d.createElement("div");
|
4 |
-
if (el.style.WebkitTransition) return "webkitTransitionEnd";
|
5 |
-
if (el.style.OTransition) return "oTransitionEnd";
|
6 |
-
return 'transitionend';
|
7 |
-
};
|
8 |
-
|
9 |
-
w.TaplyDlg = {
|
10 |
-
options: {
|
11 |
-
dialogContent: '<div class="dialog-header"><div><h4 class="modal-title taply-title">taply</h4></div></div><div class="dialog-body"><div><p>Please enter your mobile phone number to complete your payment</p><div class="input-field text-field "><input class="phone" name="phone" type="tel" value=""/></div><div class="input-field checkbox-field"><input class="save-phone" type="checkbox" id="save-mobile-number" value="save-mobile-number"/> <label for="save-mobile-number">Save mobile phone number</label></div></div></div><div class="dialog-footer"><div><button class="btn pay">Pay</button></div></div>',
|
12 |
-
autoOpen: false,
|
13 |
-
className: 'taply-dialog',
|
14 |
-
closeBtn: true,
|
15 |
-
content: "",
|
16 |
-
maxWidth: 360,
|
17 |
-
minWidth: 280,
|
18 |
-
overlay: true
|
19 |
-
},
|
20 |
-
savedPhone: '',
|
21 |
-
initialized: false,
|
22 |
-
modal: null,
|
23 |
-
overlay: null,
|
24 |
-
closeBtn: null,
|
25 |
-
transitionEnd: transitionSelect(),
|
26 |
-
init: function(){
|
27 |
-
if(w.TaplyDlg.phone) return;
|
28 |
-
var t = w.TaplyDlg,dF = d.createDocumentFragment(),cH;
|
29 |
-
if(t.overlay && t.overlay.parentNode) t.overlay.parentNode.removeChild(t.overlay);
|
30 |
-
if(t.modal && t.modal.parentNode) t.modal.parentNode.removeChild(t.modal);
|
31 |
-
|
32 |
-
if (t.options.overlay === true) {
|
33 |
-
t.overlay = d.createElement("div");
|
34 |
-
t.overlay.className = "taply-modal-overlay " + t.options.className;
|
35 |
-
dF.appendChild(this.overlay);
|
36 |
-
}
|
37 |
-
// create modal element
|
38 |
-
t.modal = d.createElement("div");
|
39 |
-
t.modal.className = "taply-modal " + t.options.className;
|
40 |
-
t.modal.style.minWidth = t.options.minWidth + "px";
|
41 |
-
t.modal.style.maxWidth = t.options.maxWidth + "px";
|
42 |
-
|
43 |
-
// create content area
|
44 |
-
cH = d.createElement("div");
|
45 |
-
cH.className = "taply-modal-window";
|
46 |
-
cH.innerHTML = t.options.dialogContent;
|
47 |
-
t.content = cH;
|
48 |
-
// if closeBtn option is true, build a close button, append close button and content to area
|
49 |
-
if (t.options.closeBtn === true) {
|
50 |
-
t.closeBtn = d.createElement("button");
|
51 |
-
t.closeBtn.className = "taply-modal-close pay-later";
|
52 |
-
t.closeBtn.innerHTML = "Close";
|
53 |
-
|
54 |
-
t.modal.appendChild(cH).appendChild(t.closeBtn);
|
55 |
-
|
56 |
-
} else {
|
57 |
-
// append content to area
|
58 |
-
this.modal.appendChild(cH);
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
// append modal to DocumentFragment
|
63 |
-
dF.appendChild(t.modal);
|
64 |
-
|
65 |
-
// append DocumentFragment to body
|
66 |
-
d.body.appendChild(dF);
|
67 |
-
var ps = t.modal.getElementsByTagName("input");
|
68 |
-
for ( var p=0;p<ps.length;p++ ){
|
69 |
-
if(ps[p].type == 'tel' || ps[p].type == 'text'){
|
70 |
-
ps[p].addEventListener('keydown', w.Taply.check.bind(t.current), false);
|
71 |
-
ps[p].module = t.current;
|
72 |
-
}
|
73 |
-
}
|
74 |
-
t.initializeEvents();
|
75 |
-
|
76 |
-
w.TaplyDlg.initialized = true;
|
77 |
-
},
|
78 |
-
// mask: function(ti){
|
79 |
-
// if(ti.onkeydown){
|
80 |
-
// ti.onkeydown = w.Taply.check;
|
81 |
-
// }
|
82 |
-
// },
|
83 |
-
send: function(){
|
84 |
-
w.Taply.send(w.TaplyDlg.current);
|
85 |
-
},
|
86 |
-
payLater: function(){
|
87 |
-
w.Taply.payLater(w.TaplyDlg.current);
|
88 |
-
w.TaplyDlg.close();
|
89 |
-
},
|
90 |
-
|
91 |
-
cancel: function(){
|
92 |
-
w.Taply.cancel(w.TaplyDlg.current);
|
93 |
-
w.TaplyDlg.close();
|
94 |
-
},
|
95 |
-
tryagain: function(){
|
96 |
-
w.TaplyDlg.open(w.TaplyDlg.current);
|
97 |
-
},
|
98 |
-
close: function() {
|
99 |
-
var t = w.TaplyDlg;
|
100 |
-
t.modal.className = t.modal.className.replace(" taply-modal-open", "");
|
101 |
-
t.overlay.className = t.overlay.className.replace(" taply-modal-overlay-open","");
|
102 |
-
},
|
103 |
-
open: function(block) {
|
104 |
-
|
105 |
-
var t = w.TaplyDlg;
|
106 |
-
t.current = block;
|
107 |
-
t.init();
|
108 |
-
t.current.phone = t.content.getElementsByClassName('phone')[0];
|
109 |
-
t.current.phone.module = block;
|
110 |
-
t.current.save_phone = t.content.getElementsByClassName('save-phone')[0];
|
111 |
-
if(w.Taply.savedPhone !== undefined && t.current.phone.value==''){
|
112 |
-
t.current.phone.value=w.Taply.savedPhone;
|
113 |
-
t.current.save_phone.checked = 1;
|
114 |
-
}
|
115 |
-
w.getComputedStyle(t.modal).height;
|
116 |
-
t.modal.className = t.modal.className + " taply-modal-open";
|
117 |
-
t.overlay.className = t.overlay.className + " taply-modal-overlay-open";
|
118 |
-
},
|
119 |
-
initializeEvents: function(){
|
120 |
-
var t = w.TaplyDlg;
|
121 |
-
var closeBtns = d.getElementsByClassName("close-modal");
|
122 |
-
if (closeBtns) {
|
123 |
-
for(var i=0;i<closeBtns.length;i++){
|
124 |
-
closeBtns[i].addEventListener('click', t.cancel.bind(t), false);
|
125 |
-
}
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
if (this.overlay) {
|
130 |
-
this.overlay.addEventListener('click', t.close.bind(t));
|
131 |
-
}
|
132 |
-
|
133 |
-
var payBtns = t.content.getElementsByClassName("btn pay");
|
134 |
-
if(payBtns.length){
|
135 |
-
payBtns[0].addEventListener('click', t.send.bind(t), false);
|
136 |
-
}
|
137 |
-
|
138 |
-
var payLaterBtns = t.modal.getElementsByClassName("pay-later");
|
139 |
-
if(payLaterBtns.length){
|
140 |
-
payLaterBtns[0].addEventListener('click', t.payLater.bind(t), false);
|
141 |
-
}
|
142 |
-
|
143 |
-
var tryAgainBtns = t.content.getElementsByClassName("btn try-again");
|
144 |
-
if(tryAgainBtns.length){
|
145 |
-
tryAgainBtns[0].addEventListener('click', t.tryagain.bind(t), false);
|
146 |
-
}
|
147 |
-
},
|
148 |
-
changeContent: function(c){
|
149 |
-
var b = w.TaplyDlg.content.getElementsByClassName('dialog-body')[0],n='Unknown error', f= '';
|
150 |
-
switch(c){
|
151 |
-
case 0:
|
152 |
-
n= '<div><p>' + (w.Taply.notifyMessages[c] ? w.Taply.notifyMessages[c] : n) + '</p></div>';
|
153 |
-
f='<div><button class="btn try-again">Try again</button></div>';
|
154 |
-
break;
|
155 |
-
case 1:
|
156 |
-
n='<div><div class="loader">Loading</div><p>' + w.Taply.notifyMessages[c] + '</p></div>';
|
157 |
-
f='<div>' + (w.Taply.showPayLater? '<button class="btn pay-later">Pay later</button>' : '') + '<button class="btn btn-alt close-modal">Cancel</button></div>'
|
158 |
-
break;
|
159 |
-
default :
|
160 |
-
n= '<div><p>' + (w.Taply.notifyMessages[c] ? w.Taply.notifyMessages[c] : n) + '</p></div>';
|
161 |
-
}
|
162 |
-
w.TaplyDlg.content.getElementsByClassName('dialog-footer')[0].innerHTML = f;
|
163 |
-
b.innerHTML = n;
|
164 |
-
w.TaplyDlg.initializeEvents();
|
165 |
-
}
|
166 |
-
};
|
167 |
-
w.TaplyModule = function(el,id){
|
168 |
-
var t=this;
|
169 |
-
t.id=id;
|
170 |
-
t.el = el;
|
171 |
-
t.type = el.attributes['data-type'] ? el.attributes['data-type'].value : 'item'; // (item, cart, auto)
|
172 |
-
|
173 |
-
t.phone = null;
|
174 |
-
t.save_phone = null;
|
175 |
-
t.view_type = el.attributes['data-view-type'] ? el.attributes['data-view-type'].value : 'popup';
|
176 |
-
|
177 |
-
switch(t.view_type){
|
178 |
-
case 'block':
|
179 |
-
var ps = el.getElementsByTagName('input');
|
180 |
-
if(ps.length){
|
181 |
-
for(var p=0;p<ps.length;p++){
|
182 |
-
if(ps[p].name == 'phone'){
|
183 |
-
t.phone = t.phone === null? ps[p] : t.phone;
|
184 |
-
ps[p].addEventListener('keydown', w.Taply.check.bind(t), false);
|
185 |
-
ps[p].module = t;
|
186 |
-
}
|
187 |
-
if(ps[p].name == 'save-phone'){
|
188 |
-
t.save_phone = ps[p];
|
189 |
-
}
|
190 |
-
}
|
191 |
-
}
|
192 |
-
|
193 |
-
break;
|
194 |
-
case 'popup':
|
195 |
-
if(w.Taply.dlg_css === undefined){
|
196 |
-
w.Taply.dlg_css=document.createElement("link");
|
197 |
-
w.Taply.dlg_css.setAttribute("rel", "stylesheet");
|
198 |
-
w.Taply.dlg_css.setAttribute("type", "text/css");
|
199 |
-
w.Taply.dlg_css.setAttribute("href", "//www.paybytaply.com/css/taply-dialog.css");
|
200 |
-
d.getElementsByTagName("head")[0].appendChild(w.Taply.dlg_css);
|
201 |
-
}
|
202 |
-
break;
|
203 |
-
}
|
204 |
-
t.btn = el.getElementsByClassName('taply-btn');
|
205 |
-
if(t.btn.length){
|
206 |
-
t.btn[0].onclick = function(e){
|
207 |
-
switch(t.view_type){
|
208 |
-
case 'block':
|
209 |
-
w.Taply.send(t);
|
210 |
-
break;
|
211 |
-
case 'popup':
|
212 |
-
w.TaplyDlg.open(t);
|
213 |
-
break;
|
214 |
-
}
|
215 |
-
return false;
|
216 |
-
}
|
217 |
-
}
|
218 |
-
t.notify = function(n){
|
219 |
-
var txt = w.Taply.notifyMessages[n];
|
220 |
-
switch(t.view_type){
|
221 |
-
case 'block':
|
222 |
-
var ps = t.el.getElementsByClassName('note');
|
223 |
-
if(ps.length){
|
224 |
-
ps[0].innerHTML = '<p>' + txt + '</p>';
|
225 |
-
}
|
226 |
-
break;
|
227 |
-
case 'popup':
|
228 |
-
w.TaplyDlg.changeContent(n);
|
229 |
-
break;
|
230 |
-
}
|
231 |
-
}
|
232 |
-
};
|
233 |
-
w.Taply = {
|
234 |
-
apiurl: "https://api.paybytaply.com/payment",
|
235 |
-
btnClass: 'taply-block',
|
236 |
-
modules: [],
|
237 |
-
mask: '(___) ___-____',
|
238 |
-
notifies:{
|
239 |
-
invalidPhone:0,
|
240 |
-
complete:1,
|
241 |
-
firstTime:2,
|
242 |
-
notInstall:3,
|
243 |
-
serverError:4
|
244 |
-
},
|
245 |
-
notifyMessages:{
|
246 |
-
'-3': "Your transaction has been refunded.",
|
247 |
-
'-2': "Your transaction has been deleted.",
|
248 |
-
'-1': "Your transaction has been canceled.",
|
249 |
-
'0' :'Please enter a valid phone number.',
|
250 |
-
'1' :'Please complete your payment on your taply mobile app.',
|
251 |
-
'2' :'Good news! Save $10 off your first taply transaction. Please download the taply app using the link texted to your mobile phone.',
|
252 |
-
'3' :'Please download the taply app using the link texted to your mobile phone.',
|
253 |
-
'4' :'Unknown error.',
|
254 |
-
'10': "Your transaction has been pending.",
|
255 |
-
'11': "Your transaction has been approved.",
|
256 |
-
'12': "Your order has been sent to your taply mobile app for checkout at a later time."
|
257 |
-
},
|
258 |
-
ls: function (url,f){
|
259 |
-
var h = d.getElementsByTagName("head")[0] || d.documentElement;
|
260 |
-
var s = d.createElement("script");
|
261 |
-
s.src = url;
|
262 |
-
s.onload = s.onreadystatechange = f;
|
263 |
-
h.insertBefore( s, h.firstChild );
|
264 |
-
},
|
265 |
-
format: function(p){
|
266 |
-
var s='',k=0,m=w.Taply.mask;
|
267 |
-
if(p.length){
|
268 |
-
for(var i=0;i<m.length;i++){
|
269 |
-
if(m[i] != '_'){
|
270 |
-
s+=m[i];
|
271 |
-
}else{
|
272 |
-
if(p[k]){
|
273 |
-
s+= p[k++];
|
274 |
-
}else{
|
275 |
-
break;
|
276 |
-
}
|
277 |
-
}
|
278 |
-
}
|
279 |
-
}
|
280 |
-
return s;
|
281 |
-
},
|
282 |
-
check: function(e){
|
283 |
-
var k = e.keyCode || e.charCode;
|
284 |
-
|
285 |
-
if(!e.ctrlKey && !(k > 47 && k < 58) && k != 8){
|
286 |
-
e.preventDefault();
|
287 |
-
}
|
288 |
-
|
289 |
-
var v=this.phone.value,p=parseInt( v.replace(/[^\d]/g,'') ,10);
|
290 |
-
p=isNaN(p)? '' : p.toString();
|
291 |
-
switch(e.keyCode){
|
292 |
-
case 13:
|
293 |
-
w.Taply.send(this);
|
294 |
-
break;
|
295 |
-
case 8:
|
296 |
-
return true;
|
297 |
-
case 46:
|
298 |
-
p = p.substr(0,p.length-1);
|
299 |
-
break;
|
300 |
-
default :
|
301 |
-
var c = String.fromCharCode(e.keyCode);
|
302 |
-
if(e.keyCode > 47 && e.keyCode < 58){
|
303 |
-
p = p + c;
|
304 |
-
}else if(e.keyCode > 95 && e.keyCode < 106){
|
305 |
-
p = p + (e.keyCode-96);
|
306 |
-
}else{
|
307 |
-
return false;
|
308 |
-
}
|
309 |
-
}
|
310 |
-
this.phone.value = w.Taply.format(p);
|
311 |
-
e.preventDefault();
|
312 |
-
return false;
|
313 |
-
},
|
314 |
-
init: function(){
|
315 |
-
// w.Taply.ls(w.Taply.apiurl + '/start?callback=Taply.initValues');
|
316 |
-
w.Taply.initValues();
|
317 |
-
var tbs = d.getElementsByClassName(w.Taply.btnClass);
|
318 |
-
for(var i=0; i<tbs.length; i++){
|
319 |
-
w.Taply.modules.push(new w.TaplyModule(tbs[i],w.Taply.modules.length) );
|
320 |
-
}
|
321 |
-
},
|
322 |
-
initValues: function(){
|
323 |
-
var phone = w.localStorage.getItem('taply_phone');
|
324 |
-
if(phone){
|
325 |
-
w.Taply.savedPhone = phone;
|
326 |
-
var tbs = d.getElementsByClassName(w.Taply.btnClass);
|
327 |
-
for(var i=0; i<tbs.length; i++){
|
328 |
-
var ps = tbs[i].getElementsByTagName('input');
|
329 |
-
for(var p=0;p<ps.length;p++){
|
330 |
-
if(ps[p].name == 'phone'){
|
331 |
-
ps[p].value = phone;
|
332 |
-
}
|
333 |
-
if(ps[p].name == 'save-phone'){
|
334 |
-
ps[p].checked = 1;
|
335 |
-
}
|
336 |
-
}
|
337 |
-
}
|
338 |
-
}
|
339 |
-
},
|
340 |
-
getParamStr: function(block,er){
|
341 |
-
var p='';
|
342 |
-
switch(block.type){
|
343 |
-
case 'item':
|
344 |
-
p = "&iuid=" + block.el.attributes['data-iuid'].value;
|
345 |
-
break;
|
346 |
-
case 'cart':
|
347 |
-
p = "&cart=" + encodeURIComponent(block.el.attributes['data-cart'].value);
|
348 |
-
break;
|
349 |
-
case 'auto':
|
350 |
-
// var cart = w.Taply.getCart(block);
|
351 |
-
break;
|
352 |
-
}
|
353 |
-
|
354 |
-
p += '&phone=' + block.phone.value.replace(/[\W_]/g,'')+ "&save_phone=" + (block.save_phone.checked? 1:0) + "&block_id=" + block.id;
|
355 |
-
return p; //(Taply.iuid !== undefined? "&iuid=" + Taply.iuid : "&cart=" + Taply.cart) + "&cc=" + Taply.dlg.country.value + "&phone=" + Taply.dlg.phone.value.replace(/[\W_]/g,'') + "&save_phone=" + (Taply.dlg.save_phone.checked? 1:0);
|
356 |
-
},
|
357 |
-
verify: function(block){
|
358 |
-
var pattern = new RegExp(/\(?([0-9]{3})\)?[\s]{0,1}[0-9]{3}[-]?[0-9]{4}/);
|
359 |
-
if(!pattern.test(block.phone.value)){
|
360 |
-
block.notify(w.Taply.notifies.invalidPhone);
|
361 |
-
return false;
|
362 |
-
}
|
363 |
-
return true;
|
364 |
-
},
|
365 |
-
send: function(block){
|
366 |
-
clearInterval(w.Taply.ch);
|
367 |
-
if(block.save_phone.checked){
|
368 |
-
w.Taply.savedPhone = block.phone.value;
|
369 |
-
w.localStorage.setItem('taply_phone',w.Taply.savedPhone);
|
370 |
-
}
|
371 |
-
if(w.Taply.verify(block)){
|
372 |
-
w.Taply.ls(w.Taply.apiurl + '/add?callback=Taply.checkResponse' + w.Taply.getParamStr(block));
|
373 |
-
}
|
374 |
-
},
|
375 |
-
cancel: function(block){
|
376 |
-
clearInterval(w.Taply.ch);
|
377 |
-
if(block.pid){
|
378 |
-
w.Taply.ls(w.Taply.apiurl + "/cancel?callback=n&payment=" + block.pid);
|
379 |
-
block.initialized = false;
|
380 |
-
}
|
381 |
-
},
|
382 |
-
payLater: function(block){
|
383 |
-
clearInterval(w.Taply.ch);
|
384 |
-
if(block.pid){
|
385 |
-
w.Taply.ls(w.Taply.apiurl + (w.Taply.showPayLater? '/paylater' : '/cancel' ) + "?callback=n&payment=" + block.pid);
|
386 |
-
block.initialized = false;
|
387 |
-
}
|
388 |
-
},
|
389 |
-
checkResponse: function(data){
|
390 |
-
var el, n='';
|
391 |
-
if(data.result !== undefined){
|
392 |
-
el = w.Taply.modules[data.result.block_id];
|
393 |
-
}
|
394 |
-
if(data.status == "success"){
|
395 |
-
if(el === undefined){
|
396 |
-
return;
|
397 |
-
}
|
398 |
-
w.Taply.showPayLater = data.result.pay_later_button;
|
399 |
-
if (data.result.payment_result == 1){
|
400 |
-
n = w.Taply.notifies.complete;
|
401 |
-
w.Taply.ch = setInterval(w.Taply.checkPayment,1000,data.result.payment);
|
402 |
-
}else{
|
403 |
-
if(data.result.firsttime){
|
404 |
-
n = w.Taply.notifies.firstTime;
|
405 |
-
}
|
406 |
-
n = w.Taply.notifies.notInstall;
|
407 |
-
}
|
408 |
-
|
409 |
-
}else{
|
410 |
-
n=w.Taply.notifies.serverError;
|
411 |
-
w.Taply.notifyMessages[n]='';
|
412 |
-
for(var i=0;i<data.errors.length;i++){
|
413 |
-
if(data.errors[i].error_code === 'E00901'){
|
414 |
-
n = w.Taply.notifies.invalidPhone;
|
415 |
-
break;
|
416 |
-
}else{
|
417 |
-
w.Taply.notifyMessages[n]+=data.errors[i].error_message + '</br>';
|
418 |
-
}
|
419 |
-
}
|
420 |
-
}
|
421 |
-
if(el !== undefined){
|
422 |
-
el.pid = data.result.payment;
|
423 |
-
el.notify(n);
|
424 |
-
}else{
|
425 |
-
alert(w.Taply.notifyMessages[n]);
|
426 |
-
}
|
427 |
-
},
|
428 |
-
checkPayment: function(pid){
|
429 |
-
w.Taply.ls(w.Taply.apiurl + "/get-payment-status?callback=Taply.checkPaymentResponse&payment=" + pid);
|
430 |
-
},
|
431 |
-
checkPaymentResponse: function(data){
|
432 |
-
var n = 'Unknown Error, try later';
|
433 |
-
if(data.status == "success"){
|
434 |
-
if (data.result.payment_status == 0){
|
435 |
-
return;
|
436 |
-
}
|
437 |
-
if(w.TaplyDlg.current){
|
438 |
-
w.TaplyDlg.current.pid=null;
|
439 |
-
}
|
440 |
-
clearInterval(w.Taply.ch);
|
441 |
-
n = data.result.payment_status<0? data.result.payment_status : data.result.payment_status + 10;
|
442 |
-
if(data.result.redirect !== undefined){
|
443 |
-
setTimeout(function(){w.location = data.result.redirect;},3000);
|
444 |
-
}
|
445 |
-
}
|
446 |
-
if(w.TaplyDlg.current){
|
447 |
-
w.TaplyDlg.current.notify(n);
|
448 |
-
};
|
449 |
-
},
|
450 |
-
};
|
451 |
-
var css=document.createElement("style");
|
452 |
-
css.innerHTML = ".pay-module .taply-apply-pay {background: url( //www.paybytaply.com/static/img/asset/pay-by-taply-btn-dark-wide.png ) no-repeat;display: block;float: right;height: 53px;margin-bottom: 10px;font-size: 0;width: 248px;}@media only screen and (min--moz-device-pixel-ratio: 2),only screen and (-o-min-device-pixel-ratio: 2/1),only screen and (-webkit-min-device-pixel-ratio: 2),only screen and (min-device-pixel-ratio: 2) {.pay-module .taply-apply-pay {background-image: url( //www.paybytaply.com/static/img/asset/pay-by-taply-btn-dark-wide-2x.png ); background-size: 248px 53px;}}.pay-module a {color: #6a0fa5; text-decoration: none; }.pay-module a:hover {text-decoration: underline; }.pay-module p {color: #959595; font-size: 16px; clear: both;}.pay-module h4 {color: #595959; font-size: 16px; margin-bottom: 10px; }.taply-modal button { box-shadow: none; }";
|
453 |
-
d.getElementsByTagName("head")[0].appendChild(css);
|
454 |
-
w.addEventListener('load', w.Taply.init.bind(w), false);
|
455 |
-
})(window,document);
|
1 |
+
!function(e,a){function t(){var e=a.createElement("div");return e.style.WebkitTransition?"webkitTransitionEnd":e.style.OTransition?"oTransitionEnd":"transitionend"}e.TaplyDlg={options:{dialogContent:'<form action="javascript:void(0)"><div class="dialog-header"><div><h4 class="modal-title taply-title">taply</h4></div></div><div class="dialog-body"><div><p>Please enter your mobile phone number to complete your payment</p><div class="input-field text-field "><input class="phone" name="phone" type="tel" value=""/></div><div class="input-field checkbox-field"><input class="save-phone" type="checkbox" id="save-mobile-number" value="save-mobile-number"/> <label for="save-mobile-number">Save mobile phone number</label></div></div></div><div class="dialog-footer"><div><button class="btn pay">Pay</button></div></div></form>',autoOpen:!1,className:"taply-dialog",closeBtn:!0,content:"",maxWidth:360,minWidth:280,overlay:!0},savedPhone:"",initialized:!1,modal:null,overlay:null,closeBtn:null,transitionEnd:t(),init:function(){if(!e.TaplyDlg.phone){var t,n=e.TaplyDlg,l=a.createDocumentFragment();n.overlay&&n.overlay.parentNode&&n.overlay.parentNode.removeChild(n.overlay),n.modal&&n.modal.parentNode&&n.modal.parentNode.removeChild(n.modal),n.options.overlay===!0&&(n.overlay=a.createElement("div"),n.overlay.className="taply-modal-overlay "+n.options.className,l.appendChild(this.overlay)),n.modal=a.createElement("div"),n.modal.className="taply-modal "+n.options.className,n.modal.style.minWidth=n.options.minWidth+"px",n.modal.style.maxWidth=n.options.maxWidth+"px",t=a.createElement("div"),t.className="taply-modal-window",t.innerHTML=n.options.dialogContent,n.content=t,n.options.closeBtn===!0?(n.closeBtn=a.createElement("button"),n.closeBtn.className="taply-modal-close pay-later",n.closeBtn.innerHTML="Close",n.modal.appendChild(t).appendChild(n.closeBtn)):this.modal.appendChild(t),l.appendChild(n.modal),a.body.appendChild(l);for(var o=n.modal.getElementsByTagName("input"),i=0;i<o.length;i++)("tel"==o[i].type||"text"==o[i].type)&&(o[i].addEventListener("keydown",e.Taply.check.bind(n.current),!1),o[i].module=n.current);n.initializeEvents(),e.TaplyDlg.initialized=!0}},send:function(){e.Taply.send(e.TaplyDlg.current)},payLater:function(){e.Taply.payLater(e.TaplyDlg.current),e.TaplyDlg.close()},cancel:function(){e.Taply.cancel(e.TaplyDlg.current),e.TaplyDlg.close()},tryagain:function(){e.TaplyDlg.open(e.TaplyDlg.current)},close:function(){var a=e.TaplyDlg;a.modal.className=a.modal.className.replace(" taply-modal-open",""),a.overlay.className=a.overlay.className.replace(" taply-modal-overlay-open","")},open:function(a){var t=e.TaplyDlg;t.current=a,t.init(),t.current.phone=t.content.getElementsByClassName("phone")[0],t.current.phone.module=a,t.current.save_phone=t.content.getElementsByClassName("save-phone")[0],void 0!==e.Taply.savedPhone&&""==t.current.phone.value&&(t.current.phone.value=e.Taply.format(e.Taply.savedPhone),t.current.save_phone.checked=1),e.getComputedStyle(t.modal).height,t.modal.className=t.modal.className+" taply-modal-open",t.overlay.className=t.overlay.className+" taply-modal-overlay-open",setTimeout(function(){t.current.phone.focus()},300)},initializeEvents:function(){var t=e.TaplyDlg,n=a.getElementsByClassName("close-modal");if(n)for(var l=0;l<n.length;l++)n[l].addEventListener("click",t.cancel.bind(t),!1);this.overlay&&this.overlay.addEventListener("click",t.close.bind(t));var o=t.content.getElementsByClassName("btn pay");o.length&&o[0].addEventListener("click",t.send.bind(t),!1);var i=t.modal.getElementsByClassName("pay-later");i.length&&i[0].addEventListener("click",t.payLater.bind(t),!1);var s=t.content.getElementsByClassName("btn try-again");s.length&&s[0].addEventListener("click",t.tryagain.bind(t),!1)},changeContent:function(a){var t=e.TaplyDlg.content.getElementsByClassName("dialog-body")[0],n="Unknown error",l="";switch(a){case 0:n="<div><p>"+(e.Taply.notifyMessages[a]?e.Taply.notifyMessages[a]:n)+"</p></div>",l='<div><button class="btn try-again">Try again</button></div>';break;case 1:n='<div><div class="loader">Loading</div><p>'+e.Taply.notifyMessages[a]+"</p></div>",l="<div>"+(e.Taply.showPayLater?'<button class="btn pay-later">Pay later</button>':"")+'<button class="btn btn-alt close-modal">Cancel</button></div>';break;default:n="<div><p>"+(e.Taply.notifyMessages[a]?e.Taply.notifyMessages[a]:n)+"</p></div>"}e.TaplyDlg.content.getElementsByClassName("dialog-footer")[0].innerHTML=l,t.innerHTML=n,e.TaplyDlg.initializeEvents()}},e.TaplyModule=function(t,n){var l=this;switch(l.id=n,l.el=t,l.type=t.attributes["data-type"]?t.attributes["data-type"].value:"item",l.phone=null,l.save_phone=null,l.view_type=t.attributes["data-view-type"]?t.attributes["data-view-type"].value:"popup",l.view_type){case"block":var o=t.getElementsByTagName("input");if(o.length)for(var i=0;i<o.length;i++)"phone"==o[i].name&&(l.phone=null===l.phone?o[i]:l.phone,o[i].addEventListener("keydown",e.Taply.check.bind(l),!1),o[i].module=l),"save-phone"==o[i].name&&(l.save_phone=o[i]);break;case"popup":void 0===e.Taply.dlg_css&&(e.Taply.dlg_css=document.createElement("link"),e.Taply.dlg_css.setAttribute("rel","stylesheet"),e.Taply.dlg_css.setAttribute("type","text/css"),e.Taply.dlg_css.setAttribute("href","//www.paybytaply.com/css/taply-dialog.css"),a.getElementsByTagName("head")[0].appendChild(e.Taply.dlg_css))}l.btn=t.getElementsByClassName("taply-btn"),l.btn.length&&(l.btn[0].onclick=function(a){switch(l.view_type){case"block":e.Taply.send(l);break;case"popup":e.TaplyDlg.open(l)}return!1}),l.notify=function(a){var t=e.Taply.notifyMessages[a];switch(l.view_type){case"block":var n=l.el.getElementsByClassName("note");n.length&&(n[0].innerHTML="<p>"+t+"</p>");break;case"popup":e.TaplyDlg.changeContent(a)}}},e.Taply={apiurl:"https://api.paybytaply.com/payment",btnClass:"taply-block",modules:[],mask:"(___) ___-____",notifies:{invalidPhone:0,complete:1,firstTime:2,notInstall:3,serverError:4,notActivate:5},notifyMessages:{"-3":"Your transaction has been refunded.","-2":"Your transaction has been deleted.","-1":"Your transaction has been canceled.",0:"Please enter a valid phone number.",1:"Please complete your payment on your taply mobile app.",2:"Good news! Save $10 off your first taply transaction. Please download the taply app using the link texted to your mobile phone.",3:"Please download the taply app using the link texted to your mobile phone.",4:"Unknown error.",5:"Please activate the taply app.",10:"Your transaction has been pending.",11:"Your transaction has been approved.",12:"Your order has been sent to your taply mobile app for checkout at a later time."},ls:function(e,t){var n=a.getElementsByTagName("head")[0]||a.documentElement,l=a.createElement("script");l.src=e,l.onload=l.onreadystatechange=function(){n.removeChild(l)},n.insertBefore(l,n.firstChild)},format:function(a){var t="",n=0,l=e.Taply.mask;if(a=a.replace(/[^\d]/g,""),a.length)for(var o=0;o<l.length;o++)if("_"!=l[o])t+=l[o];else{if(!a[n])break;t+=a[n++]}return t},check:function(a){var t=a.keyCode||a.charCode;a.ctrlKey||t>47&&58>t||8==t||9==t||a.preventDefault();var n=this.phone.value,l=parseInt(n.replace(/[^\d]/g,""),10);switch(l=isNaN(l)?"":l.toString(),a.keyCode){case 9:return;case 13:e.Taply.send(this);case 8:return!0;case 46:l=l.substr(0,l.length-1);break;default:var o=String.fromCharCode(a.keyCode);if(a.keyCode>47&&a.keyCode<58)l+=o;else{if(!(a.keyCode>95&&a.keyCode<106))return!1;l+=a.keyCode-96}}return this.phone.value=e.Taply.format(l),a.preventDefault(),!1},init:function(){e.Taply.initValues();for(var t=a.getElementsByClassName(e.Taply.btnClass),n=0;n<t.length;n++)e.Taply.modules.push(new e.TaplyModule(t[n],e.Taply.modules.length))},initValues:function(){var t=e.localStorage.getItem("taply_phone");if(t){e.Taply.savedPhone=t;for(var n=a.getElementsByClassName(e.Taply.btnClass),l=0;l<n.length;l++)for(var o=n[l].getElementsByTagName("input"),i=0;i<o.length;i++)"phone"==o[i].name&&(o[i].value=t),"save-phone"==o[i].name&&(o[i].checked=1)}},getCookie:function(e){var a=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return a?decodeURIComponent(a[1]):void 0},getParamStr:function(a,t){var n="";switch(a.type){case"item":n="&iuid="+a.el.attributes["data-iuid"].value;break;case"cart":if(a.el.attributes["data-shop"]&&"shopify"===a.el.attributes["data-shop"].value){var l=JSON.parse(a.el.attributes["data-cart"].value);l.shopify_cart=e.Taply.getCookie("cart"),a.el.attributes["data-cart"].value=JSON.stringify(l)}n="&cart="+encodeURIComponent(a.el.attributes["data-cart"].value);break;case"auto":}return n+="&phone="+a.phone.value.replace(/[\W_]/g,"")+"&save_phone="+(a.save_phone.checked?1:0)+"&block_id="+a.id},verify:function(a){var t=new RegExp(/\(?([0-9]{3})\)?[\s]{0,1}[0-9]{3}[-]?[0-9]{4}/);return t.test(a.phone.value)?!0:(a.notify(e.Taply.notifies.invalidPhone),!1)},send:function(a){clearInterval(e.Taply.ch),a.save_phone.checked&&(e.Taply.savedPhone=a.phone.value,e.localStorage.setItem("taply_phone",e.Taply.savedPhone)),e.Taply.verify(a)&&e.Taply.ls(e.Taply.apiurl+"/add?callback=Taply.checkResponse"+e.Taply.getParamStr(a))},cancel:function(a){clearInterval(e.Taply.ch),a.pid&&(e.Taply.ls(e.Taply.apiurl+"/cancel?callback=n&payment="+a.pid),a.initialized=!1)},payLater:function(a){clearInterval(e.Taply.ch),a.pid&&(e.Taply.ls(e.Taply.apiurl+(e.Taply.showPayLater?"/paylater":"/cancel")+"?callback=n&payment="+a.pid),a.initialized=!1)},checkResponse:function(a){var t,n="";if(void 0!==a.result&&(t=e.Taply.modules[a.result.block_id]),"success"==a.status){if(void 0===t)return;e.Taply.showPayLater=a.result.pay_later_button,a.result.payment_result?(n=e.Taply.notifies.complete,e.Taply.ch=setInterval(e.Taply.checkPayment,1e3,a.result.payment)):(n=e.Taply.notifies.notActivate,a.result.firsttime&&(n=e.Taply.notifies.firstTime),a.result.sms_status&&(n=e.Taply.notifies.notInstall))}else{n=e.Taply.notifies.serverError,e.Taply.notifyMessages[n]="";for(var l=0;l<a.errors.length;l++){if("E00901"===a.errors[l].error_code){n=e.Taply.notifies.invalidPhone;break}e.Taply.notifyMessages[n]+=a.errors[l].error_message}}void 0!==t?(t.pid=a.result.payment,t.notify(n)):e.TaplyDlg.changeContent(n),(n==e.Taply.notifies.notInstall||n==e.Taply.notifies.notActivate)&&e.setTimeout(function(){t.notify(1),e.Taply.ch=setInterval(e.Taply.checkPayment,1e3,a.result.payment)},5e3)},checkPayment:function(a){e.Taply.ls(e.Taply.apiurl+"/get-payment-status?callback=Taply.checkPaymentResponse&payment="+a)},checkPaymentResponse:function(a){var t="Unknown Error, try later";if("success"==a.status){if(0==a.result.payment_status)return;e.TaplyDlg.current&&(e.TaplyDlg.current.pid=null),clearInterval(e.Taply.ch),t=a.result.payment_status<0?a.result.payment_status:a.result.payment_status+10,void 0!==a.result.redirect&&setTimeout(function(){e.location=a.result.redirect},3e3)}e.TaplyDlg.current&&e.TaplyDlg.current.notify(t)}};var n=document.createElement("style");n.innerHTML=".pay-module .taply-apply-pay {background: url( //www.paybytaply.com/static/img/asset/pay-by-taply-btn-dark-wide.png ) no-repeat;display: block;float: right;height: 53px;margin-bottom: 10px;font-size: 0;width: 248px;}@media only screen and (min--moz-device-pixel-ratio: 2),only screen and (-o-min-device-pixel-ratio: 2/1),only screen and (-webkit-min-device-pixel-ratio: 2),only screen and (min-device-pixel-ratio: 2) {.pay-module .taply-apply-pay {background-image: url( //www.paybytaply.com/static/img/asset/pay-by-taply-btn-dark-wide-2x.png ); background-size: 248px 53px;}}.pay-module a {color: #6a0fa5; text-decoration: none; }.pay-module a:hover {text-decoration: underline; }.pay-module p {color: #959595; font-size: 16px; clear: both;}.pay-module h4 {color: #595959; font-size: 16px; margin-bottom: 10px; }.taply-modal button { box-shadow: none; }",a.getElementsByTagName("head")[0].appendChild(n),"complete"===document.readyState?e.Taply.init():e.addEventListener("load",e.Taply.init.bind(e),!1)}(window,document);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>taply</name>
|
4 |
-
<version>1.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
@@ -9,11 +9,11 @@
|
|
9 |
<summary>Securely checkout using Apple Pay</summary>
|
10 |
<description>Securely checkout using Apple Pay with only a tap of your finger and never enter your billing or shipping information again.
|
11 |
taply allows you to use Apple Pay for an incredibly fast, secure, and seamless online checkout. Go anywhere online that has the taply button, enter your mobile number, then use the taply app to complete the purchase using Touch ID.</description>
|
12 |
-
<notes>change api
|
13 |
<authors><author><name>taply</name><user>taply</user><email>admin@paybytaply.com</email></author></authors>
|
14 |
-
<date>
|
15 |
-
<time>
|
16 |
-
<contents><target name="magelocal"><dir><dir name="Taply"><dir name="Paybutton"><dir name="Block"><dir name="Button"><file name="Pay.php" hash="7c751e6a0aa7e1e015e5dd58e4c8f7da"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c8404ec959ddf4bf9fbee31fc2314d34"/></dir><dir name="Model"><file name="Payment.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.4.0</min><max>5.6.999</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>taply</name>
|
4 |
+
<version>1.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
<channel>community</channel>
|
9 |
<summary>Securely checkout using Apple Pay</summary>
|
10 |
<description>Securely checkout using Apple Pay with only a tap of your finger and never enter your billing or shipping information again.
|
11 |
taply allows you to use Apple Pay for an incredibly fast, secure, and seamless online checkout. Go anywhere online that has the taply button, enter your mobile number, then use the taply app to complete the purchase using Touch ID.</description>
|
12 |
+
<notes>change api </notes>
|
13 |
<authors><author><name>taply</name><user>taply</user><email>admin@paybytaply.com</email></author></authors>
|
14 |
+
<date>2016-01-27</date>
|
15 |
+
<time>15:31:09</time>
|
16 |
+
<contents><target name="magelocal"><dir><dir name="Taply"><dir name="Order"><dir name="controllers"><dir name="Taply"><file name="OrderController.php" hash="00eedb8b49cfe8ae1aecba1c40e3f17a"/></dir></dir><dir name="etc"><file name="config.xml" hash="80129765898cac5c81f83739352317e1"/><file name="system_.xml" hash="520313dbaf29da8a44325f1a2880d30a"/></dir></dir><dir name="Paybutton"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="View.php" hash="31dc5ad3ff90929a5adff81f6286d6cf"/></dir></dir></dir><dir name="Button"><file name="Pay.php" hash="7c751e6a0aa7e1e015e5dd58e4c8f7da"/></dir></dir><dir name="Helper"><file name="Data.php" hash="c8404ec959ddf4bf9fbee31fc2314d34"/></dir><dir name="Model"><file name="Payment.php" hash="f630057cc99ec86c542592a904055002"/><file name="Viewtype.php" hash="c39cf7f525e11ab1de3f10a939caf494"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Taply"><file name="OrderController.php" hash="5593f8a36002649d34f0c8e6b07ab4b6"/></dir></dir><file name="GetshippingController.php" hash="eddc9190345dffefbfcfcd59035af51d"/><file name="OrderController.php" hash="be686c5550ed8bc92340f3e9e5d7017b"/><file name="SuccessController.php" hash="db0ce352d1d7bce814b4024eeba88357"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7001550ad892cd8ca7a0917a0f9bd0bd"/><file name="config.xml" hash="f5880f339e17e42056f842ce1c42e876"/><file name="system.xml" hash="520313dbaf29da8a44325f1a2880d30a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Taply_Paybutton.xml" hash="2c4c33fa727a3fe1d863353583e1dfa0"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="taply.xml" hash="bc7a785448a0e2b2754e46fa786a5b3d"/></dir><dir name="template"><dir name="taply"><file name="button.phtml" hash="b6541c278d428eea006a782e11abe2e3"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="taply"><file name="taply.1.1.js" hash="84cbe3c8924bb5d3e0dfa947894a75e1"/></dir></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.4.0</min><max>5.6.999</max></php></required></dependencies>
|
19 |
</package>
|