Skip to content

Commit ad963dd

Browse files
authored
minor #72 fixed where partner attribution id was hardcoded (SirDomin)
This PR was merged into the 1.0-dev branch. Discussion ---------- Commits ------- c2934ab fixed where partner attribution id was hardcoded
2 parents afa3f2f + c2934ab commit ad963dd

File tree

9 files changed

+35
-15
lines changed

9 files changed

+35
-15
lines changed

spec/Api/CompleteOrderApiSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class CompleteOrderApiSpec extends ObjectBehavior
2525
{
2626
function let(Client $client): void
2727
{
28-
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
28+
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
2929
}
3030

3131
function it_implements_complete_order_api_interface(): void
@@ -51,7 +51,7 @@ function it_completes_pay_pal_order_with_given_id(
5151
'headers' => [
5252
'Authorization' => 'Bearer TOKEN',
5353
'Prefer' => 'return=representation',
54-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
54+
'PayPal-Partner-Attribution-Id' => 'PARTNER_ATTRIBUTION_ID',
5555
'Content-Type' => 'application/json',
5656
],
5757
]

spec/Api/CreateOrderApiSpec.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class CreateOrderApiSpec extends ObjectBehavior
2929
{
3030
function let(Client $client): void
3131
{
32-
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
32+
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
3333
}
3434

3535
function it_implements_create_order_api_interface(): void

spec/Api/OrderDetailsApiSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class OrderDetailsApiSpec extends ObjectBehavior
2424
{
2525
function let(Client $client): void
2626
{
27-
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
27+
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
2828
}
2929

3030
function it_implements_pay_pal_order_details_provider_interface(): void
@@ -46,7 +46,7 @@ function it_provides_details_about_pay_pal_order(
4646
'Authorization' => 'Bearer TOKEN',
4747
'Content-Type' => 'application/json',
4848
'Accept' => 'application/json',
49-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
49+
'PayPal-Partner-Attribution-Id' => 'PARTNER_ATTRIBUTION_ID',
5050
],
5151
]
5252
)->willReturn($detailsResponse);

spec/Api/RefundPaymentApiSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class RefundPaymentApiSpec extends ObjectBehavior
2626
{
2727
function let(Client $client): void
2828
{
29-
$this->beConstructedWith($client, 'https://api.test-paypal.com/');
29+
$this->beConstructedWith($client, 'https://api.test-paypal.com/', 'PARTNER_ATTRIBUTION_ID');
3030
}
3131

3232
function it_implements_refund_order_api_interface(): void
@@ -51,7 +51,7 @@ function it_refunds_pay_pal_payment_with_given_id(
5151
Argument::that(function (array $options): bool {
5252
return
5353
$options['headers']['Authorization'] === 'Bearer TOKEN' &&
54-
$options['headers']['PayPal-Partner-Attribution-Id'] === 'sylius-ppcp4p-bn-code' &&
54+
$options['headers']['PayPal-Partner-Attribution-Id'] === 'PARTNER_ATTRIBUTION_ID' &&
5555
$options['headers']['Content-Type'] === 'application/json' &&
5656
is_string($options['headers']['PayPal-Request-Id'])
5757
;

src/Api/CompleteOrderApi.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ final class CompleteOrderApi implements CompleteOrderApiInterface
2323
/** @var string */
2424
private $baseUrl;
2525

26-
public function __construct(Client $client, string $baseUrl)
26+
/** @var string */
27+
private $partnerAttributionId;
28+
29+
public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
2730
{
2831
$this->client = $client;
2932
$this->baseUrl = $baseUrl;
33+
$this->partnerAttributionId = $partnerAttributionId;
3034
}
3135

3236
public function complete(string $token, string $orderId): array
@@ -38,7 +42,7 @@ public function complete(string $token, string $orderId): array
3842
'headers' => [
3943
'Authorization' => 'Bearer ' . $token,
4044
'Prefer' => 'return=representation',
41-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
45+
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
4246
'Content-Type' => 'application/json',
4347
],
4448
]

src/Api/CreateOrderApi.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ final class CreateOrderApi implements CreateOrderApiInterface
2828
/** @var string */
2929
private $baseUrl;
3030

31-
public function __construct(Client $client, string $baseUrl)
31+
/** @var string */
32+
private $partnerAttributionId;
33+
34+
public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
3235
{
3336
$this->client = $client;
3437
$this->baseUrl = $baseUrl;
38+
$this->partnerAttributionId = $partnerAttributionId;
3539
}
3640

3741
public function create(string $token, PaymentInterface $payment): array
@@ -97,7 +101,7 @@ public function create(string $token, PaymentInterface $payment): array
97101
'Authorization' => 'Bearer ' . $token,
98102
'Content-Type' => 'application/json',
99103
'Accept' => 'application/json',
100-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
104+
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
101105
],
102106
'json' => $data,
103107
]

src/Api/OrderDetailsApi.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ final class OrderDetailsApi implements OrderDetailsApiInterface
1414
/** @var string */
1515
private $baseUrl;
1616

17-
public function __construct(Client $client, string $baseUrl)
17+
/** @var string */
18+
private $partnerAttributionId;
19+
20+
public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
1821
{
1922
$this->client = $client;
2023
$this->baseUrl = $baseUrl;
24+
$this->partnerAttributionId = $partnerAttributionId;
2125
}
2226

2327
public function get(string $token, string $orderId): array
@@ -29,7 +33,7 @@ public function get(string $token, string $orderId): array
2933
'Authorization' => 'Bearer ' . $token,
3034
'Content-Type' => 'application/json',
3135
'Accept' => 'application/json',
32-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
36+
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
3337
],
3438
]
3539
);

