Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIPRES-352: Billie payment method setup #17

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/Builder/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,6 @@ protected function getAccountSettingsSection($isApiKeyProvided)
'customLogoUrl' => $this->creditCardLogoProvider->getLogoPathUri() . "?{$dateStamp}",
'customLogoExist' => $this->creditCardLogoProvider->logoExists(),
'voucherCategory' => $this->configurationAdapter->get(Config::MOLLIE_VOUCHER_CATEGORY),
'klarnaPayments' => Config::KLARNA_PAYMENTS,
'klarnaStatuses' => [Config::MOLLIE_STATUS_KLARNA_AUTHORIZED, Config::MOLLIE_STATUS_KLARNA_SHIPPED],
'applePayDirectProduct' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_PRODUCT),
'applePayDirectCart' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_CART),
'applePayDirectStyle' => (int) $this->configurationAdapter->get(Config::MOLLIE_APPLE_PAY_DIRECT_STYLE),
Expand Down Expand Up @@ -481,22 +479,22 @@ protected function getAdvancedSettingsSection()

$input[] = [
'type' => 'select',
'label' => $this->module->l('Select when to create the Klarna invoice', self::FILE_NAME),
'label' => $this->module->l('Select when to create the Order invoice', self::FILE_NAME),
'desc' => $this->module->display($this->module->getPathUri(), 'views/templates/admin/invoice_description.tpl'),
'tab' => $advancedSettings,
'name' => Config::MOLLIE_KLARNA_INVOICE_ON,
'name' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS,
'options' => [
'query' => [
[
'id' => Config::MOLLIE_STATUS_DEFAULT,
'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT,
'name' => $this->module->l('Default', self::FILE_NAME),
],
[
'id' => Config::MOLLIE_STATUS_KLARNA_AUTHORIZED,
'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED,
'name' => $this->module->l('Authorised', self::FILE_NAME),
],
[
'id' => Config::MOLLIE_STATUS_KLARNA_SHIPPED,
'id' => Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED,
'name' => $this->module->l('Shipped', self::FILE_NAME),
],
],
Expand Down
26 changes: 15 additions & 11 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ class Config
const MOLLIE_STATUS_INITIATED = 'MOLLIE_STATUS_INITIATED';
const MOLLIE_STATUS_PARTIALLY_SHIPPED = 'MOLLIE_PARTIALLY_SHIPPED';
const MOLLIE_STATUS_ORDER_COMPLETED = 'MOLLIE_STATUS_ORDER_COMPLETED';
const MOLLIE_STATUS_DEFAULT = 'MOLLIE_STATUS_DEFAULT';
const MOLLIE_STATUS_KLARNA_AUTHORIZED = 'MOLLIE_STATUS_KLARNA_AUTHORIZED';
const MOLLIE_STATUS_KLARNA_SHIPPED = 'MOLLIE_STATUS_KLARNA_SHIPPED';
const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT';
const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED';
const MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED = 'MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED';
const MOLLIE_STATUS_CHARGEBACK = 'MOLLIE_STATUS_CHARGEBACK';
const MOLLIE_KLARNA_INVOICE_ON = 'MOLLIE_KLARNA_INVOICE_ON';
const MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS = 'MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS';
const MOLLIE_APPLE_PAY_DIRECT_PRODUCT = 'MOLLIE_APPLE_PAY_DIRECT_PRODUCT';
const MOLLIE_APPLE_PAY_DIRECT_CART = 'MOLLIE_APPLE_PAY_DIRECT_CART';

Expand Down Expand Up @@ -262,16 +262,18 @@ class Config
const RESTORE_CART_BACKTRACE_MEMORIZATION_SERVICE = 'memo';
const RESTORE_CART_BACKTRACE_RETURN_CONTROLLER = 'return';

const KLARNA_PAYMENTS = [
const AUTHORIZABLE_PAYMENTS = [
PaymentMethod::KLARNA_PAY_LATER,
PaymentMethod::KLARNA_SLICE_IT,
PaymentMethod::KLARNA_PAY_NOW,
self::MOLLIE_PAYMENT_METHOD_BILLIE,
];

const ORDER_API_ONLY_METHODS = [
PaymentMethod::KLARNA_PAY_LATER,
PaymentMethod::KLARNA_SLICE_IT,
PaymentMethod::KLARNA_PAY_NOW,
self::MOLLIE_PAYMENT_METHOD_BILLIE,
self::MOLLIE_VOUCHER_METHOD_ID,
self::MOLLIE_in3_METHOD_ID,
];
Expand Down Expand Up @@ -309,6 +311,7 @@ class Config
'voucher' => 'Voucher',
'klarnapaynow' => 'Klarna Pay now.',
'in3' => 'in3',
'billie' => 'Billie',
];

const MOLLIE_BUTTON_ORDER_TOTAL_REFRESH = 'MOLLIE_BUTTON_ORDER_TOTAL_REFRESH';
Expand All @@ -318,14 +321,15 @@ class Config

public static function getStatuses()
{
$isKlarnaDefault = Configuration::get(Config::MOLLIE_KLARNA_INVOICE_ON) === Config::MOLLIE_STATUS_DEFAULT;
$isAuthorizablePaymentInvoiceOnStatusDefault =
Configuration::get(Config::MOLLIE_AUTHORIZABLE_PAYMENT_INVOICE_ON_STATUS) === Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_DEFAULT;

return [
self::MOLLIE_AWAITING_PAYMENT => Configuration::get(self::MOLLIE_STATUS_AWAITING),
PaymentStatus::STATUS_PAID => Configuration::get(self::MOLLIE_STATUS_PAID),
OrderStatus::STATUS_COMPLETED => Configuration::get(self::MOLLIE_STATUS_COMPLETED),
PaymentStatus::STATUS_AUTHORIZED => $isKlarnaDefault ?
Configuration::get(self::MOLLIE_STATUS_PAID) : Configuration::get(self::MOLLIE_STATUS_KLARNA_AUTHORIZED),
PaymentStatus::STATUS_AUTHORIZED => $isAuthorizablePaymentInvoiceOnStatusDefault ?
Configuration::get(self::MOLLIE_STATUS_PAID) : Configuration::get(self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED),
PaymentStatus::STATUS_CANCELED => Configuration::get(self::MOLLIE_STATUS_CANCELED),
PaymentStatus::STATUS_EXPIRED => Configuration::get(self::MOLLIE_STATUS_EXPIRED),
RefundStatus::STATUS_REFUNDED => Configuration::get(self::MOLLIE_STATUS_REFUNDED),
Expand All @@ -338,7 +342,7 @@ public static function getStatuses()
self::STATUS_PAID_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK_PAID'),
self::STATUS_PENDING_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK_UNPAID'),
self::STATUS_ON_BACKORDER => Configuration::get('PS_OS_OUTOFSTOCK'),
self::MOLLIE_STATUS_KLARNA_SHIPPED => Configuration::get(self::MOLLIE_STATUS_KLARNA_SHIPPED),
self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED => Configuration::get(self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED),
self::MOLLIE_CHARGEBACK => Configuration::get(self::MOLLIE_STATUS_CHARGEBACK),
];
}
Expand All @@ -360,8 +364,8 @@ public static function getMollieOrderStatuses()
self::MOLLIE_STATUS_PARTIAL_REFUND,
self::MOLLIE_STATUS_AWAITING,
self::MOLLIE_STATUS_ORDER_COMPLETED,
self::MOLLIE_STATUS_KLARNA_AUTHORIZED,
self::MOLLIE_STATUS_KLARNA_SHIPPED,
self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED,
self::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED,
self::MOLLIE_STATUS_CHARGEBACK,
];
}
Expand Down
5 changes: 3 additions & 2 deletions src/Handler/Certificate/ApplePayDirectCertificateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Mollie\Handler\Certificate;

