diff --git a/src/PaymentMethods/PaymentFacade.php b/src/PaymentMethods/PaymentFacade.php index 584472a..76d65d6 100644 --- a/src/PaymentMethods/PaymentFacade.php +++ b/src/PaymentMethods/PaymentFacade.php @@ -166,8 +166,13 @@ public function paymentMethod(): PaymentMethod */ public function __call(?string $name, array $arguments) { - if (method_exists($this->paymentMethod, $name)) - { + if (method_exists($this->paymentMethod, $name)) { + if($name === 'setServiceVersion') { + $this->paymentMethod->setServiceVersion($arguments[0]); + + return $this; + } + $this->paymentMethod->setPayload((new PayloadService($arguments[0] ?? []))->toArray()); return $this->paymentMethod->$name(); diff --git a/src/PaymentMethods/PaymentMethod.php b/src/PaymentMethods/PaymentMethod.php index 3041656..0a1cf3a 100644 --- a/src/PaymentMethods/PaymentMethod.php +++ b/src/PaymentMethods/PaymentMethod.php @@ -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 diff --git a/tests/Buckaroo/Payments/AfterpayTest.php b/tests/Buckaroo/Payments/AfterpayTest.php index a92d30d..bec23ab 100644 --- a/tests/Buckaroo/Payments/AfterpayTest.php +++ b/tests/Buckaroo/Payments/AfterpayTest.php @@ -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()); }