Skip to content

Commit

Permalink
Implemented Apple Pay
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed May 20, 2019
1 parent 46e1aa3 commit 0d58b81
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/code/community/Mollie/Mpm/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -748,17 +748,19 @@ public function getAvailableMethods($storeId, $quote = null, $resource = 'orders
if ($amount !== null && $amount['value'] > 0) {
$this->mollieMethods = $mollieApi->methods->all(
array(
"resource" => $resource,
"include" => $include,
"amount[value]" => $amount['value'],
"amount[currency]" => $amount['currency']
'resource' => $resource,
'include' => $include,
'amount[value]' => $amount['value'],
'amount[currency]' => $amount['currency'],
'includeWallets' => 'applepay',
)
);
} else {
$this->mollieMethods = $mollieApi->methods->all(
array(
"resource" => $resource,
"include" => $include
'resource' => $resource,
'include' => $include,
'includeWallets' => 'applepay',
)
);
}
Expand Down
52 changes: 52 additions & 0 deletions app/code/community/Mollie/Mpm/Model/Method/Applepay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Copyright (c) 2012-2019, Mollie B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category Mollie
* @package Mollie_Mpm
* @author Mollie B.V. (info@mollie.nl)
* @copyright Copyright (c) 2012-2019 Mollie B.V. (https://www.mollie.nl)
* @license http://www.opensource.org/licenses/bsd-license.php BSD-License 2
*/

class Mollie_Mpm_Model_Method_Applepay extends Mollie_Mpm_Model_Method_Abstract
{

const METHOD_CODE = 'mollie_applepay';
const PAYMENT_METHOD = 'Applepay';

/**
* Payment method code
*
* @var string
*/
protected $_code = self::METHOD_CODE;

/**
* @var string
*/
protected $_paymentMethod = self::PAYMENT_METHOD;

}
10 changes: 10 additions & 0 deletions app/code/community/Mollie/Mpm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@
<method/>
<payment_description>{ordernumber}</payment_description>
</mollie_przelewy24>
<mollie_applepay>
<active>1</active>
<sort_order>160</sort_order>
<title>Apple Pay</title>
<model>mpm/method_applepay</model>
<group>mollie</group>
<allowspecific>0</allowspecific>
<method/>
<payment_description>{ordernumber}</payment_description>
</mollie_applepay>
<mollie_giftcard>
<active>0</active>
<sort_order>10</sort_order>
Expand Down
121 changes: 121 additions & 0 deletions app/code/community/Mollie/Mpm/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2377,6 +2377,127 @@
</sort_order>
</fields>
</mollie_przelewy24>
<mollie_applepay translate="label" module="mpm">
<label>Mollie - Apple Pay</label>
<expanded>0</expanded>
<sort_order>240</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<fields>
<active translate="label">
<label>Enabled</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment><![CDATA[<strong>Please note:</strong> This payment method is only visible when the users device has Apple Pay enabled.]]></comment>
</active>
<title translate="label">
<label>Title</label>
<frontend_type>text</frontend_type>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<active>1</active>
</depends>
</title>
<method translate="label tooltip">
<label>Method</label>
<frontend_type>select</frontend_type>
<source_model>mpm/adminhtml_system_config_source_method</source_model>
<sort_order>3</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment><![CDATA[<strong>Payment API</strong><br>Use the Payment API Platform for the transactions.<br><br><strong>Order API</strong><br>Use the new Order API Platform and get additional insights in the orders. Read <a href="https://docs.mollie.com/orders/why-use-orders" target="_blank" >more.</a>]]></comment>
<depends>
<active>1</active>
</depends>
</method>
<payment_description translate="label">
<label>Description</label>
<frontend_type>text</frontend_type>
<sort_order>4</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<active>1</active>
<method>payment</method>
</depends>
<comment><![CDATA[The description to be used for this transaction. These variables are available:<br><br>
<strong>{ordernumber}</strong>: The order number for this transaction<br>
<strong>{storename}</strong>: The name of the store<br><br>
(Note: This only works when the method is set to Payments API)
]]></comment>
</payment_description>
<allowspecific translate="label">
<label>Payment from Applicable Countries</label>
<frontend_type>allowspecific</frontend_type>
<sort_order>5</sort_order>
<source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<active>1</active>
</depends>
</allowspecific>
<specificcountry translate="label">
<label>Payment from Specific Countries</label>
<frontend_type>multiselect</frontend_type>
<sort_order>6</sort_order>
<source_model>adminhtml/system_config_source_country</source_model>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<can_be_empty>1</can_be_empty>
<depends>
<active>1</active>
</depends>
</specificcountry>
<min_order_total translate="label">
<label>Minimum Order Total</label>
<frontend_type>text</frontend_type>
<sort_order>7</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<active>1</active>
</depends>
</min_order_total>
<max_order_total translate="label">
<label>Maximum Order Total</label>
<frontend_type>text</frontend_type>
<sort_order>8</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<active>1</active>
</depends>
</max_order_total>
<sort_order translate="label">
<label>Sort Order</label>
<frontend_type>text</frontend_type>
<sort_order>9</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<frontend_class>validate-number</frontend_class>
<depends>
<active>1</active>
</depends>
</sort_order>
</fields>
</mollie_applepay>
<mollie_giftcard translate="label" module="mpm">
<label>Mollie - Giftcard</label>
<expanded>0</expanded>
Expand Down
5 changes: 5 additions & 0 deletions app/design/frontend/base/default/layout/mollie_mpm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@
</block>
</reference>
</mpm_api_redirect>
<checkout_onepage_paymentmethod>
<reference name="checkout.onepage.payment.methods.scripts">
<block type="core/template" template="mollie/mpm/checkout/scripts/hide-apple-pay.phtml" />
</reference>
</checkout_onepage_paymentmethod>
</layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$('dt_method_mollie_applepay').hide();

if (window.ApplePaySession && window.ApplePaySession.canMakePayments()) {
$('dt_method_mollie_applepay').show();
}
1 change: 1 addition & 0 deletions modman
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ app/locale/de_DE/Mollie_Mpm.csv app/locale/de_DE/Mollie_Mpm.csv
# app/design
app/design/frontend/base/default/layout/mollie_mpm.xml app/design/frontend/base/default/layout/mollie_mpm.xml
app/design/frontend/base/default/template/mollie/mpm/payment app/design/frontend/base/default/template/mollie/mpm/payment
app/design/frontend/base/default/template/mollie/mpm/checkout app/design/frontend/base/default/template/mollie/mpm/checkout
app/design/frontend/base/default/template/mollie/mpm/loading.phtml app/design/frontend/base/default/template/mollie/mpm/loading.phtml
app/design/adminhtml/default/default/layout/mollie_mpm.xml app/design/adminhtml/default/default/layout/mollie_mpm.xml
app/design/adminhtml/default/default/template/mollie/mpm app/design/adminhtml/default/default/template/mollie/mpm
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0d58b81

Please sign in to comment.