Skip to content

Commit

Permalink
Merge pull request #121 from xendit/TPI-6671/cashalo-magento
Browse files Browse the repository at this point in the history
Implement new payment: Cashalo
  • Loading branch information
andykim authored Mar 29, 2022
2 parents ecb82eb + 07d40b6 commit 5b9bfca
Show file tree
Hide file tree
Showing 19 changed files with 254 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 3.6.0 (2022-03-22)
Features:
- Add new PH payment: Cashalo

## 3.5.0 (2022-03-08)
Improvements:
- Code refactoring
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ To activate this feature, you need to follow this additional steps:
- PayLater
- Kredivo
- BillEase (PH)
- Cashalo (PH)
- Direct Debit
- BRI
- BPI (PH)
Expand Down
2 changes: 1 addition & 1 deletion Xendit/M2Invoice/Helper/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function getHeaders($isPublicRequest, $preferredMethod = null, $customHe
'Content-Type' => 'application/json',
'x-plugin-name' => 'MAGENTO2',
'user-agent' => 'Magento 2 Module',
'x-plugin-version' => '3.5.0'
'x-plugin-version' => '3.6.0'
];

if ($preferredMethod !== null) {
Expand Down
1 change: 1 addition & 0 deletions Xendit/M2Invoice/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ public function xenditPaymentMethod($payment)
"dp_palawan" => "dp_palawan",
"dp_mlhuillier" => "dp_mlhuillier",
"dp_ecpay_loan" => "dp_ecpay_loan",
"cashalo" => "cashalo",
];

$response = false;
Expand Down
1 change: 1 addition & 0 deletions Xendit/M2Invoice/Model/Adminhtml/Source/ChosenMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function toOptionArray($isMultiselect = false)
['value' => 'dp_palawan', 'label' => __('Palawan Express Pera Padala')],
['value' => 'dp_mlhuillier', 'label' => __('M Lhuillier')],
['value' => 'dp_ecpay_loan', 'label' => __('ECPay Loans')],
['value' => 'cashalo', 'label' => __('Cashalo')],
];

if (!$isMultiselect) {
Expand Down
27 changes: 27 additions & 0 deletions Xendit/M2Invoice/Model/Payment/Cashalo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Xendit\M2Invoice\Model\Payment;

use Magento\Quote\Api\Data\CartInterface;

/**
* Class Cashalo
* @package Xendit\M2Invoice\Model\Payment
*/
class Cashalo extends AbstractInvoice
{
/**
* Payment Method feature
*
* @var bool
*/
protected $_isInitializeNeeded = true;

/**
* Payment code
*
* @var string
*/
protected $_code = 'cashalo';
protected $methodCode = 'CASHALO';
}
7 changes: 7 additions & 0 deletions Xendit/M2Invoice/Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ public function getConfig()
'description' => $this->xenditHelper->getPaymentDescription('bsiva'),
'image' => $this->xenditHelper->getPaymentImage('bsiva')
],
'cashalo' => [
'title' => $this->xenditHelper->getPaymentTitle("cashalo"),
'min_order_amount' => $this->xenditHelper->getPaymentMinOrderAmount("cashalo"),
'max_order_amount' => $this->xenditHelper->getPaymentMaxOrderAmount("cashalo"),
'description' => $this->xenditHelper->getPaymentDescription("cashalo"),
'image' => $this->xenditHelper->getPaymentImage('cashalo')
],
]
];

Expand Down
2 changes: 1 addition & 1 deletion Xendit/M2Invoice/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "xendit/m2invoice",
"description": "Xendit Payment Gateway Module",
"type": "magento2-module",
"version": "3.5.0",
"version": "3.6.0",
"license": [
"GPL-3.0"
],
Expand Down
29 changes: 29 additions & 0 deletions Xendit/M2Invoice/etc/adminhtml/paylater/cashalo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
<group id="cashalo" translate="label" type="text" sortOrder="160" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Cashalo</label>
<field id="active" translate="label comment" sortOrder="1" type="select" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/cashalo/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Title</label>
<config_path>payment/cashalo/title</config_path>
</field>
<field id="description" translate="label" type="textarea" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Description</label>
<config_path>payment/cashalo/description</config_path>
</field>
<field id="min_order_total" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Minimum Order Total</label>
<frontend_class>validate-zero-or-greater</frontend_class>
<config_path>payment/cashalo/min_order_total</config_path>
</field>
<field id="max_order_total" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Maximum Order Total</label>
<frontend_class>validate-zero-or-greater</frontend_class>
<config_path>payment/cashalo/max_order_total</config_path>
</field>
</group>
</include>
11 changes: 6 additions & 5 deletions Xendit/M2Invoice/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,39 @@
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="xendit_env" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="xendit_env" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Payment Mode</label>
<source_model>Xendit\M2Invoice\Model\Adminhtml\Source\EnvRadioBtn</source_model>
<comment>
Choose live to perform real transaction
</comment>
<attribute type="shared">1</attribute>
</field>
<field id="test_public_key" translate="label" type="obscure" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="test_public_key" translate="label" type="obscure" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test - Public Key</label>
<comment>
Public API key provided by Xendit Dashboard
</comment>
<attribute type="shared">1</attribute>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="test_private_key" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="test_private_key" translate="label" type="obscure" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test - Private Key</label>
<comment>
Secret API key provided by Xendit Dashboard
</comment>
<attribute type="shared">1</attribute>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="public_key" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="public_key" translate="label" type="obscure" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Public Key</label>
<comment>
Public API key provided by Xendit Dashboard
</comment>
<attribute type="shared">1</attribute>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="private_key" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<field id="private_key" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Private Key</label>
<comment>
Secret API key provided by Xendit Dashboard
Expand Down Expand Up @@ -219,6 +219,7 @@
<attribute type="expanded">0</attribute>
<include path="Xendit_M2Invoice::paylater/kredivo.xml"/>
<include path="Xendit_M2Invoice::paylater/billease.xml"/>
<include path="Xendit_M2Invoice::paylater/cashalo.xml"/>
</group>
</group>

