Skip to content

Commit

Permalink
Merge branch 'PISYL-204/add-Bancomatpay'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Payments/MethodsInterface.php
  • Loading branch information
SergejSavic committed Jul 23, 2024
2 parents a8aee5e + 77aceea commit 65b5a3c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Helper/ConvertOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace SyliusMolliePlugin\Helper;

use Mollie\Api\Types\PaymentMethod;
use Sylius\Component\Addressing\Model\ZoneInterface;
use Sylius\Component\Core\Model\Scope;
use Sylius\Component\Core\Model\ShippingMethodInterface;
Expand Down Expand Up @@ -84,7 +85,7 @@ public function convert(
$details['amount']['value'] = $amount;
$details['orderNumber'] = (string) $order->getNumber();
$details['shippingAddress'] = $this->createShippingAddress($customer);
$details['billingAddress'] = $this->createBillingAddress($customer);
$details['billingAddress'] = $this->createBillingAddress($customer, $method->getMethodId());
$details['lines'] = $this->createLines($divisor, $method);
$details['lines'] = array_merge($details['lines'], $this->createShippingFee($divisor));

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

private function createBillingAddress(CustomerInterface $customer): array
private function createBillingAddress(CustomerInterface $customer, string $methodId): array
{
$billingAddress = $this->order->getBillingAddress();

Assert::notNull($billingAddress);

return [
$address = [
'streetAndNumber' => $billingAddress->getStreet(),
'postalCode' => $billingAddress->getPostcode(),
'city' => $billingAddress->getCity(),
'country' => $billingAddress->getCountryCode(),
'givenName' => $billingAddress->getFirstName(),
'familyName' => $billingAddress->getLastName(),
'organizationName' => $billingAddress->getCompany(),
'email' => $customer->getEmail(),
'email' => $customer->getEmail()
];

if ($methodId === PaymentMethod::BANCOMATPAY && $billingAddress->getPhoneNumber()) {
$address['phone'] = $billingAddress->getPhoneNumber();
}

return $address;
}

private function createLines(int $divisor, MollieGatewayConfigInterface $method): array
Expand Down
18 changes: 18 additions & 0 deletions src/Payments/Methods/Bancomatpay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SyliusMolliePlugin\Payments\Methods;

use Mollie\Api\Types\PaymentMethod;

final class Bancomatpay extends AbstractMethod
{
public function getMethodId(): string
{
return PaymentMethod::BANCOMATPAY;
}

public function getPaymentType(): string
{
return self::PAYMENT_API;
}
}
2 changes: 2 additions & 0 deletions src/Payments/MethodsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use SyliusMolliePlugin\Payments\Methods\Alma;
use SyliusMolliePlugin\Payments\Methods\ApplePay;
use SyliusMolliePlugin\Payments\Methods\Bancomatpay;
use SyliusMolliePlugin\Payments\Methods\Bancontact;
use SyliusMolliePlugin\Payments\Methods\BankTransfer;
use SyliusMolliePlugin\Payments\Methods\Belfius;
Expand Down Expand Up @@ -63,6 +64,7 @@ interface MethodsInterface
Blik::class,
Riverty::class,
Trustly::class,
Bancomatpay::class,
Payconiq::class
];

Expand Down

0 comments on commit 65b5a3c

Please sign in to comment.