Skip to content

Commit

Permalink
Paypal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson committed Sep 22, 2023
1 parent e5e3966 commit 64a0457
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions payment/paypal/src/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getOrder(string $orderId)
public function capture(string $orderId)
{
return $this->baseHttpClient()->withToken($this->getAccessToken())
->withBody('')
->withBody('', 'application/json')
->post("/v2/checkout/orders/{$orderId}/capture")
->json();
}
Expand All @@ -60,6 +60,8 @@ public function buildInitialOrder(Cart $cart): array
$billingAddress = $cart->billingAddress;
$shippingAddress = $cart->shippingAddress ?: $billingAddress;

$successRoute = config('lunar.payments.paypal.success_route', 'checkout.success');

$requestData = [
'intent' => 'CAPTURE',
'purchase_units' => [
Expand Down Expand Up @@ -87,13 +89,13 @@ public function buildInitialOrder(Cart $cart): array
'shipping_preference' => 'SET_PROVIDED_ADDRESS',
'payment_method_preference' => 'IMMEDIATE_PAYMENT_REQUIRED',
'email' => $billingAddress?->contact_email,
'return_url' => route('checkout.success'),
'cancel_url' => route('checkout.index', $cart->fingerprint()),
'return_url' => route($successRoute),
'cancel_url' => route($successRoute, $cart->fingerprint()),
'name' => [
'given_name' => $billingAddress?->first_name,
'surname' => $billingAddress?->last_name,
],
'email_address' => $billingAddress->email,
'email_address' => $billingAddress->contact_email,
'address' => [
'address_line_1' => $billingAddress?->line_one,
'address_line_2' => $billingAddress?->line_two,
Expand All @@ -107,7 +109,7 @@ public function buildInitialOrder(Cart $cart): array
];

return $this->baseHttpClient()->withToken($this->getAccessToken())->withBody(
json_encode($requestData)
json_encode($requestData), 'application/json'
)->post('v2/checkout/orders')->json();
}
}

0 comments on commit 64a0457

Please sign in to comment.