Expand Down
32 changes: 23 additions & 9 deletions Xendit/M2Invoice/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,20 @@
<sort_order>20</sort_order>
<currency>PHP</currency>
</billease>
<cashalo>
<active>1</active>
<payment_action>initialize</payment_action>
<model>Xendit\M2Invoice\Model\Payment\Cashalo</model>
<title>Cashalo</title>
<description>Pay for orders using Cashalo via Xendit</description>
<min_order_total>1500</min_order_total>
<max_order_total>4500</max_order_total>
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>21</sort_order>
<currency>PHP</currency>
</cashalo>
<cebuana>
<active>1</active>
<payment_action>initialize</payment_action>
Expand All @@ -312,7 +326,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>21</sort_order>
<sort_order>22</sort_order>
<currency>PHP</currency>
</cebuana>
<dd_bpi>
Expand All @@ -326,7 +340,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>22</sort_order>
<sort_order>23</sort_order>
<currency>PHP</currency>
</dd_bpi>
<dd_ubp>
Expand All @@ -340,7 +354,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>23</sort_order>
<sort_order>24</sort_order>
<currency>PHP</currency>
</dd_ubp>
<dp_ecpay_loan>
Expand All @@ -354,7 +368,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>24</sort_order>
<sort_order>25</sort_order>
<currency>PHP</currency>
</dp_ecpay_loan>
<gcash>
Expand All @@ -368,7 +382,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>25</sort_order>
<sort_order>26</sort_order>
<currency>PHP</currency>
</gcash>
<grabpay>
Expand All @@ -382,7 +396,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>26</sort_order>
<sort_order>27</sort_order>
<currency>PHP</currency>
</grabpay>
<dp_mlhuillier>
Expand All @@ -396,7 +410,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>27</sort_order>
<sort_order>28</sort_order>
<currency>PHP</currency>
</dp_mlhuillier>
<dp_palawan>
Expand All @@ -410,7 +424,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>28</sort_order>
<sort_order>29</sort_order>
<currency>PHP</currency>
</dp_palawan>
<paymaya>
Expand All @@ -424,7 +438,7 @@
<is_gateway>1</is_gateway>
<can_initialize>1</can_initialize>
<can_use_checkout>1</can_use_checkout>
<sort_order>29</sort_order>
<sort_order>30</sort_order>
<currency>PHP</currency>
</paymaya>
</payment>
Expand Down
2 changes: 1 addition & 1 deletion Xendit/M2Invoice/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Xendit_M2Invoice" setup_version="3.5.0" active="true"></module>
<module name="Xendit_M2Invoice" setup_version="3.6.0" active="true"></module>
</config>
3 changes: 3 additions & 0 deletions Xendit/M2Invoice/etc/payment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@ https://github.com/magento/magento2/blob/2.2.0-rc2.1/app/code/Magento/Multishipp
<method name='dp_ecpay_loan'>
<allow_multiple_address>1</allow_multiple_address>
</method>
<method name='cashalo'>
<allow_multiple_address>1</allow_multiple_address>
</method>
</methods>
</payment>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<item name="dp_ecpay_loan" xsi:type="string">Xendit_M2Invoice::multishipping/dp_ecpay_loan.phtml</item>
<item name="bjbva" xsi:type="string">Xendit_M2Invoice::multishipping/bjbva.phtml</item>
<item name="bsiva" xsi:type="string">Xendit_M2Invoice::multishipping/bsiva.phtml</item>
<item name="cashalo" xsi:type="string">Xendit_M2Invoice::multishipping/cashalo.phtml</item>
</argument>
</arguments>
</referenceBlock>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
?>
<script>
require([
'uiLayout',
'jquery'
], function (layout, $) {
$(function () {
var paymentMethodData = {
method: 'cashalo'
};
layout([
{
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/multishipping/cashalo',
name: 'payment_method_cashalo',
method: paymentMethodData.method,
item: paymentMethodData
}
]);

if(window.checkoutConfig.payment[paymentMethodData.method].image != ""){
$("label[for=p_method_"+paymentMethodData.method+"]")
.prepend('<img class="xendit-payment-icon" src="'+window.checkoutConfig.payment[paymentMethodData.method].image+'" />');
}

$('body').trigger('contentUpdated');
})
})
</script>
<!-- ko template: getTemplate() --><!-- /ko -->
10 changes: 10 additions & 0 deletions Xendit/M2Invoice/view/frontend/web/images/methods/cashalo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ define(
type: 'bsiva',
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/bsiva'
},
{
type: 'cashalo',
component: 'Xendit_M2Invoice/js/view/payment/method-renderer/cashalo'
},
);
return Component.extend({});
}
Expand Down
Loading

0 comments on commit 5b9bfca

Please sign in to comment.