From 906134381e22c1319ef9de57ab640f4eef51f7b8 Mon Sep 17 00:00:00 2001 From: Alex Kratky Date: Tue, 27 Sep 2022 11:43:15 +0200 Subject: [PATCH 1/5] payment urls --- src/Model/IPaymentMethod.php | 33 ++++++++++ src/Model/PaymentMethod.php | 2 +- src/Model/PaymentMethodWithPayUrl.php | 84 ++++++++++++++++++++++++++ src/Service/ApiService.php | 33 +++++++++- src/Service/ApiServiceInterface.php | 8 +++ src/Service/GateService.php | 31 ++++++++-- src/Service/GateServiceInterface.php | 8 +++ src/TheClient.php | 35 +++++++++++ tests/Mocks/Service/ApiMockService.php | 64 ++++++++++++++++++++ 9 files changed, 292 insertions(+), 6 deletions(-) create mode 100644 src/Model/IPaymentMethod.php create mode 100644 src/Model/PaymentMethodWithPayUrl.php diff --git a/src/Model/IPaymentMethod.php b/src/Model/IPaymentMethod.php new file mode 100644 index 0000000..dea4f96 --- /dev/null +++ b/src/Model/IPaymentMethod.php @@ -0,0 +1,33 @@ + + */ + public function getTags(); + + /** + * @return array + */ + public function toArray(); +} diff --git a/src/Model/PaymentMethod.php b/src/Model/PaymentMethod.php index 36a6d06..6c25f5a 100644 --- a/src/Model/PaymentMethod.php +++ b/src/Model/PaymentMethod.php @@ -5,7 +5,7 @@ use ThePay\ApiClient\Utils\Json; use ThePay\ApiClient\ValueObject\Url; -class PaymentMethod +class PaymentMethod implements IPaymentMethod { /** * @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::CARD diff --git a/src/Model/PaymentMethodWithPayUrl.php b/src/Model/PaymentMethodWithPayUrl.php new file mode 100644 index 0000000..380e094 --- /dev/null +++ b/src/Model/PaymentMethodWithPayUrl.php @@ -0,0 +1,84 @@ + */ + private $tags; + + /** @var Url|null */ + private $imageUrl; + + /** @var Url */ + private $payUrl; + + /** + * @param string|array $values Json in string or associative array + */ + public function __construct($values) + { + $data = is_array($values) ? $values : Json::decode($values, true); + + $this->code = $data['code']; + $this->title = $data['title']; + $this->imageUrl = new Url($data['image']['src']); + $this->tags = $data['tags']; + $this->payUrl = new Url($data['url']); + } + + /** @return string */ + public function getCode() + { + return $this->code; + } + + /** @return string */ + public function getTitle() + { + return $this->title; + } + + /** @return Url */ + public function getImageUrl() + { + return $this->imageUrl; + } + + /** @return Url */ + public function getPayUrl() + { + return $this->payUrl; + } + + /** + * @return array + */ + public function getTags() + { + return $this->tags; + } + + /** + * @return array + */ + public function toArray() + { + return array( + 'code' => $this->code, + 'title' => $this->title, + 'tags' => $this->tags, + 'imageUrl' => (string) $this->imageUrl, + 'payUrl' => (string) $this->payUrl, + ); + } +} diff --git a/src/Service/ApiService.php b/src/Service/ApiService.php index 5a1522c..48773f9 100644 --- a/src/Service/ApiService.php +++ b/src/Service/ApiService.php @@ -15,6 +15,7 @@ use ThePay\ApiClient\Model\CreatePaymentResponse; use ThePay\ApiClient\Model\PaginatedCollectionParams; use ThePay\ApiClient\Model\Payment; +use ThePay\ApiClient\Model\PaymentMethodWithPayUrl; use ThePay\ApiClient\Model\PaymentRefund; use ThePay\ApiClient\Model\PaymentRefundInfo; use ThePay\ApiClient\Model\Project; @@ -95,7 +96,7 @@ public function getActivePaymentMethods(LanguageCode $languageCode = null) $arguments['language'] = $languageCode->getValue(); } - $url = $this->url(array('methods')); + $url = $this->url(array('methods'), $arguments); $response = $this ->httpService ->get($url); @@ -420,6 +421,36 @@ public function createPaymentRefund(Identifier $uid, Amount $amount, StringValue } } + /** + * Returns an array of available payment methods with pay URLs for certain payment. + * + * @return array + */ + public function getPaymentUrlsForPayment(Identifier $uid, LanguageCode $languageCode = null) + { + $arguments = array(); + if ($languageCode) { + $arguments['language'] = $languageCode->getValue(); + } + + $url = $this->url(array('payments', $uid->getValue(), 'payment_urls'), $arguments); + $response = $this->httpService->get($url); + + if ($response->getCode() !== 200) { + throw $this->buildException($url, $response); + } + + $responseData = Json::decode($response->getBody(), true); + + $paymentMethods = array(); + foreach ($responseData as $paymentMethod) { + $paymentMethods[] = new PaymentMethodWithPayUrl($paymentMethod); + } + + return $paymentMethods; + } + + /** * Build URL for API requests diff --git a/src/Service/ApiServiceInterface.php b/src/Service/ApiServiceInterface.php index c11cfa7..e41a1f3 100644 --- a/src/Service/ApiServiceInterface.php +++ b/src/Service/ApiServiceInterface.php @@ -13,6 +13,7 @@ use ThePay\ApiClient\Model\CreatePaymentParams; use ThePay\ApiClient\Model\CreatePaymentResponse; use ThePay\ApiClient\Model\Payment; +use ThePay\ApiClient\Model\PaymentMethodWithPayUrl; use ThePay\ApiClient\Model\PaymentRefundInfo; use ThePay\ApiClient\Model\Project; use ThePay\ApiClient\Model\RealizeIrregularSubscriptionPaymentParams; @@ -153,4 +154,11 @@ public function getPaymentRefund(Identifier $uid); * @return void */ public function createPaymentRefund(Identifier $uid, Amount $amount, StringValue $reason); + + /** + * Returns an array of available payment methods with pay URLs for certain payment. + * + * @return array + */ + public function getPaymentUrlsForPayment(Identifier $uid, LanguageCode $languageCode = null); } diff --git a/src/Service/GateService.php b/src/Service/GateService.php index 4073cbb..bf764b8 100644 --- a/src/Service/GateService.php +++ b/src/Service/GateService.php @@ -4,8 +4,11 @@ use ThePay\ApiClient\Model\Collection\PaymentMethodCollection; use ThePay\ApiClient\Model\CreatePaymentParams; +use ThePay\ApiClient\Model\IPaymentMethod; use ThePay\ApiClient\Model\PaymentMethod; use ThePay\ApiClient\TheConfig; +use ThePay\ApiClient\ValueObject\Identifier; +use ThePay\ApiClient\ValueObject\LanguageCode; /** * Class GateService is responsible for rendering payment forms. @@ -21,8 +24,6 @@ class GateService implements GateServiceInterface /** * @var ApiServiceInterface - * - * @phpstan-ignore-next-line never read (never mind, backward compatibility is more important) */ private $api; @@ -95,6 +96,7 @@ public function getPaymentButtons(CreatePaymentParams $params, PaymentMethodColl } $result .= '
'; + /** @var IPaymentMethod $method */ foreach ($methods as $method) { $btnAttrs['data-payment-method'] = $method->getCode(); $result .= $this->buildButton($this->getUrlForPayment($paymentData, $method->getCode()), $this->getButtonMethodContent($method), $btnAttrs); @@ -104,6 +106,27 @@ public function getPaymentButtons(CreatePaymentParams $params, PaymentMethodColl return $result; } + /** + * @param Identifier $uid UID of payment + * @return string HTML + */ + public function getPaymentButtonsForPayment(Identifier $uid, LanguageCode $languageCode = null) + { + $paymentMethods = $this->api->getPaymentUrlsForPayment($uid, $languageCode); + $result = ''; + + $btnAttrs = array(); + + $result .= '
'; + foreach ($paymentMethods as $method) { + $btnAttrs['data-payment-method'] = $method->getCode(); + $result .= $this->buildButton($method->getPayUrl(), $this->getButtonMethodContent($method), $btnAttrs); + } + $result .= '
'; + + return $result; + } + public function getInlineAssets() { @@ -202,10 +225,10 @@ private function buildPaymentDataForm(array $paymentData, array $attributes = ar /** * Returns content of method for button link - * @param PaymentMethod $method + * @param IPaymentMethod $method * @return string HTML */ - private function getButtonMethodContent(PaymentMethod $method) + private function getButtonMethodContent(IPaymentMethod $method) { return '' . 'htmlAttributes(array('src' => $method->getImageUrl(), 'alt' => $method->getTitle())) . ' />' diff --git a/src/Service/GateServiceInterface.php b/src/Service/GateServiceInterface.php index f747052..1811d19 100644 --- a/src/Service/GateServiceInterface.php +++ b/src/Service/GateServiceInterface.php @@ -5,6 +5,8 @@ use ThePay\ApiClient\Model\Collection\PaymentMethodCollection; use ThePay\ApiClient\Model\CreatePaymentParams; use ThePay\ApiClient\TheConfig; +use ThePay\ApiClient\ValueObject\Identifier; +use ThePay\ApiClient\ValueObject\LanguageCode; interface GateServiceInterface { @@ -19,6 +21,12 @@ public function __construct(TheConfig $config, ApiServiceInterface $api); */ public function getPaymentButtons(CreatePaymentParams $params, PaymentMethodCollection $methods); + /** + * @param Identifier $uid UID of payment + * @return string HTML + */ + public function getPaymentButtonsForPayment(Identifier $uid, LanguageCode $languageCode = null); + /** * @param string $content HTML content of button * @param string|null $methodCode diff --git a/src/TheClient.php b/src/TheClient.php index 8f860fb..c7ad51d 100644 --- a/src/TheClient.php +++ b/src/TheClient.php @@ -15,6 +15,7 @@ use ThePay\ApiClient\Model\Collection\PaymentMethodCollection; use ThePay\ApiClient\Model\CreatePaymentParams; use ThePay\ApiClient\Model\CreatePaymentResponse; +use ThePay\ApiClient\Model\PaymentMethodWithPayUrl; use ThePay\ApiClient\Model\PaymentRefundInfo; use ThePay\ApiClient\Model\Project; use ThePay\ApiClient\Model\RealizeIrregularSubscriptionPaymentParams; @@ -207,6 +208,20 @@ public function getPayments(PaymentsFilter $filter = null, $page = 1, $limit = 2 ->getPayments($filter, $page, $limit); } + /** + * Returns an array of available payment methods with pay URLs for certain payment. + * + * @return array + */ + public function getPaymentUrlsForPayment(string $uid) + { + $this->validateUid($uid); + + return $this + ->api + ->getPaymentUrlsForPayment(new Identifier($uid)); + } + /** * Returns HTML code with payment buttons for each available payment method. * Every button is a link with click event handler to post the user to the payment process. @@ -241,6 +256,26 @@ public function getPaymentButtons(CreatePaymentParams $params, PaymentMethodFilt return $result; } + /** + * Returns HTML code with payment buttons for each available payment method. + * Every button contains direct link to pay with certain method. + * + * @param string $uid UID of payment + * @param string|null $languageCode + * @param bool $useInlineAssets false value disable generation default style & scripts + * + * @return string HTML + */ + public function getPaymentButtonsForPayment($uid, $languageCode = null, $useInlineAssets = true) + { + $result = ''; + if ($useInlineAssets) { + $result .= $this->getInlineAssets(); + } + $result .= $this->gate->getPaymentButtonsForPayment(new Identifier($uid), $languageCode ? new LanguageCode($languageCode) : $languageCode); + return $result; + } + /** * @param CreatePaymentParams $params * @param string $title diff --git a/tests/Mocks/Service/ApiMockService.php b/tests/Mocks/Service/ApiMockService.php index a81ac9e..8b0d3a0 100644 --- a/tests/Mocks/Service/ApiMockService.php +++ b/tests/Mocks/Service/ApiMockService.php @@ -12,6 +12,7 @@ use ThePay\ApiClient\Model\CreatePaymentParams; use ThePay\ApiClient\Model\CreatePaymentResponse; use ThePay\ApiClient\Model\Payment; +use ThePay\ApiClient\Model\PaymentMethodWithPayUrl; use ThePay\ApiClient\Model\PaymentRefund; use ThePay\ApiClient\Model\PaymentRefundInfo; use ThePay\ApiClient\Model\Project; @@ -344,6 +345,69 @@ public function getActivePaymentMethods(LanguageCode $languageCode = null) ); } + /** + * Fetch all active payment methods. + * + * @return array + */ + public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languageCode = null) + { + return array( + 0 => new PaymentMethodWithPayUrl( + array( + 'code' => 'test_online', + 'title' => 'shared::payment_methods.test_online', + 'tags' => + array( + 0 => 'access_account_owner', + 1 => 'online', + 2 => 'returnable', + ), + 'image' => + array( + 'src' => 'http://localhost:8000/img/payment_methods/test_online.png', + ), + 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=test_online', + ), + ), + 1 => new PaymentMethodWithPayUrl( + array( + 'code' => 'test_offline', + 'title' => 'shared::payment_methods.test_offline', + 'tags' => + array( + 0 => 'access_account_owner', + 1 => 'returnable', + ), + 'image' => + array( + 'src' => 'http://localhost:8000/img/payment_methods/test_offline.png', + ), + 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=test_offline', + ), + ), + 2 => new PaymentMethodWithPayUrl( + array( + 'code' => 'card', + 'title' => 'Platba kartou', + 'tags' => + array( + 0 => 'card', + 1 => 'online', + 2 => 'pre_authorization', + 3 => 'recurring_payments', + 4 => 'returnable', + ), + 'image' => + array( + 'src' => 'http://localhost:8000/img/payment_methods/card.png', + ), + 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=card', + ), + ), + ); + } + /** * @param Identifier $paymentUid * @return Payment From f8b2eb53919a4e029a3ccaacea20ae5df0c90c78 Mon Sep 17 00:00:00 2001 From: Alex Kratky Date: Tue, 27 Sep 2022 12:12:44 +0200 Subject: [PATCH 2/5] stan fix --- tests/Mocks/Service/ApiMockService.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Mocks/Service/ApiMockService.php b/tests/Mocks/Service/ApiMockService.php index 8b0d3a0..33ad5a2 100644 --- a/tests/Mocks/Service/ApiMockService.php +++ b/tests/Mocks/Service/ApiMockService.php @@ -350,7 +350,7 @@ public function getActivePaymentMethods(LanguageCode $languageCode = null) * * @return array */ - public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languageCode = null) + public function getPaymentUrlsForPayment(Identifier $uid, LanguageCode $languageCode = null) { return array( 0 => new PaymentMethodWithPayUrl( @@ -368,7 +368,7 @@ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languag 'src' => 'http://localhost:8000/img/payment_methods/test_online.png', ), 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=test_online', - ), + ) ), 1 => new PaymentMethodWithPayUrl( array( @@ -384,7 +384,7 @@ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languag 'src' => 'http://localhost:8000/img/payment_methods/test_offline.png', ), 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=test_offline', - ), + ) ), 2 => new PaymentMethodWithPayUrl( array( @@ -403,7 +403,7 @@ public function getPaymentUrlsForPayment(Identifier $uid, ?LanguageCode $languag 'src' => 'http://localhost:8000/img/payment_methods/card.png', ), 'url' => 'http://localhost:8000/' . $uid->__toString() . '/update?payment_method_code=card', - ), + ) ), ); } From 8f6d2017e66af795d3ccf09d0272ee450af492a7 Mon Sep 17 00:00:00 2001 From: Alex Kratky Date: Tue, 27 Sep 2022 13:10:17 +0200 Subject: [PATCH 3/5] doc update --- doc/create-payment.md | 14 ++++++++++++ doc/get-pay-urls-for-existing-payment.md | 22 +++++++++++++++++++ doc/index.md | 27 ++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 doc/get-pay-urls-for-existing-payment.md diff --git a/doc/create-payment.md b/doc/create-payment.md index 64cadcd..bc4eadf 100644 --- a/doc/create-payment.md +++ b/doc/create-payment.md @@ -67,6 +67,20 @@ Payment method buttons should look like this, second image is with hover. ![default](img/payment_method_button.png) ![hover](img/payment_method_button_hover.png) +### Redirect user to gate with payment method selected for already created payment + +Method **getPaymentButtonsForPayment** returns HTML code. + +```php + // used default rendering + $paymentButtons = $client->getPaymentButtonsForPayment($paymentUid); +``` + +Payment method buttons should look like this, second image is with hover. + +![default](img/payment_method_button.png) +![hover](img/payment_method_button_hover.png) + #### Buttons css customization Example of rendered HTML for one button, values with **some** word can dynamically change in HTML rendering. diff --git a/doc/get-pay-urls-for-existing-payment.md b/doc/get-pay-urls-for-existing-payment.md new file mode 100644 index 0000000..b8b86a6 --- /dev/null +++ b/doc/get-pay-urls-for-existing-payment.md @@ -0,0 +1,22 @@ +# Get pay URLs for existing payments + +Returns an array of available payment methods with pay URLs for certain payment. + +```php +/** @var \ThePay\ApiClient\TheClient $client */ +$paymentMethod = $client->getPaymentUrlsForPayment('uid-454548', 'cs'); +``` + +### Preformatted buttons + +Method **getPaymentButtonsForPayment** returns HTML code. + +```php + // used default rendering + $paymentButtons = $client->getPaymentButtonsForPayment($paymentUid); +``` + +Payment method buttons should look like this, second image is with hover. + +![default](img/payment_method_button.png) +![hover](img/payment_method_button_hover.png) \ No newline at end of file diff --git a/doc/index.md b/doc/index.md index 86b2f2a..b33c3c3 100644 --- a/doc/index.md +++ b/doc/index.md @@ -12,6 +12,7 @@ | getPayments | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/get-payments | | getPaymentButtons | | | getPaymentButton | | +| getPaymentButtons | | | createPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/create-new-payment | | realizePreauthorizedPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-preauthorized-payment | | cancelPreauthorizedPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/cancel-preauthorized-payment | @@ -22,6 +23,7 @@ | realizeIrregularSubscriptionPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-irregular-subscription-payment | | realizeUsageBasedSubscriptionPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-usage-based-subscription-payment | | realizePaymentBySavedAuthorization | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-payment-by-saved-authorization | +| getPaymentUrlsForPayment | https://dataapi21.docs.apiary.io/#reference/payment-creation/saved-card-authorization/change-method-for-payment/get-available-payment-methods | ## Usage examples @@ -54,6 +56,8 @@ [Saving authorization](saving-authorization.md) +[Get pay URLs for existing payments](get-pay-urls-for-existing-payment.md) + ## Methods ### getProjects @@ -113,6 +117,18 @@ Returns HTML markup with list of payment buttons. Returns HTML markup with "Pay!" button. +### getPaymentButtonsForPayment + +Returns HTML markup with list of payment buttons for already existing payment. + +#### Parameters + +| name | type | | desc | +| --- | --- | --- | --- | +| $uid | string | required | Payment's UID | +| $languageCode | PaymentMethodFilter | optional | Language code in ISO 6391 (2 chars) format | +| $useInlineAssets | bool | optional | will generate basic css & js | + #### Parameters | name | type | | desc | @@ -234,3 +250,14 @@ Create new payment using saved authorization. | --- | --- | --- | --- | | $uid | string | required | UID of parent payment | | $params | RealizePaymentBySavedAuthorizationParams | required | | + +### getPaymentUrlsForPayment + +Returns an array of available payment methods with pay URLs for certain payment. + +#### Parameters + +| name | type | | description | +| --- | --- | --- | --- | +| $uid | string | required | Payment's UID | +| $languageCode | PaymentMethodFilter | optional | Language code in ISO 6391 (2 chars) format | From 1fb0a06ae8d194daec94ca06eb29250d91fcf1a9 Mon Sep 17 00:00:00 2001 From: Alex Kratky Date: Thu, 29 Sep 2022 09:18:15 +0200 Subject: [PATCH 4/5] fixes --- doc/create-payment.md | 14 -------------- doc/index.md | 6 +++--- src/Model/IPaymentMethod.php | 5 ----- src/TheClient.php | 11 +++++++++-- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/doc/create-payment.md b/doc/create-payment.md index bc4eadf..64cadcd 100644 --- a/doc/create-payment.md +++ b/doc/create-payment.md @@ -67,20 +67,6 @@ Payment method buttons should look like this, second image is with hover. ![default](img/payment_method_button.png) ![hover](img/payment_method_button_hover.png) -### Redirect user to gate with payment method selected for already created payment - -Method **getPaymentButtonsForPayment** returns HTML code. - -```php - // used default rendering - $paymentButtons = $client->getPaymentButtonsForPayment($paymentUid); -``` - -Payment method buttons should look like this, second image is with hover. - -![default](img/payment_method_button.png) -![hover](img/payment_method_button_hover.png) - #### Buttons css customization Example of rendered HTML for one button, values with **some** word can dynamically change in HTML rendering. diff --git a/doc/index.md b/doc/index.md index b33c3c3..08ea24b 100644 --- a/doc/index.md +++ b/doc/index.md @@ -12,7 +12,7 @@ | getPayments | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/get-payments | | getPaymentButtons | | | getPaymentButton | | -| getPaymentButtons | | +| getPaymentButtonsForPayment | | | createPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/create-new-payment | | realizePreauthorizedPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-preauthorized-payment | | cancelPreauthorizedPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/cancel-preauthorized-payment | @@ -23,7 +23,7 @@ | realizeIrregularSubscriptionPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-irregular-subscription-payment | | realizeUsageBasedSubscriptionPayment | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-usage-based-subscription-payment | | realizePaymentBySavedAuthorization | https://dataapi21.docs.apiary.io/#reference/0/project-level-resources/realize-payment-by-saved-authorization | -| getPaymentUrlsForPayment | https://dataapi21.docs.apiary.io/#reference/payment-creation/saved-card-authorization/change-method-for-payment/get-available-payment-methods | +| getPaymentUrlsForPayment | https://dataapi21.docs.apiary.io/#reference/payment-management/general-payment-management/get-available-payment-methods | ## Usage examples @@ -126,7 +126,7 @@ Returns HTML markup with list of payment buttons for already existing payment. | name | type | | desc | | --- | --- | --- | --- | | $uid | string | required | Payment's UID | -| $languageCode | PaymentMethodFilter | optional | Language code in ISO 6391 (2 chars) format | +| $languageCode | string | optional | Language code in ISO 6391 (2 chars) format | | $useInlineAssets | bool | optional | will generate basic css & js | #### Parameters diff --git a/src/Model/IPaymentMethod.php b/src/Model/IPaymentMethod.php index dea4f96..9c77719 100644 --- a/src/Model/IPaymentMethod.php +++ b/src/Model/IPaymentMethod.php @@ -25,9 +25,4 @@ public function getImageUrl(); * @return array */ public function getTags(); - - /** - * @return array - */ - public function toArray(); } diff --git a/src/TheClient.php b/src/TheClient.php index c7ad51d..dae2df4 100644 --- a/src/TheClient.php +++ b/src/TheClient.php @@ -211,15 +211,22 @@ public function getPayments(PaymentsFilter $filter = null, $page = 1, $limit = 2 /** * Returns an array of available payment methods with pay URLs for certain payment. * + * @param string $uid UID of payment, + * @param string|null $languageCode language code in ISO 6391 format * @return array */ - public function getPaymentUrlsForPayment(string $uid) + public function getPaymentUrlsForPayment($uid, $languageCode = null) { $this->validateUid($uid); + $language = null; + if ($languageCode !== null) { + $language = new LanguageCode($languageCode); + } + return $this ->api - ->getPaymentUrlsForPayment(new Identifier($uid)); + ->getPaymentUrlsForPayment(new Identifier($uid), $language); } /** From 54b20f5b082ee7c1b47caf3bda46a3eea84c7cd7 Mon Sep 17 00:00:00 2001 From: Alex Kratky Date: Thu, 29 Sep 2022 09:20:13 +0200 Subject: [PATCH 5/5] fixed typo --- doc/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/index.md b/doc/index.md index 08ea24b..704cd94 100644 --- a/doc/index.md +++ b/doc/index.md @@ -260,4 +260,4 @@ Returns an array of available payment methods with pay URLs for certain payment. | name | type | | description | | --- | --- | --- | --- | | $uid | string | required | Payment's UID | -| $languageCode | PaymentMethodFilter | optional | Language code in ISO 6391 (2 chars) format | +| $languageCode | string | optional | Language code in ISO 6391 (2 chars) format |