Skip to content

Commit 1bf21d1

Browse files
authored
Merge pull request #24 from logeecom/master
PISYL-247: PISYL-245: Add Riverty and trusty payment methods
2 parents e11165b + 65b5a3c commit 1bf21d1

File tree

13 files changed

+166
-9
lines changed

13 files changed

+166
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": "^7.4 || ^8.0",
88
"sylius/sylius": "~1.9.0 || ~1.10.0 || ~1.11.0 || ~1.12.0",
99
"symfony/messenger": "^4.4 || ^5.2 || ^6.0",
10-
"mollie/mollie-api-php": "^v2.65.0",
10+
"mollie/mollie-api-php": "^v2.71.0",
1111
"sylius/refund-plugin": "^1.0",
1212
"sylius/admin-order-creation-plugin": "^0.12 || ^0.13 || v0.14",
1313
"ext-json": "*",

src/Action/CaptureAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public function execute($request): void
163163
));
164164
}
165165

166-
$this->gateway->execute(new CreatePayment($details));
166+
$this->gateway->execute(new CreateOrder($details));
167167
}
168168

169169
if (isset($details['metadata']['methodType']) && Options::ORDER_API === $details['metadata']['methodType']) {

src/Helper/ConvertOrder.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace SyliusMolliePlugin\Helper;
77

8+
use Mollie\Api\Types\PaymentMethod;
89
use Sylius\Component\Addressing\Model\ZoneInterface;
910
use Sylius\Component\Core\Model\Scope;
1011
use Sylius\Component\Core\Model\ShippingMethodInterface;
@@ -84,7 +85,7 @@ public function convert(
8485
$details['amount']['value'] = $amount;
8586
$details['orderNumber'] = (string) $order->getNumber();
8687
$details['shippingAddress'] = $this->createShippingAddress($customer);
87-
$details['billingAddress'] = $this->createBillingAddress($customer);
88+
$details['billingAddress'] = $this->createBillingAddress($customer, $method->getMethodId());
8889
$details['lines'] = $this->createLines($divisor, $method);
8990
$details['lines'] = array_merge($details['lines'], $this->createShippingFee($divisor));
9091

@@ -109,22 +110,28 @@ private function createShippingAddress(CustomerInterface $customer): array
109110
];
110111
}
111112

