diff --git a/src/Helper/ConvertOrder.php b/src/Helper/ConvertOrder.php index 36bb6695..ea5bbbd2 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; @@ -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)); @@ -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 00000000..05a702f6 --- /dev/null +++ b/src/Payments/Methods/Bancomatpay.php @@ -0,0 +1,18 @@ +