use Mollie;
use Mollie\Factory\ModuleFactory;
use Mollie\Handler\Certificate\Exception\ApplePayDirectCertificateCreation;
use Mollie\Utility\FileUtility;

Expand All @@ -30,9 +31,9 @@ class ApplePayDirectCertificateHandler implements CertificateHandlerInterface
private $mollie;
private $serverRoot;

public function __construct(Mollie $mollie)
public function __construct(ModuleFactory $moduleFactory)
{
$this->mollie = $mollie;
$this->mollie = $moduleFactory->getModule();
$this->serverRoot = $_SERVER['DOCUMENT_ROOT'];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Order/OrderCreationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public function __construct(
*
* @throws \Exception
*/
public function createOrder($apiPayment, int $cartId, bool $isKlarnaOrder = false): int
public function createOrder($apiPayment, int $cartId, bool $isAuthorizablePayment = false): int
{
$orderStatus = $isKlarnaOrder ?
$orderStatus = $isAuthorizablePayment ?
(int) Config::getStatuses()[PaymentStatus::STATUS_AUTHORIZED] :
(int) Config::getStatuses()[PaymentStatus::STATUS_PAID];

Expand Down
10 changes: 5 additions & 5 deletions src/Install/OrderStateInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
/**
* @throws CouldNotInstallModule
*/
public function install()
public function install(): bool
{
$this->installOrderState(
Config::MOLLIE_STATUS_PARTIAL_REFUND,
Expand Down Expand Up @@ -69,9 +69,9 @@ public function install()
);

$this->installOrderState(
Config::MOLLIE_STATUS_KLARNA_AUTHORIZED,
Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_AUTHORIZED,
new OrderStateData(
'Klarna payment authorized',
'Order payment authorized',
'#8A2BE2',
true,
true,
Expand All @@ -85,9 +85,9 @@ public function install()
);

$this->installOrderState(
Config::MOLLIE_STATUS_KLARNA_SHIPPED,
Config::MOLLIE_AUTHORIZABLE_PAYMENT_STATUS_SHIPPED,
new OrderStateData(
'Klarna payment shipped',
'Order payment shipped',
'#8A2BE2',
true,
true,
Expand Down
5 changes: 3 additions & 2 deletions src/Presenter/OrderListActionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Mollie\Presenter;

use Mollie;
use Mollie\Factory\ModuleFactory;
use Smarty_Data;

class OrderListActionBuilder
Expand All @@ -23,9 +24,9 @@ class OrderListActionBuilder
*/
private $mollie;

public function __construct(Mollie $mollie)
public function __construct(ModuleFactory $moduleFactory)
{
$this->mollie = $mollie;
$this->mollie = $moduleFactory->getModule();
}

public function buildOrderPaymentResendButton(Smarty_Data $smarty, $orderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Mollie;
use Mollie\Adapter\Context;
use Mollie\Api\Types\PaymentMethod;
use Mollie\Factory\ModuleFactory;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
Expand Down Expand Up @@ -79,14 +80,14 @@ class BancontactPaymentOptionProvider implements PaymentOptionProviderInterface
private $orderTotalProvider;

public function __construct(
Mollie $module,
ModuleFactory $moduleFactory,
Context $context,
CreditCardLogoProvider $creditCardLogoProvider,
PaymentFeeProviderInterface $paymentFeeProvider,
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider
) {
$this->module = $module;
$this->module = $moduleFactory->getModule();
$this->context = $context;
$this->creditCardLogoProvider = $creditCardLogoProvider;
$this->paymentFeeProvider = $paymentFeeProvider;
Expand Down
5 changes: 3 additions & 2 deletions src/Provider/PaymentOption/BasePaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

use Mollie;
use Mollie\Adapter\Context;
use Mollie\Factory\ModuleFactory;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
Expand Down Expand Up @@ -78,14 +79,14 @@ class BasePaymentOptionProvider implements PaymentOptionProviderInterface
private $orderTotalProvider;

public function __construct(
Mollie $module,
ModuleFactory $moduleFactory,
Context $context,
CreditCardLogoProvider $creditCardLogoProvider,
PaymentFeeProviderInterface $paymentFeeProvider,
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider
) {
$this->module = $module;
$this->module = $moduleFactory->getModule();
$this->context = $context;
$this->creditCardLogoProvider = $creditCardLogoProvider;
$this->paymentFeeProvider = $paymentFeeProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\Context;
use Mollie\Config\Config;
use Mollie\Factory\ModuleFactory;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
Expand Down Expand Up @@ -92,7 +93,7 @@ class CreditCardPaymentOptionProvider implements PaymentOptionProviderInterface
private $configurationAdapter;

public function __construct(
Mollie $module,
ModuleFactory $moduleFactory,
Context $context,
CreditCardLogoProvider $creditCardLogoProvider,
OrderTotalProviderInterface $orderTotalProvider,
Expand All @@ -101,7 +102,7 @@ public function __construct(
MolCustomerRepository $customerRepository,
ConfigurationAdapter $configurationAdapter
) {
$this->module = $module;
$this->module = $moduleFactory->getModule();
$this->context = $context;
$this->creditCardLogoProvider = $creditCardLogoProvider;
$this->orderTotalProvider = $orderTotalProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use Mollie\Adapter\ConfigurationAdapter;
use Mollie\Adapter\Context;
use Mollie\Config\Config;
use Mollie\Factory\ModuleFactory;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
Expand Down Expand Up @@ -92,7 +93,7 @@ class CreditCardSingleClickPaymentOptionProvider implements PaymentOptionProvide
private $configurationAdapter;

public function __construct(
Mollie $module,
ModuleFactory $moduleFactory,
Context $context,
CreditCardLogoProvider $creditCardLogoProvider,
OrderTotalProviderInterface $orderTotalProvider,
Expand All @@ -101,7 +102,7 @@ public function __construct(
MolCustomerRepository $customerRepository,
ConfigurationAdapter $configurationAdapter
) {
$this->module = $module;
$this->module = $moduleFactory->getModule();
$this->context = $context;
$this->creditCardLogoProvider = $creditCardLogoProvider;
$this->orderTotalProvider = $orderTotalProvider;
Expand Down
5 changes: 3 additions & 2 deletions src/Provider/PaymentOption/IdealPaymentOptionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Mollie;
use Mollie\Adapter\Context;
use Mollie\Builder\Content\PaymentOption\IdealDropdownInfoBlock;
use Mollie\Factory\ModuleFactory;
use Mollie\Provider\CreditCardLogoProvider;
use Mollie\Provider\OrderTotal\OrderTotalProviderInterface;
use Mollie\Provider\PaymentFeeProviderInterface;
Expand Down Expand Up @@ -90,7 +91,7 @@ class IdealPaymentOptionProvider implements PaymentOptionProviderInterface
private $orderTotalProvider;

public function __construct(
Mollie $module,
ModuleFactory $moduleFactory,
Context $context,
CreditCardLogoProvider $creditCardLogoProvider,
PaymentFeeProviderInterface $paymentFeeProvider,
Expand All @@ -99,7 +100,7 @@ public function __construct(
LanguageService $languageService,
OrderTotalProviderInterface $orderTotalProvider
) {
$this->module = $module;
$this->module = $moduleFactory->getModule();
$this->context = $context;
$this->creditCardLogoProvider = $creditCardLogoProvider;
$this->paymentFeeProvider = $paymentFeeProvider;
Expand Down
Loading