Skip to content

Commit

Permalink
Merge branch 'feature/klarnapaynow' into release-week-8
Browse files Browse the repository at this point in the history
  • Loading branch information
michielgerritsen committed Feb 23, 2023
2 parents 1a54fae + f20fbb7 commit 67b0553
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/code/community/Mollie/Mpm/Helper/PaymentFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public function methodSupportsPaymentFee($methodCode)
{
$supportedMethods = array(
'mollie_klarnapaylater',
'mollie_klarnapaynow',
'mollie_klarnasliceit',
);

Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Mollie/Mpm/Model/Client/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ private function createPartialInvoice(Mage_Sales_Model_Order_Shipment $shipment,
$payment = $order->getPayment();

if (
!in_array($payment->getMethod(), array('mollie_klarnapaylater', 'mollie_klarnasliceit')) ||
!in_array($payment->getMethod(), array('mollie_klarnapaylater', 'mollie_klarnapaynow', 'mollie_klarnasliceit')) ||
$this->mollieHelper->getInvoiceMoment($order) != 'shipment'
) {
return null;
Expand Down
52 changes: 52 additions & 0 deletions app/code/community/Mollie/Mpm/Model/Method/Klarnapaynow.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_Klarnapaynow extends Mollie_Mpm_Model_Method_Abstract
{

const METHOD_CODE = 'mollie_klarnapaynow';
const PAYMENT_METHOD = 'Klarnapaynow';

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

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function methodSupportsPaymentFeeProvider()
{
return [
['mollie_klarnapaylater', true],
['mollie_klarnapaynow', true],
['mollie_klarnasliceit', true],
['doesnotexists', false],
];
Expand Down
20 changes: 15 additions & 5 deletions app/code/community/Mollie/Mpm/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,19 @@
<method>order</method>
<invoice_moment>shipment</invoice_moment>
</mollie_klarnapaylater>
<mollie_klarnasliceit>
<mollie_klarnapaynow>
<active>1</active>
<sort_order>150</sort_order>
<title>Klarna Pay Now</title>
<model>mpm/method_klarnapaynow</model>
<group>mollie</group>
<allowspecific>0</allowspecific>
<method>order</method>
<invoice_moment>shipment</invoice_moment>
</mollie_klarnapaynow>
<mollie_klarnasliceit>
<active>1</active>
<sort_order>160</sort_order>
<title>Klarna Slice</title>
<model>mpm/method_klarnasliceit</model>
<group>mollie</group>
Expand All @@ -498,7 +508,7 @@
</mollie_klarnasliceit>
<mollie_paymentlink>
<active>1</active>
<sort_order>160</sort_order>
<sort_order>170</sort_order>
<title>Payment Link / Admin Payment</title>
<model>mpm/method_paymentlink</model>
<group>mollie</group>
Expand All @@ -509,7 +519,7 @@
</mollie_paymentlink>
<mollie_przelewy24>
<active>1</active>
<sort_order>170</sort_order>
<sort_order>180</sort_order>
<title>Przelewy24</title>
<model>mpm/method_przelewy24</model>
<group>mollie</group>
Expand All @@ -519,7 +529,7 @@
</mollie_przelewy24>
<mollie_applepay>
<active>1</active>
<sort_order>180</sort_order>
<sort_order>190</sort_order>
<title>Apple Pay</title>
<model>mpm/method_applepay</model>
<group>mollie</group>
Expand All @@ -529,7 +539,7 @@
</mollie_applepay>
<mollie_mybank>
<active>1</active>
<sort_order>190</sort_order>
<sort_order>200</sort_order>
<title>MyBank</title>
<model>mpm/method_mybank</model>
<group>mollie</group>
Expand Down
143 changes: 137 additions & 6 deletions app/code/community/Mollie/Mpm/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2149,10 +2149,141 @@
</model>
</fields>
</mollie_klarnapaylater>
<mollie_klarnapaynow translate="label" module="mpm">
<label>Mollie - Klarna Pay Now</label>
<expanded>0</expanded>
<sort_order>220</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>
</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>
<allowspecific translate="label">
<label>Payment from Applicable Countries</label>
<frontend_type>allowspecific</frontend_type>
<sort_order>50</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>51</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>98</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>99</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>
<payment_surcharge>
<label>Klarna Payment Surcharge</label>
<frontend_type>text</frontend_type>
<sort_order>100</sort_order>
<comment><![CDATA[Enter the extra costs for a Klarna Pay Now payment with a maximum of € 1.95]]></comment>
<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>
<backend_model>mpm/adminhtml_system_config_backend_surchargeValidation</backend_model>
</payment_surcharge>
<payment_surcharge_tax_class>
<label>Klarna Payment Surcharge Tax Class</label>
<frontend_type>text</frontend_type>
<sort_order>101</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_shipping_taxclass</source_model>
<depends>
<active>1</active>
</depends>
</payment_surcharge_tax_class>
<invoice_moment translate="label comment">
<label>When to create the invoice?</label>
<frontend_type>select</frontend_type>
<sort_order>102</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<source_model>mpm/adminhtml_system_config_source_invoiceMoment</source_model>
<comment><![CDATA[When do we create the invoice?<br><strong>On Authorize and set status Paid before shipment:</strong><br>Create a full invoice with the status Paid after the order is authorized and not shipped yet.<br><br><strong>On Authorize and set payment status Paid after shipment:</strong><br>Create a full invoice with the payment status Pending after the order is authorized and set payment status to Paid after a shipment.<br><br><strong>On Shipment (recommended):</strong><br>Create a (partial) invoice for shipped item(s).</span>]]></comment>
<depends>
<active>1</active>
</depends>
</invoice_moment>
<sort_order translate="label">
<label>Sort Order</label>
<frontend_type>text</frontend_type>
<sort_order>103</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>
<model>
</model>
</fields>
</mollie_klarnapaynow>
<mollie_klarnasliceit translate="label" module="mpm">
<label>Mollie - Klarna Slice</label>
<expanded>0</expanded>
<sort_order>220</sort_order>
<sort_order>230</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down Expand Up @@ -2281,7 +2412,7 @@
<mollie_paymentlink translate="label" module="mpm">
<label>Mollie - Payment Link / Admin Payment</label>
<expanded>0</expanded>
<sort_order>230</sort_order>
<sort_order>240</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down Expand Up @@ -2396,7 +2527,7 @@
<mollie_przelewy24 translate="label" module="mpm">
<label>Mollie - Przelewy24</label>
<expanded>0</expanded>
<sort_order>240</sort_order>
<sort_order>250</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down Expand Up @@ -2518,7 +2649,7 @@
<mollie_applepay translate="label" module="mpm">
<label>Mollie - Apple Pay</label>
<expanded>0</expanded>
<sort_order>250</sort_order>
<sort_order>260</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down Expand Up @@ -2641,7 +2772,7 @@
<mollie_mybank translate="label" module="mpm">
<label>Mollie - MyBank</label>
<expanded>0</expanded>
<sort_order>260</sort_order>
<sort_order>270</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down Expand Up @@ -2763,7 +2894,7 @@
<mollie_giftcard translate="label" module="mpm">
<label>Mollie - Giftcard</label>
<expanded>0</expanded>
<sort_order>270</sort_order>
<sort_order>280</sort_order>
<frontend_type>text</frontend_type>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
Expand Down

0 comments on commit 67b0553

Please sign in to comment.