112-
private function createBillingAddress(CustomerInterface $customer): array
113+
private function createBillingAddress(CustomerInterface $customer, string $methodId): array
113114
{
114115
$billingAddress = $this->order->getBillingAddress();
115116

116117
Assert::notNull($billingAddress);
117118

118-
return [
119+
$address = [
119120
'streetAndNumber' => $billingAddress->getStreet(),
120121
'postalCode' => $billingAddress->getPostcode(),
121122
'city' => $billingAddress->getCity(),
122123
'country' => $billingAddress->getCountryCode(),
123124
'givenName' => $billingAddress->getFirstName(),
124125
'familyName' => $billingAddress->getLastName(),
125126
'organizationName' => $billingAddress->getCompany(),
126-
'email' => $customer->getEmail(),
127+
'email' => $customer->getEmail()
127128
];
129+
130+
if ($methodId === PaymentMethod::BANCOMATPAY && $billingAddress->getPhoneNumber()) {
131+
$address['phone'] = $billingAddress->getPhoneNumber();
132+
}
133+
134+
return $address;
128135
}
129136

130137
private function createLines(int $divisor, MollieGatewayConfigInterface $method): array

src/Migrations/Version20240301074755.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getDescription(): string
2222

2323
public function up(Schema $schema): void
2424
{
25-
$this->addSql('ALTER TABLE ' . self::TABLE_NAME . ' ADD qr_code_enabled TINYINT(1) NOT NULL');
25+
$this->addSql('ALTER TABLE ' . self::TABLE_NAME . ' ADD qr_code_enabled TINYINT(1) DEFAULT NULL');
2626
}
2727

2828
public function down(Schema $schema): void
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Migrations;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
use Doctrine\Migrations\AbstractMigration;
7+
8+
class Version20240627164350 extends AbstractMigration
9+
{
10+
//table name
11+
private const TABLE_NAME = 'mollie_configuration';
12+
13+
public function getDescription(): string
14+
{
15+
return '';
16+
}
17+
18+
/**
19+
* Delete giropay payment method from mollie configuration table
20+
*
21+
* @param Schema $schema
22+
* @return void
23+
*/
24+
public function up(Schema $schema): void
25+
{
26+
$this->addSql('DELETE FROM ' . self::TABLE_NAME . ' WHERE method_id = \'giropay\'');
27+
}
28+
29+
public function down(Schema $schema): void
30+
{
31+
}
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Migrations;
4+
5+
use Doctrine\DBAL\Schema\Schema;
6+
use Doctrine\Migrations\AbstractMigration;
7+
8+
class Version20240716134351 extends AbstractMigration
9+
{
10+
private const TABLE_NAME = 'mollie_configuration';
11+
12+
/**
13+
* @return string
14+
*/
15+
public function getDescription(): string
16+
{
17+
return 'Change qr_code_enabled column to allow NULL values and set default to NULL';
18+
}
19+
20+
/**
21+
* @param Schema $schema
22+
*
23+
* @return void
24+
*/
25+
public function up(Schema $schema): void
26+
{
27+
$this->addSql('ALTER TABLE ' . self::TABLE_NAME . ' MODIFY qr_code_enabled TINYINT(1) DEFAULT NULL');
28+
}
29+
30+
/**
31+
* @param Schema $schema
32+
*
33+
* @return void
34+
*/
35+
public function down(Schema $schema): void
36+
{
37+
$this->addSql('ALTER TABLE ' . self::TABLE_NAME . ' MODIFY qr_code_enabled TINYINT(1) NOT NULL');
38+
}
39+
}

src/Payments/Methods/Bancomatpay.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Payments\Methods;
4+
5+
use Mollie\Api\Types\PaymentMethod;
6+
7+
final class Bancomatpay extends AbstractMethod
8+
{
9+
public function getMethodId(): string
10+
{
11+
return PaymentMethod::BANCOMATPAY;
12+
}
13+
14+
public function getPaymentType(): string
15+
{
16+
return self::PAYMENT_API;
17+
}
18+
}

src/Payments/Methods/Payconiq.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Payments\Methods;
4+
5+
use Mollie\Api\Types\PaymentMethod;
6+
7+
final class Payconiq extends AbstractMethod
8+
{
9+
public function getMethodId(): string
10+
{
11+
return PaymentMethod::PAYCONIQ;
12+
}
13+
public function getPaymentType(): string
14+
{
15+
return self::PAYMENT_API;
16+
}
17+
}

src/Payments/Methods/Riverty.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Payments\Methods;
4+
5+
use Mollie\Api\Types\PaymentMethod;
6+
7+
final class Riverty extends AbstractMethod
8+
{
9+
public function getMethodId(): string
10+
{
11+
return PaymentMethod::RIVERTY;
12+
}
13+
public function getPaymentType(): string
14+
{
15+
return self::ORDER_API;
16+
}
17+
}

src/Payments/Methods/Trustly.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace SyliusMolliePlugin\Payments\Methods;
4+
5+
use Mollie\Api\Types\PaymentMethod;
6+
7+
class Trustly extends AbstractMethod
8+
{
9+
public function getMethodId(): string
10+
{
11+
return 'trustly';
12+
}
13+
14+
public function getPaymentType(): string
15+
{
16+
return self::PAYMENT_API;
17+
}
18+
}

src/Payments/MethodsInterface.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use SyliusMolliePlugin\Payments\Methods\Alma;
99
use SyliusMolliePlugin\Payments\Methods\ApplePay;
10+
use SyliusMolliePlugin\Payments\Methods\Bancomatpay;
1011
use SyliusMolliePlugin\Payments\Methods\Bancontact;
1112
use SyliusMolliePlugin\Payments\Methods\BankTransfer;
1213
use SyliusMolliePlugin\Payments\Methods\Belfius;
@@ -16,7 +17,6 @@
1617
use SyliusMolliePlugin\Payments\Methods\DirectDebit;
1718
use SyliusMolliePlugin\Payments\Methods\Eps;
1819
use SyliusMolliePlugin\Payments\Methods\GiftCard;
19-
use SyliusMolliePlugin\Payments\Methods\Giropay;
2020
use SyliusMolliePlugin\Payments\Methods\Ideal;
2121
use SyliusMolliePlugin\Payments\Methods\In3;
2222
use SyliusMolliePlugin\Payments\Methods\Kbc;
@@ -26,10 +26,13 @@
2626
use SyliusMolliePlugin\Payments\Methods\Klarnasliceit;
2727
use SyliusMolliePlugin\Payments\Methods\MealVoucher;
2828
use SyliusMolliePlugin\Payments\Methods\MyBank;
29+
use SyliusMolliePlugin\Payments\Methods\Payconiq;
2930
use SyliusMolliePlugin\Payments\Methods\PayPal;
3031
use SyliusMolliePlugin\Payments\Methods\Przelewy24;
32+
use SyliusMolliePlugin\Payments\Methods\Riverty;
3133
use SyliusMolliePlugin\Payments\Methods\SofortBanking;
3234
use Mollie\Api\Resources\Method;
35+
use SyliusMolliePlugin\Payments\Methods\Trustly;
3336
use SyliusMolliePlugin\Payments\Methods\Twint;
3437

3538
interface MethodsInterface
@@ -43,7 +46,6 @@ interface MethodsInterface
4346
CreditCard::class,
4447
Eps::class,
4548
GiftCard::class,
46-
Giropay::class,
4749
Ideal::class,
4850
Kbc::class,
4951
KlarnaOne::class,
@@ -60,6 +62,10 @@ interface MethodsInterface
6062
Billie::class,
6163
Twint::class,
6264
Blik::class,
65+
Riverty::class,
66+
Trustly::class,
67+
Bancomatpay::class,
68+
Payconiq::class
6369
];
6470

6571
public function getAllEnabled(): array;

src/Payments/PaymentTerms/Options.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static function getOnlyOrderAPIMethods(): array
7979
PaymentMethod::IN3,
8080
PaymentMethod::BILLIE,
8181
MealVoucher::MEAL_VOUCHERS,
82+
PaymentMethod::RIVERTY
8283
];
8384
}
8485

tests/Application/templates/bundles/SyliusAdminBundle/PaymentMethod/_mollieMethodsForm.html.twig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{% set billie = constant('Mollie\\Api\\Types\\PaymentMethod::BILLIE') %}
99
{% set in3 = constant('Mollie\\Api\\Types\\PaymentMethod::IN3') %}
1010
{% set alma = constant('Mollie\\Api\\Types\\PaymentMethod::ALMA') %}
11+
{% set riverty = constant('Mollie\\Api\\Types\\PaymentMethod::RIVERTY') %}
1112
{% import '@SyliusUi/Macro/flags.html.twig' as flags %}
1213

1314
<div class="ui segment" id="mollie-payment-form" data-status="{{resource.id}}">
@@ -142,6 +143,7 @@
142143
methodForm.vars.value.methodId == klarnaSliceIt or
143144
methodForm.vars.value.methodId == billie or
144145
methodForm.vars.value.methodId == alma or
146+
methodForm.vars.value.methodId == riverty or
145147
methodForm.vars.value.methodId == in3
146148
%}
147149
{{ form_row(methodForm.paymentType, {'attr': {'disabled': 'disabled', 'class': 'js-onboardingWizard-PaymentMethod'}}) }}

0 commit comments

Comments
 (0)