From a8d15afefad384a8da8f4ea7388754992a223ae3 Mon Sep 17 00:00:00 2001 From: SergejSavic Date: Fri, 19 Jul 2024 11:55:22 +0200 Subject: [PATCH 1/2] add Bancomatpay payment method --- src/Helper/ConvertOrder.php | 13 ++++++++++--- src/Payments/Methods/Bancomatpay.php | 18 ++++++++++++++++++ src/Payments/MethodsInterface.php | 4 +++- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 src/Payments/Methods/Bancomatpay.php diff --git a/src/Helper/ConvertOrder.php b/src/Helper/ConvertOrder.php index 36bb669..6819d99 100644 --- a/src/Helper/ConvertOrder.php +++ b/src/Helper/ConvertOrder.php @@ -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; @@ -109,13 +110,13 @@ 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(), @@ -123,8 +124,14 @@ private function createBillingAddress(CustomerInterface $customer): array '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 diff --git a/src/Payments/Methods/Bancomatpay.php b/src/Payments/Methods/Bancomatpay.php new file mode 100644 index 0000000..05a702f --- /dev/null +++ b/src/Payments/Methods/Bancomatpay.php @@ -0,0 +1,18 @@ + Date: Fri, 19 Jul 2024 11:56:10 +0200 Subject: [PATCH 2/2] add Bancomatpay payment method --- src/Helper/ConvertOrder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helper/ConvertOrder.php b/src/Helper/ConvertOrder.php index 6819d99..ea5bbbd 100644 --- a/src/Helper/ConvertOrder.php +++ b/src/Helper/ConvertOrder.php @@ -85,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));