Skip to content

Commit

Permalink
minor #72 fixed where partner attribution id was hardcoded (SirDomin)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

Discussion
----------



Commits
-------

c2934ab fixed where partner attribution id was hardcoded
  • Loading branch information
Zales0123 authored Aug 31, 2020
2 parents afa3f2f + c2934ab commit ad963dd
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
4 changes: 2 additions & 2 deletions spec/Api/CompleteOrderApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class CompleteOrderApiSpec extends ObjectBehavior
{
function let(Client $client): void
{
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
}

function it_implements_complete_order_api_interface(): void
Expand All @@ -51,7 +51,7 @@ function it_completes_pay_pal_order_with_given_id(
'headers' => [
'Authorization' => 'Bearer TOKEN',
'Prefer' => 'return=representation',
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => 'PARTNER_ATTRIBUTION_ID',
'Content-Type' => 'application/json',
],
]
Expand Down
2 changes: 1 addition & 1 deletion spec/Api/CreateOrderApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class CreateOrderApiSpec extends ObjectBehavior
{
function let(Client $client): void
{
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
}

function it_implements_create_order_api_interface(): void
Expand Down
4 changes: 2 additions & 2 deletions spec/Api/OrderDetailsApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class OrderDetailsApiSpec extends ObjectBehavior
{
function let(Client $client): void
{
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
}

function it_implements_pay_pal_order_details_provider_interface(): void
Expand All @@ -46,7 +46,7 @@ function it_provides_details_about_pay_pal_order(
'Authorization' => 'Bearer TOKEN',
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => 'PARTNER_ATTRIBUTION_ID',
],
]
)->willReturn($detailsResponse);
Expand Down
4 changes: 2 additions & 2 deletions spec/Api/RefundPaymentApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class RefundPaymentApiSpec extends ObjectBehavior
{
function let(Client $client): void
{
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
}

function it_implements_refund_order_api_interface(): void
Expand All @@ -51,7 +51,7 @@ function it_refunds_pay_pal_payment_with_given_id(
Argument::that(function (array $options): bool {
return
$options['headers']['Authorization'] === 'Bearer TOKEN' &&
$options['headers']['PayPal-Partner-Attribution-Id'] === 'sylius-ppcp4p-bn-code' &&
$options['headers']['PayPal-Partner-Attribution-Id'] === 'PARTNER_ATTRIBUTION_ID' &&
$options['headers']['Content-Type'] === 'application/json' &&
is_string($options['headers']['PayPal-Request-Id'])
;
Expand Down
8 changes: 6 additions & 2 deletions src/Api/CompleteOrderApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ final class CompleteOrderApi implements CompleteOrderApiInterface
/** @var string */
private $baseUrl;

public function __construct(Client $client, string $baseUrl)
/** @var string */
private $partnerAttributionId;

public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
{
$this->client = $client;
$this->baseUrl = $baseUrl;
$this->partnerAttributionId = $partnerAttributionId;
}

public function complete(string $token, string $orderId): array
Expand All @@ -38,7 +42,7 @@ public function complete(string $token, string $orderId): array
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Prefer' => 'return=representation',
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
'Content-Type' => 'application/json',
],
]
Expand Down
8 changes: 6 additions & 2 deletions src/Api/CreateOrderApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ final class CreateOrderApi implements CreateOrderApiInterface
/** @var string */
private $baseUrl;

public function __construct(Client $client, string $baseUrl)
/** @var string */
private $partnerAttributionId;

public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
{
$this->client = $client;
$this->baseUrl = $baseUrl;
$this->partnerAttributionId = $partnerAttributionId;
}

public function create(string $token, PaymentInterface $payment): array
Expand Down Expand Up @@ -97,7 +101,7 @@ public function create(string $token, PaymentInterface $payment): array
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
],
'json' => $data,
]
Expand Down
8 changes: 6 additions & 2 deletions src/Api/OrderDetailsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ final class OrderDetailsApi implements OrderDetailsApiInterface
/** @var string */
private $baseUrl;

public function __construct(Client $client, string $baseUrl)
/** @var string */
private $partnerAttributionId;

public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
{
$this->client = $client;
$this->baseUrl = $baseUrl;
$this->partnerAttributionId = $partnerAttributionId;
}

public function get(string $token, string $orderId): array
Expand All @@ -29,7 +33,7 @@ public function get(string $token, string $orderId): array
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
],
]
);
Expand Down
8 changes: 6 additions & 2 deletions src/Api/RefundPaymentApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ final class RefundPaymentApi implements RefundPaymentApiInterface
/** @var string */
private $baseUrl;

public function __construct(Client $client, string $baseUrl)
/** @var string */
private $partnerAttributionId;

public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
{
$this->client = $client;
$this->baseUrl = $baseUrl;
$this->partnerAttributionId = $partnerAttributionId;
}

public function refund(string $token, string $paymentId): array
Expand All @@ -38,7 +42,7 @@ public function refund(string $token, string $paymentId): array
[
'headers' => [
'Authorization' => 'Bearer ' . $token,
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
'Content-Type' => 'application/json',
'PayPal-Request-Id' => Uuid::uuid4()->toString(),
],
Expand Down
4 changes: 4 additions & 0 deletions src/Resources/config/services/api.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
>
<argument type="service" id="sylius.http_client" />
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
</service>

<service
Expand All @@ -24,6 +25,7 @@
>
<argument type="service" id="sylius.http_client" />
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
<argument>%env(resolve:PAYPAL_TRACKING_ID)%)</argument>
</service>

<service
Expand All @@ -32,6 +34,7 @@
>
<argument type="service" id="sylius.http_client" />
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
</service>

<service
Expand All @@ -49,6 +52,7 @@
>
<argument type="service" id="sylius.http_client" />
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
</service>
</services>
</container>

0 comments on commit ad963dd

Please sign in to comment.