Skip to content

Commit

Permalink
User can specify desired locale (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
marianogoldman authored Sep 16, 2020
1 parent 56139b0 commit 279e58a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
16 changes: 14 additions & 2 deletions src/OrderBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class OrderBuilder
private int $amount = 0;
private string $description = '';
private string $brandName = '';
private string $locale = 'es-AR';
private string $returnUrl = '';
private string $cancelUrl = '';

Expand Down Expand Up @@ -67,6 +68,16 @@ public function brandName(string $brandName): OrderBuilder
return $this;
}

/**
* @param string $locale
* @return OrderBuilder
*/
public function setLocale(string $locale): OrderBuilder
{
$this->locale = $locale;
return $this;
}

/**
* @param string $returnUrl
* @return OrderBuilder
Expand All @@ -87,7 +98,8 @@ public function cancelUrl(string $cancelUrl): OrderBuilder
return $this;
}

public function make(): array {
public function make(): array
{
return [
'intent' => 'CAPTURE',
'purchase_units' => [
Expand All @@ -105,7 +117,7 @@ public function make(): array {
],
'application_context' => [
'brand_name' => $this->brandName,
'locale' => 'es-AR',
'locale' => $this->locale,
'user_action' => 'PAY_NOW',
'payment_method' => [
'payee_preferred' => 'IMMEDIATE_PAYMENT_REQUIRED',
Expand Down
7 changes: 5 additions & 2 deletions src/PayPalApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public function __construct(string $apiClientKey, string $apiClientSecret, bool

/**
* @param array $order
*
* @return array
* @throws RequestException
*/
Expand Down Expand Up @@ -73,6 +72,11 @@ public function findOrderById(string $id): ?array
->json();
}

/**
* @param string $orderId
* @return array|null
* @throws RequestException
*/
public function captureOrder(string $orderId): ?array
{
$token = $this->getToken();
Expand All @@ -88,7 +92,6 @@ public function captureOrder(string $orderId): ?array

/**
* @param string $querystring
*
* @return string
* @throws RequestException
*/
Expand Down
2 changes: 1 addition & 1 deletion src/PayPalFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ class PayPalFacade extends Facade
*/
protected static function getFacadeAccessor()
{
return 'paypal';
return PayPal::class;
}
}

0 comments on commit 279e58a

Please sign in to comment.