Skip to content

Commit

Permalink
Able to set service version
Browse files Browse the repository at this point in the history
  • Loading branch information
ShuCh3n committed Mar 11, 2024
1 parent 3e3ea83 commit 128f9a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/PaymentMethods/PaymentFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ public function __call(?string $name, array $arguments)
{
if (method_exists($this->paymentMethod, $name))
{
if($name === 'setServiceVersion')

Check failure on line 171 in src/PaymentMethods/PaymentFacade.php

View workflow job for this annotation

GitHub Actions / PHP 7.4 - prefer-stable -

Whitespace found at end of line

Check failure on line 171 in src/PaymentMethods/PaymentFacade.php

View workflow job for this annotation

GitHub Actions / PHP 8.2 - prefer-stable -

Whitespace found at end of line

Check failure on line 171 in src/PaymentMethods/PaymentFacade.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 - prefer-stable -

Whitespace found at end of line
{
$this->paymentMethod->setServiceVersion($arguments[0]);

return $this;
}

$this->paymentMethod->setPayload((new PayloadService($arguments[0] ?? []))->toArray());

return $this->paymentMethod->$name();
Expand Down
10 changes: 10 additions & 0 deletions src/PaymentMethods/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ public function serviceVersion(): int
return $this->serviceVersion;
}

/**
* @return PaymentInterface
*/
public function setServiceVersion(int $serviceVersion): PaymentInterface
{
$this->serviceVersion = $serviceVersion;

return $this;
}

/**
* @param bool|null $isManually
* @return $this
Expand Down
2 changes: 1 addition & 1 deletion tests/Buckaroo/Payments/AfterpayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AfterpayTest extends BuckarooTestCase
*/
public function it_creates_a_afterpay_payment()
{
$response = $this->buckaroo->method('afterpay')->pay($this->getPaymentPayload());
$response = $this->buckaroo->method('afterpay')->setServiceVersion(3)->pay($this->getPaymentPayload());

$this->assertTrue($response->isSuccess());
}
Expand Down

0 comments on commit 128f9a6

Please sign in to comment.