src/Api/RefundPaymentApi.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ final class RefundPaymentApi implements RefundPaymentApiInterface
2424
/** @var string */
2525
private $baseUrl;
2626

27-
public function __construct(Client $client, string $baseUrl)
27+
/** @var string */
28+
private $partnerAttributionId;
29+
30+
public function __construct(Client $client, string $baseUrl, string $partnerAttributionId)
2831
{
2932
$this->client = $client;
3033
$this->baseUrl = $baseUrl;
34+
$this->partnerAttributionId = $partnerAttributionId;
3135
}
3236

3337
public function refund(string $token, string $paymentId): array
@@ -38,7 +42,7 @@ public function refund(string $token, string $paymentId): array
3842
[
3943
'headers' => [
4044
'Authorization' => 'Bearer ' . $token,
41-
'PayPal-Partner-Attribution-Id' => 'sylius-ppcp4p-bn-code',
45+
'PayPal-Partner-Attribution-Id' => $this->partnerAttributionId,
4246
'Content-Type' => 'application/json',
4347
'PayPal-Request-Id' => Uuid::uuid4()->toString(),
4448
],

src/Resources/config/services/api.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
>
1717
<argument type="service" id="sylius.http_client" />
1818
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
19+
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
1920
</service>
2021

2122
<service
@@ -24,6 +25,7 @@
2425
>
2526
<argument type="service" id="sylius.http_client" />
2627
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
28+
<argument>%env(resolve:PAYPAL_TRACKING_ID)%)</argument>
2729
</service>
2830

2931
<service
@@ -32,6 +34,7 @@
3234
>
3335
<argument type="service" id="sylius.http_client" />
3436
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
37+
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
3538
</service>
3639

3740
<service
@@ -49,6 +52,7 @@
4952
>
5053
<argument type="service" id="sylius.http_client" />
5154
<argument>%env(resolve:PAYPAL_API_BASE_URL)%</argument>
55+
<argument>%env(resolve:PAYPAL_TRACKING_ID)%</argument>
5256
</service>
5357
</services>
5458
</container>

0 commit comments

Comments
 (0)