MisterSoft_Paidy - Version 1.0.0

Version Notes

Auth or Auth/Capture
(Partial) capture
(Partial) Refund
Void
Test flagging
Mobile optimized

Download this release

Release Info

Developer Sergey Balitsky
Extension MisterSoft_Paidy
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/MisterSoft/Paidy/Block/Checkout/Form.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MisterSoft_Paidy_Block_Checkout_Form extends Mage_Payment_Block_Form {
3
+
4
+ protected function _construct() {
5
+ parent::_construct();
6
+ $this->setTemplate('mistersoft_paidy/checkout/form.phtml');
7
+ }
8
+ }
app/code/community/MisterSoft/Paidy/Block/Checkout/Paidy.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MisterSoft_Paidy_Block_Checkout_Paidy extends Mage_Core_Block_Template {
3
+
4
+ public function getApiKey() {
5
+ return Mage::getStoreConfig('payment/paidy/api_key');
6
+ }
7
+ public function getPaidyData() {
8
+ return Mage::getModel('paidy/paidy')->getPaidyData();;
9
+ }
10
+ }
app/code/community/MisterSoft/Paidy/Helper/Data.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ class Mistersoft_Paidy_Helper_Data extends Mage_Core_Helper_Abstract {
3
+ }
app/code/community/MisterSoft/Paidy/Model/Paidy.php ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Our test CC module adapter
5
+ */
6
+ class MisterSoft_Paidy_Model_Paidy extends Mage_Payment_Model_Method_Abstract
7
+ {
8
+ /**
9
+ * unique internal payment method identifier
10
+ *
11
+ * @var string [a-z0-9_]
12
+ */
13
+ protected $_code = 'paidy';
14
+
15
+ /**
16
+ * Here are examples of flags that will determine functionality availability
17
+ * of this module to be used by frontend and backend.
18
+ *
19
+ * @see all flags and their defaults in Mage_Payment_Model_Method_Abstract
20
+ *
21
+ * It is possible to have a custom dynamic logic by overloading
22
+ * public function can* for each flag respectively
23
+ */
24
+
25
+ protected $_isGateway = true;
26
+ protected $_canOrder = false;
27
+ protected $_canAuthorize = true;
28
+ protected $_canCapture = true;
29
+ protected $_canCapturePartial = true;
30
+ protected $_canCaptureOnce = false;
31
+ protected $_canRefund = true;
32
+ protected $_canRefundInvoicePartial = true;
33
+ protected $_canVoid = true;
34
+ protected $_canUseInternal = true;
35
+ protected $_canUseCheckout = true;
36
+ protected $_canUseForMultishipping = true;
37
+ protected $_isInitializeNeeded = false;
38
+ protected $_canFetchTransactionInfo = true;
39
+ protected $_canReviewPayment = false;
40
+ protected $_canCreateBillingAgreement = false;
41
+ protected $_canManageRecurringProfiles = true;
42
+ protected $_canSaveCc = false;
43
+
44
+
45
+ // form for hidden field
46
+ protected $_formBlockType = 'paidy/checkout_form';
47
+ protected $allowed_transactions = array(
48
+ 'status',
49
+ 'capture',
50
+ 'update',
51
+ 'close',
52
+ 'refund',
53
+ 'authorize'
54
+ );
55
+ const PAIDY_URL = 'https://api.paidy.com/pay/';
56
+ protected $last_result = null;
57
+
58
+ /**
59
+ * Here you will need to implement authorize, capture and void public methods
60
+ *
61
+ * @see examples of transaction specific public methods such as
62
+ * authorize, capture and void in MisterSoft_Paidy_Model_Paidy
63
+ */
64
+
65
+ /**
66
+ * Authorize payment
67
+ *
68
+ * @param Mage_Sales_Model_Order_Payment $payment
69
+ * @return MisterSoft_Paidy_Model_Paidy
70
+ */
71
+ public function authorize(Varien_Object $payment, $amount)
72
+ {
73
+ $pform = Mage::app()->getRequest()->getParams('payment');
74
+ if (!empty($pform['payment']['paymentid'])) {
75
+ if ($this->checkTransactionStatus($pform['payment']['paymentid'])) {
76
+ $payment->setTransactionId($pform['payment']['paymentid'])->setIsTransactionClosed(0);
77
+ } else {
78
+ $payment->setTransactionId($pform['payment']['paymentid'])->setIsTransactionClosed(0);
79
+ $payment->setIsTransactionPending(true);
80
+ $payment->setIsFraudDetected(true);
81
+ };
82
+ } else {
83
+ Mage::throwException(Mage::helper('paidy')->__('No paidy transaction information.'));
84
+ };
85
+ return $this;
86
+ }
87
+ /**
88
+ * Capture payment
89
+ *
90
+ * @param Mage_Sales_Model_Order_Payment $payment
91
+ * @return MisterSoft_Paidy_Model_Paidy
92
+ */
93
+ public function capture(Varien_Object $payment, $amount) {
94
+ $auth_tid = null;
95
+ if (!(($auth = $payment->getAuthorizationTransaction()) && ($auth_tid = $auth->getTxnId()))) {
96
+ $this->authorize($payment, $amount);
97
+ $auth_tid = $payment->getAuthorizationTransaction()->getTxnId();
98
+ }
99
+ if (is_null($auth_tid)) {
100
+ Mage::throwException(Mage::helper('paidy')->__('No authorize transaction find for capture'));
101
+ };
102
+ // process capture
103
+ $data = array($auth_tid);
104
+ // lookup for invoice
105
+ $invoice = Mage::registry('current_invoice');
106
+ if ( $invoice ) {
107
+ // TODO: PARTIAL PROCESS THERE - BUT NO DOCS FOR NOW
108
+ // fill data with partial info from invoice
109
+ $i = 1;
110
+ $seq = array();
111
+ foreach ($payment->getOrder()->getAllItems() as $oitem) {
112
+ $seq[$oitem->getItemId()] = $i++;
113
+ };
114
+ foreach ($invoice->getAllItems() as $item) {
115
+ if ($item->getParentId()) { continue; };
116
+
117
+ $paidy_item = array(
118
+ 'item_id' => (string)$seq[$item->getOrderItemId()],
119
+ 'quantity' => (int)$item->getQty()
120
+ );
121
+
122
+ $data['items'][] = $paidy_item;
123
+
124
+ };
125
+ $data['tax'] = $invoice->getTaxAmount();
126
+ $data['shipping'] = $invoice->getShippingAmount();
127
+ };
128
+ $result = $this->processTransaction('capture', $data);
129
+ if ($result->status == 'capture_success') {
130
+ // create transaction
131
+ $payment->setTransactionId($result->capture_id);
132
+ } else {
133
+ Mage::throwException(Mage::helper('paidy')->__('Cannot capture'));
134
+ };
135
+
136
+ return $this;
137
+ }
138
+
139
+
140
+ /**
141
+ * Refund capture
142
+ *
143
+ * @param Mage_Sales_Model_Order_Payment $payment
144
+ * @return MisterSoft_Paidy_Model_Paidy
145
+ */
146
+ public function refund(Varien_Object $payment, $amount)
147
+ {
148
+ $data = array($payment->getParentTransactionId(), (int)$amount);
149
+ $result = $this->processTransaction('refund', $data);
150
+ if ($result->status == 'refund_success') {
151
+ $payment->setTransactionId($payment->getParentTransactionId() . '-refund')->setIsTransactionClosed(1);
152
+ $payment->setShouldCloseParentTransaction(!$payment->getCreditmemo()->getInvoice()->canRefund());
153
+ } else {
154
+ Mage::throwException(Mage::helper('paidy')->__('Refund Failed'));
155
+ };
156
+ return $this;
157
+ }
158
+
159
+ public function void(Varien_Object $payment) {
160
+ $data = array($payment->getParentTransactionId());
161
+ $result = $this->processTransaction('close', $data);
162
+ if ($result->status == 'close_success') {
163
+ $payment->setTransactionId($payment->getParentTransactionId() . '-close')
164
+ ->setIsTransactionClosed(1)
165
+ ->setShouldCloseParentTransaction(1);
166
+ } else {
167
+ Mage::throwException(Mage::helper('paidy')->__('Void Failed'));
168
+ };
169
+ return $this;
170
+ }
171
+
172
+ public function cancel(Varien_Object $payment) {
173
+ return $this->void($payment);
174
+ }
175
+
176
+ /**
177
+ * Fetch transaction details info
178
+ *
179
+ * @param Mage_Payment_Model_Info $payment
180
+ * @param string $transactionId
181
+ * @return array
182
+ */
183
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
184
+ {
185
+ // we can fetch transaction only for auth transactions
186
+ $txn = $payment->getTransaction($transactionId);
187
+
188
+ if ($txn->getTxnType() != Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) {
189
+ Mage::throwException(sprintf(Mage::helper('paidy')->__("Only transaction with type '%s' can be fetched from Paidy.", Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH)));
190
+ return array();
191
+ };
192
+
193
+ $data = array($transactionId);
194
+ $result = $this->processTransaction('status', $data);
195
+ if (in_array($result->status, array('open', 'closed'))) {
196
+ $payment->setIsTransactionClosed($result->status != 'open');
197
+ //$payment->setIsTransactionApproved(true);
198
+ } else {
199
+ //$payment->setIsTransactionDenied(true);
200
+ Mage::throwException(Mage::helper('paidy')->__('Status Failed'));
201
+ };
202
+ Mage::log("fetchTransactionInfo - " . json_encode($result), Zend_Log::ERR, 'paidy.log');
203
+ return (array)$result;
204
+ }
205
+
206
+
207
+
208
+ /**
209
+ * Payment action getter compatible with payment model
210
+ *
211
+ * @see Mage_Sales_Model_Payment::place()
212
+ * @return string
213
+ */
214
+ public function getConfigPaymentAction() {
215
+ switch ($this->getConfigData('payment_action')) {
216
+ case 'auth':
217
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE;
218
+ case 'auth&capture':
219
+ return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE;
220
+ }
221
+ }
222
+ /*
223
+ * Check transaction status - is exists or not
224
+ */
225
+ private function checkTransactionStatus($tid) {
226
+ $result = $this->processTransaction('status', array($tid));
227
+ //Mage::log(print_r($result, true), Zend_Log::ERR, 'paidy.log', true);
228
+ $this->last_result = $result;
229
+ return ($result && $result->status === 'open');
230
+ }
231
+ private function processTransaction($type, $data) {
232
+ $result = null;
233
+ if (in_array($type, $this->allowed_transactions)) {
234
+ $request = array();
235
+ $payment_id = array_shift($data);
236
+ switch ($type) {
237
+ case 'refund':
238
+ $amount = array_shift($data);
239
+ if (!is_null($amount)) {
240
+ $request['amount'] = (int)$amount;
241
+ };
242
+ $request['capture_id'] = $payment_id;
243
+ $request['checksum'] = base64_encode( hash ('sha256', $this->getConfigData('api_secret') . $payment_id, true ) );
244
+ break;
245
+ case 'capture':
246
+ if (!empty($data)) {
247
+ foreach ($data as $dkey => $dvalue) {
248
+ $request[$dkey] = $dvalue;
249
+ }
250
+ };
251
+ case 'close':
252
+ case 'status':
253
+ $request['payment_id'] = $payment_id;
254
+ $request['checksum'] = base64_encode( hash ('sha256', $this->getConfigData('api_secret') . $payment_id, true ) );
255
+ break;
256
+ default:
257
+ Mage::throwException(Mage::helper('paidy')->__('Not existing transaction type'));
258
+ break;
259
+ };
260
+ $client = new Varien_Http_Client(self::PAIDY_URL . $type);
261
+ $client->setMethod(Varien_Http_Client::POST);
262
+ $client->setHeaders('Content-type: application/json');
263
+ $client->setHeaders('Authorization: Bearer ' . $this->getConfigData('api_key'));
264
+ $client->setRawData(json_encode($request));
265
+ Mage::log("Send - " . json_encode($request), Zend_Log::ERR, 'paidy.log');
266
+ $response = $client->request();
267
+ Mage::log("Received - " . $response->getBody(), Zend_Log::ERR, 'paidy.log');
268
+ if ($response->isError()) {
269
+ Mage::throwException($response->getMessage() . print_r($client, true));
270
+ };
271
+ $result = json_decode($response->getBody());
272
+ } else {
273
+ Mage::throwException(sprintf(Mage::helper('paidy')->__('Not allowed transaction type: %s'), $type));
274
+ };
275
+ return $result;
276
+ }
277
+ public function getPaidyData() {
278
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
279
+
280
+ $billing = $quote->getBillingAddress();
281
+ $customer = $quote->getCustomer();
282
+ $paidy_data = array();
283
+ $paidy_data['buyer'] = array();
284
+ $paidy_data['buyer']['name'] = $billing->getName();
285
+ $paidy_data['buyer']['name2'] = $billing->getName();
286
+ $paidy_data['buyer']['dob'] = $quote->getCustomerDob() ? $quote->getCustomerDob() : '';
287
+ $paidy_data['buyer']['email'] = array('address' => $quote->getCustomerEmail());
288
+ $paidy_data['buyer']['address'] = array(
289
+ 'address1' => $billing->getStreet2(),
290
+ 'address2' => $billing->getStreet1(),
291
+ 'address3' => $billing->getCity(),
292
+ 'address4' => $billing->getRegion() . ' ' . Mage::getModel('directory/country')->loadByCode($billing->getCountry())->getName(),
293
+ 'postal_code' => $billing->getPostcode()
294
+ );
295
+ $paidy_data['buyer']['phone'] = array('number' => $billing->getTelephone());
296
+ $paidy_data['order'] = array();
297
+ $paidy_data['order']['items'] = array();
298
+ $i = 1;
299
+ foreach ($quote->getAllItems() as $item) {
300
+ if ($item->getParentId()) { continue; };
301
+
302
+ $paidy_item = array(
303
+ 'item_id' => (string)$i++,
304
+ 'title' => (string)$item->getProduct()->getName(),
305
+ 'amount' => (int)$item->getPrice(),
306
+ 'quantity' => (int)$item->getQty()
307
+ );
308
+
309
+ $paidy_data['order']['items'][] = $paidy_item;
310
+ }
311
+ $paidy_data['order']['tax'] = (int)$quote->getShippingAddress()->getTaxAmount();
312
+ $paidy_data['order']['shipping'] = (int)$quote->getShippingAddress()->getShippingAmount();
313
+ $paidy_data['order']['total_amount'] = (int)$quote->getGrandTotal();
314
+
315
+ $paidy_data['merchant_data'] = $this->getMerchantData($customer);
316
+ $paidy_data['checksum'] = $this->getPaidyChecksum($paidy_data);
317
+ $paidy_data['tracking'] = array(
318
+ "cunsumer_ip" => $_SERVER['REMOTE_ADDR'],
319
+ );
320
+ $paidy_data['test'] = (bool)Mage::getStoreConfig('payment/paidy/test_mode');
321
+ $paidy_data["options"] = array(
322
+ "authorize_type" => "extended"
323
+ );
324
+
325
+ return $paidy_data;
326
+ }
327
+ private function getMerchantData($customer) {
328
+ $result = array(
329
+ "store" => Mage::getStoreConfig("payment/paidy/store_name")
330
+ ? Mage::getStoreConfig("payment/paidy/store_name") : Mage::app()->getStore()->getName(),
331
+ "category" => 1,
332
+ "customer_age" => 0,
333
+ "last_order" => 0,
334
+ "last_order_amount" => 0,
335
+ "num_orders" => 0,
336
+ "known_address" => false,
337
+ "ltv" => 0
338
+ );
339
+ $orders = Mage::getModel('sales/order')->getCollection()
340
+ ->addFieldToFilter('customer_id', $customer->getId())
341
+ ->addFieldToFilter('state', Mage::getStoreConfig('payment/paidy/completed_status'))
342
+ ->setOrder('created_at', 'ASC')
343
+ ->load();
344
+ $result["num_orders"] = $orders->count();
345
+ if ($first_order = $orders->getFirstItem()) {
346
+ $cdate = new DateTime();
347
+ $result['customer_age'] = (int)$cdate->diff(new DateTime($first_order->getCreatedAt()))->days;
348
+ };
349
+ if ($last_order = $orders->getLastItem()) {
350
+ $cdate = new DateTime();
351
+ $result['last_order'] = (int)$cdate->diff(new DateTime($last_order->getCreatedAt()))->days;
352
+ $result['last_order_amount'] = (int)$last_order->getGrandTotal();
353
+ };
354
+ foreach ($orders as $o) {
355
+ $result['ltv'] += $o->getGrandTotal();
356
+ };
357
+
358
+ return $result;
359
+ }
360
+ private function getPaidyChecksum($t) {
361
+ $string = Mage::getStoreConfig('payment/paidy/api_secret') .
362
+ $t['order']['total_amount'] .
363
+ $t['merchant_data']['store'] .
364
+ $t['merchant_data']['customer_age'] .
365
+ $t['merchant_data']['last_order'] .
366
+ $t['merchant_data']['last_order_amount'] .
367
+ ($t['merchant_data']['known_address'] ? 'true' : 'false' ) .
368
+ $t['merchant_data']['num_orders'] .
369
+ $t['merchant_data']['ltv'];
370
+
371
+ $sha = hash ('sha256', $string, true );
372
+
373
+ return base64_encode($sha);
374
+ }
375
+ }
376
+ ?>
app/code/community/MisterSoft/Paidy/Model/System/Config/Source/PaymentActions.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ */
5
+
6
+ /**
7
+ * Source model for available payment actions
8
+ */
9
+ class MisterSoft_Paidy_Model_System_Config_Source_PaymentActions
10
+ {
11
+ /**
12
+ * Options getter
13
+ *
14
+ * @return array
15
+ */
16
+ public function toOptionArray()
17
+ {
18
+ return array(
19
+ 'auth' => Mage::helper('paidy')->__('Authorization Only'),
20
+ 'auth&capture' => Mage::helper('paidy')->__('Authorization&Capture')
21
+ );
22
+ }
23
+ }
app/code/community/MisterSoft/Paidy/etc/config.xml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MisterSoft_Paidy>
5
+ <version>1.0.0</version>
6
+ </MisterSoft_Paidy>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <paidy>
11
+ <class>MisterSoft_Paidy_Helper</class>
12
+ </paidy>
13
+ </helpers>
14
+ <blocks>
15
+ <paidy>
16
+ <class>MisterSoft_Paidy_Block</class>
17
+ </paidy>
18
+ </blocks>
19
+ <models>
20
+ <paidy>
21
+ <class>MisterSoft_Paidy_Model</class>
22
+ </paidy>
23
+ </models>
24
+ <resources>
25
+ <mistersoft_paidy_setup>
26
+ <setup>
27
+ <module>MisterSoft_Paidy</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </mistersoft_paidy_setup>
33
+ <mistersoft_paidy_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </mistersoft_paidy_write>
38
+ <mistersoft_paidy_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </mistersoft_paidy_read>
43
+ </resources>
44
+ </global>
45
+ <frontend>
46
+ <layout>
47
+ <updates>
48
+ <mistersoft_paidy>
49
+ <file>mistersoft_paidy.xml</file>
50
+ </mistersoft_paidy>
51
+ </updates>
52
+ </layout>
53
+ <translate>
54
+ <modules>
55
+ <MisterSoft_Paidy>
56
+ <files>
57
+ <default>MisterSoft_Paidy.csv</default>
58
+ </files>
59
+ </MisterSoft_Paidy>
60
+ </modules>
61
+ </translate>
62
+ </frontend>
63
+ <adminhtml>
64
+ <translate>
65
+ <modules>
66
+ <MisterSoft_Paidy>
67
+ <files>
68
+ <default>MisterSoft_Paidy.csv</default>
69
+ </files>
70
+ </MisterSoft_Paidy>
71
+ </modules>
72
+ </translate>
73
+ </adminhtml>
74
+ <default>
75
+ <payment>
76
+ <paidy>
77
+ <active>0</active>
78
+ <model>paidy/paidy</model>
79
+ <payment_action>auth</payment_action>
80
+ <order_status>processing</order_status>
81
+ <completed_status>complete</completed_status>
82
+ <title>Paidy Payments</title>
83
+ <allowspecific>0</allowspecific>
84
+ </paidy>
85
+ </payment>
86
+ </default>
87
+ </config>
app/code/community/MisterSoft/Paidy/etc/system.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <paidy translate="label" module="paidy">
7
+ <label>Paidy Payments</label>
8
+ <sort_order>670</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>10</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
+ <title translate="label">
23
+ <label>Title</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>20</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
+ </title>
30
+ <payment_action translate="label">
31
+ <label>Payment Action</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>paidy/system_config_source_paymentActions</source_model>
34
+ <sort_order>30</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ </payment_action>
38
+ <order_status translate="label">
39
+ <label>New order status</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
42
+ <sort_order>30</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
+ </order_status>
47
+ <store_name translate="label">
48
+ <label>Paidy screen store name</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>40</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ </store_name>
55
+ <api_key translate="label">
56
+ <label>API Access Key</label>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>50</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>0</show_in_store>
62
+ </api_key>
63
+ <api_secret translate="label">
64
+ <label>API Secret</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>60</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ </api_secret>
71
+ <test_mode translate="label">
72
+ <label>Test Mode</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>adminhtml/system_config_source_yesno</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
+ </test_mode>
80
+ <completed_status translate="label">
81
+ <label>Completed order status</label>
82
+ <frontend_type>select</frontend_type>
83
+ <source_model>adminhtml/system_config_source_order_status</source_model>
84
+ <sort_order>80</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </completed_status>
89
+ </fields>
90
+ </paidy>
91
+ </groups>
92
+ </payment>
93
+ </sections>
94
+ </config>
app/design/frontend/base/default/layout/mistersoft_paidy.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_onepage_index>
4
+ <reference name="head">
5
+ <block type="core/text" name="google.cdn.jquery">
6
+ <action method="setText">
7
+ <text>
8
+ <![CDATA[<script type="text/javascript" src="https://apps.paidy.com"></script>]]>
9
+ </text>
10
+ </action>
11
+ </block>
12
+ </reference>
13
+ </checkout_onepage_index>
14
+ <checkout_onepage_review>
15
+ <reference name="checkout.onepage.review.info.items.after">
16
+ <block type="paidy/checkout_paidy" name="checkout_onepage_review_info_paidy" template="mistersoft_paidy/checkout/paidy.phtml" />
17
+ </reference>
18
+ </checkout_onepage_review>
19
+
20
+ </layout>
app/design/frontend/base/default/template/mistersoft_paidy/checkout/form.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Paidy checkout hidden field
4
+ */
5
+ ?>
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
8
+ <input type="hidden" name="payment[paymentid]" id="<?php echo $_code ?>_paymentid" value="<?php echo $this->getTransactionId(); ?>">
9
+ </ul>
app/design/frontend/base/default/template/mistersoft_paidy/checkout/paidy.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Paidy checkout JS template
4
+ */
5
+
6
+ ?>
7
+ <script type="text/javascript">
8
+ var paidy = Paidy.configure({
9
+ key: "<?php echo $this->getApiKey(); ?>",
10
+ callback: function(data){
11
+ jQuery("#paidy_paymentid").val(data.payment_id);
12
+ review.save();
13
+ }
14
+ });
15
+ jQuery("#review-buttons-container .btn-checkout").prop('onclick', 'null');
16
+ jQuery("#review-buttons-container .btn-checkout").click ( function (e) {
17
+ e.preventDefault();
18
+ var data = <?php echo json_encode($this->getPaidyData()); ?>;
19
+ paidy.launch(data);
20
+ return false;
21
+ });
22
+ </script>
app/etc/modules/MisterSoft_Paidy.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * @category MisterSoft
7
+ * @package MisterSoft_Paidy
8
+ * @copyright Copyright (c) 2015 MisterSoft (http://www.mistersoft.org)
9
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <MisterSoft_Paidy>
15
+ <active>true</active>
16
+ <codePool>community</codePool>
17
+ <depends>
18
+ <Mage_Payment />
19
+ <Mage_Checkout />
20
+ </depends>
21
+ </MisterSoft_Paidy>
22
+ </modules>
23
+ </config>
app/locale/en_US/MisterSoft_Paidy.csv ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "No paidy transaction information.","No paidy transaction information."
2
+ "No authorize transaction find for capture","No authorize transaction find for capture"
3
+ "Cannot capture","Cannot capture"
4
+ "Refund Failed","Refund Failed"
5
+ "Not existing transaction type","Not existing transaction type"
6
+ "Not allowed transaction type: %s","Not allowed transaction type: %s"
7
+ "Authorization Only","Authorization Only"
8
+ "Authorization&Capture","Authorization&Capture"
9
+ "Paidy Payments","Paidy Payments"
10
+ "Enabled","Enabled"
11
+ "Title","Title"
12
+ "New order status","New order status"
13
+ "Payment Action","Payment Action"
14
+ "Paidy screen store name","Paidy screen store name"
15
+ "API Access Key","API Access Key"
16
+ "API Secret","API Secret"
17
+ "Test Mode","Test Mode"
18
+ "Completed order status","Completed order status"
app/locale/ja_JP/MisterSoft_Paidy.csv ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "No paidy transaction information.","Paidyでの取引に関する情報はありません"
2
+ "No authorize transaction find for capture","確定できる承認済み取引はありません"
3
+ "Cannot capture","確定できません"
4
+ "Refund Failed","返金に失敗しました"
5
+ "Not existing transaction type","存在しない取引形態です"
6
+ "Not allowed transaction type: %s","%sは許可されていない取引形態です"
7
+ "Authorization Only","承認のみ"
8
+ "Authorization&Capture","承認と確定"
9
+ "Paidy Payments","Paidyでの支払い"
10
+ "Enabled","有効"
11
+ "Title","タイトル"
12
+ "New order status","新規注文のステータス"
13
+ "Payment Action","支払いアクション"
14
+ "Paidy screen store name","Paidy上に表示されるストア名"
15
+ "API Access Key","APIアクセスキー"
16
+ "API Secret","APIシークレットキー"
17
+ "Test Mode","テストモード"
18
+ "Completed order status","完了した注文のステータス"
package.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MisterSoft_Paidy</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/OSL-3.0">OSL-3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Receive payments from over 100 million Japanese consumers through Paidy, a smart combination of konbini, atobarai, COD and bunkatsubarai. </summary>
10
+ <description>Features in this plugin include authorization, (partial) capture, (partial) refund, void and testing. &#xD;
11
+ &#xD;
12
+ The instant JavaScript checkout is optimized for virtually all browsers, both mobile and desktop. Consumers simply use their email address and mobile phone number to do a transaction. Paidy authorizes the transaction instantly.&#xD;
13
+ &#xD;
14
+ &#x2022; No credit card data is exchanged so no PCI DSS security is required&#xD;
15
+ &#x2022; Customers pay Paidy the next month or in installments&#xD;
16
+ &#x2022; Customers stay on your site during the entire checkout process&#xD;
17
+ &#xD;
18
+ </description>
19
+ <notes>Auth or Auth/Capture&#xD;
20
+ (Partial) capture&#xD;
21
+ (Partial) Refund&#xD;
22
+ Void&#xD;
23
+ Test flagging&#xD;
24
+ Mobile optimized&#xD;
25
+ </notes>
26
+ <authors><author><name>Sergey Balitsky</name><user>mistersoft</user><email>sergey.balitsky@gmail.com</email></author><author><name>Paidy</name><user>paidy</user><email>plugins@paidy.com</email></author></authors>
27
+ <date>2015-03-24</date>
28
+ <time>09:39:19</time>
29
+ <contents><target name="magecommunity"><dir name="MisterSoft"><dir name="Paidy"><dir name="Block"><dir name="Checkout"><file name="Form.php" hash="64264648d213dbde1df4b348dbac41c8"/><file name="Paidy.php" hash="daa70897356adbb159c988c1c690ac92"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e73d8f2fa5b43fab56398f4cf8746c49"/></dir><dir name="Model"><file name="Paidy.php" hash="e4a3214fcb720af2d6dbd9e750c3a911"/><dir name="System"><dir name="Config"><dir name="Source"><file name="PaymentActions.php" hash="a945cd161de98df7bcb694c30f7db173"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="733ae78613ec0ca89dc1dea89b5064ba"/><file name="system.xml" hash="bb29fd98851a6e3ebd504494d99bb4c5"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mistersoft_paidy.xml" hash="2f11e7ca7e79d89689ceb469b79183a7"/></dir><dir name="template"><dir name="mistersoft_paidy"><dir name="checkout"><file name="form.phtml" hash="4af8a208a5525f66bec4b3543550a611"/><file name="paidy.phtml" hash="e5e83fec48b885c8e2da1e021ae6fafb"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MisterSoft_Paidy.xml" hash="ff106a3b77036a1e4e5f3862654d360d"/></dir></target><target name="magelocale"><dir name="en_US"><file name="MisterSoft_Paidy.csv" hash="b7f6d1bb7fb1da9725441f70eab5b303"/></dir><dir name="ja_JP"><file name="MisterSoft_Paidy.csv" hash="84bfb55f5b7b26f55c151a2e70f5efe1"/></dir></target></contents>
30
+ <compatible/>
31
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php><package><name/><channel>connect.magentocommerce.com/core</channel><min/><max/></package></required></dependencies>
32
+ </package>