From 128f9a626abdf27b73be5168a60c206174cda11d Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Mon, 11 Mar 2024 16:48:57 +0800 Subject: [PATCH] Able to set service version --- src/PaymentMethods/PaymentFacade.php | 7 +++++++ src/PaymentMethods/PaymentMethod.php | 10 ++++++++++ tests/Buckaroo/Payments/AfterpayTest.php | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/PaymentMethods/PaymentFacade.php b/src/PaymentMethods/PaymentFacade.php index 584472ac..a74b2636 100644 --- a/src/PaymentMethods/PaymentFacade.php +++ b/src/PaymentMethods/PaymentFacade.php @@ -168,6 +168,13 @@ public function __call(?string $name, array $arguments) { 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 3041656c..0a1cf3a8 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 a92d30d0..bec23abd 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()); }