{{ 'sylius.pay_pal.missing_billing_address_content'|trans }}
+diff --git a/src/Api/CreateOrderApi.php b/src/Api/CreateOrderApi.php
index 455677d7..a2e18ef5 100644
--- a/src/Api/CreateOrderApi.php
+++ b/src/Api/CreateOrderApi.php
@@ -88,17 +88,6 @@ public function create(string $token, PaymentInterface $payment, string $referen
'payee' => [
'merchant_id' => $config['merchant_id'],
],
- 'shipping' => [
- 'name' => ['full_name' => 'John Doe'],
- 'address' => [
- 'address_line_1' => 'Test St. 123',
- 'address_line_2' => '6',
- 'admin_area_1' => 'CA',
- 'admin_area_2' => 'New York',
- 'postal_code' => '32000',
- 'country_code' => 'US',
- ],
- ],
'soft_descriptor' => 'Sylius PayPal Payment',
'items' => $payPalItemData['items'],
],
@@ -109,7 +98,7 @@ public function create(string $token, PaymentInterface $payment, string $referen
];
$address = $order->getShippingAddress();
- if ($address !== null) {
+ if ($address !== null && $order->isShippingRequired()) {
$data['purchase_units'][0]['shipping'] = [
'name' => ['full_name' => $address->getFullName()],
'address' => [
diff --git a/src/Controller/ProcessPayPalOrderAction.php b/src/Controller/ProcessPayPalOrderAction.php
index dbc53ff8..59a4438d 100644
--- a/src/Controller/ProcessPayPalOrderAction.php
+++ b/src/Controller/ProcessPayPalOrderAction.php
@@ -113,9 +113,12 @@ public function __invoke(Request $request): Response
} else {
$address->setFirstName($customer->getFirstName());
$address->setLastName($customer->getLastName());
- $address->setStreet('');
- $address->setCity('');
- $address->setPostcode('');
+
+ $defaultAddress = $customer->getDefaultAddress();
+
+ $address->setStreet($defaultAddress ? $defaultAddress->getStreet() : '');
+ $address->setCity($defaultAddress ? $defaultAddress->getCity() : '');
+ $address->setPostcode($defaultAddress ? $defaultAddress->getPostcode() : '');
$address->setCountryCode($data['payer']['address']['country_code']);
$stateMachine->apply(OrderCheckoutTransitions::TRANSITION_ADDRESS);
}
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
index 07177d5d..9ee48ceb 100644
--- a/src/Resources/config/services.xml
+++ b/src/Resources/config/services.xml
@@ -260,5 +260,9 @@