From 2e29c213def690801654237f02d9abbefd435307 Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 14 Nov 2025 19:26:06 +0200 Subject: [PATCH 1/6] TMONE-1055 - Added Make subscription payment, order payment for google/apple pay. --- CHANGELOG.md | 5 ++ composer.json | 2 +- src/API2Client/Api.php | 57 ++++++++++++++++++- src/API2Client/Client/APIResponse.php | 2 +- src/API2Client/Entities/OrderCreated.php | 45 ++++++++++++++- .../Entities/SubscriptionResult.php | 23 +++++++- .../Setters/OrderCreatedFactory.php | 4 +- .../Setters/OrderStatusesFactory.php | 6 +- .../Setters/SubscriptionResultFactory.php | 2 +- 9 files changed, 134 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c02f00..25df27b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. +## [1.2.0] - 2025-11-14 +### Added +- Make subscription payment +- Make order payment + ## [1.1.2] - 2025-04-16 ### Added - added license for order products and subscription diff --git a/composer.json b/composer.json index 04ba499..6ae695b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "templatemonster/api2-client", "description": "TemplateMonster API client", - "version": "1.1.2", + "version": "1.2.0", "license": "Apache License, Version 2.0", "authors": [ { diff --git a/src/API2Client/Api.php b/src/API2Client/Api.php index 7698b72..71b6e27 100644 --- a/src/API2Client/Api.php +++ b/src/API2Client/Api.php @@ -16,6 +16,7 @@ use API2Client\Entities\OrderCreated; use API2Client\Entities\OrderItem; use API2Client\Entities\Subscription; +use API2Client\Entities\SubscriptionResult; use API2Client\Setters\BillingPortalFactory; use API2Client\Setters\CustomerPortalFactory; use API2Client\Setters\OrderCreatedFactory; @@ -341,7 +342,7 @@ public function createPaymentSubscription(Subscription $subscription) /** * @param $id - * @return Entities\SubscriptionCreated + * @return Entities\SubscriptionResult * @throws ApiException */ public function cancelPaymentSubscription($id) @@ -471,4 +472,58 @@ public function getTransactionStatusUrl($transactionId) $factory = new BillingPortalFactory(); return $factory->create($response->getResult()); } + + /** + * Make subscription payment + * + * @param string $subscriptionId + * @param string $paymentMethodId + * @param string $b_token + * @return array + * @throws ApiException + */ + public function makeSubscriptionPayment($subscriptionId, $paymentMethodId, $b_token) + { + $response = $this + ->client + ->call('orders.makeSubscribePayment', array( + 'subscription_id' => $subscriptionId, + 'payment_method_id' => $paymentMethodId, + 'b_token' => $b_token + ), HttpClient::REQUEST_RAW); + + if (!$response->isSuccess()) { + throw new ApiException ($response->getErrorMessage()); + } + + return $response->getResult(); + } + + /** + * Make order payment + * + * @param string $orderId + * @param string $paymentMethodId + * @param string $b_token + * @return array + * @throws ApiException + */ + public function makeOrderPayment($orderId, $paymentMethodId, $b_token) + { + $response = $this + ->client + ->call('orders.makeOrderPayment', array( + 'order_id' => $orderId, + 'payment_method_id' => $paymentMethodId, + 'b_token' => $b_token + ), HttpClient::REQUEST_RAW); + + if (!$response->isSuccess()) { + throw new ApiException ($response->getErrorMessage()); + } + + return $response->getResult(); + } + + } diff --git a/src/API2Client/Client/APIResponse.php b/src/API2Client/Client/APIResponse.php index 00da651..ff0f99c 100644 --- a/src/API2Client/Client/APIResponse.php +++ b/src/API2Client/Client/APIResponse.php @@ -83,4 +83,4 @@ public function getErrorMessage () return ''; } -} \ No newline at end of file +} diff --git a/src/API2Client/Entities/OrderCreated.php b/src/API2Client/Entities/OrderCreated.php index fc4048e..b853c80 100644 --- a/src/API2Client/Entities/OrderCreated.php +++ b/src/API2Client/Entities/OrderCreated.php @@ -44,9 +44,13 @@ class OrderCreated protected $status; protected $paymentReference; - + protected $paymentToken; + protected $transactionId; + + protected $b_token; + /** * @param string $customerId */ @@ -175,6 +179,41 @@ public function setPaymentToken($paymentToken) $this->paymentToken = $paymentToken; } + /** + * @return mixed + */ + public function getBToken() + { + return $this->b_token; + } + + /** + * @param mixed $b_token + */ + public function setBToken($b_token) + { + $this->b_token = $b_token; + } + + /** + * @return mixed + */ + public function getTransactionId() + { + return $this->transactionId; + } + + /** + * @param mixed $transactionId + */ + public function setTransactionId($transactionId) + { + $this->transactionId = $transactionId; + } + + + + public function toArray() { return array( 'customerId' => $this->getCustomerId(), @@ -185,6 +224,8 @@ public function toArray() { 'status' => $this->getStatus (), 'payment_reference' => $this->getPaymentReference(), 'payment_token' => $this->getPaymentToken(), + 'transactionId' => $this->getTransactionId(), + 'b_token' => $this->getBToken(), ); } -} \ No newline at end of file +} diff --git a/src/API2Client/Entities/SubscriptionResult.php b/src/API2Client/Entities/SubscriptionResult.php index e734827..e2828bf 100644 --- a/src/API2Client/Entities/SubscriptionResult.php +++ b/src/API2Client/Entities/SubscriptionResult.php @@ -25,9 +25,11 @@ class SubscriptionResult private $messages = array(); private $payment_reference; - + private $client_secret; + private $b_token; + /** * @return mixed */ @@ -128,4 +130,21 @@ public function setClientSecret($client_secret) return $this; } -} \ No newline at end of file + /** + * @return mixed + */ + public function getBToken() + { + return $this->b_token; + } + + /** + * @param mixed $b_token + */ + public function setBToken($b_token) + { + $this->b_token = $b_token; + } + + +} diff --git a/src/API2Client/Setters/OrderCreatedFactory.php b/src/API2Client/Setters/OrderCreatedFactory.php index c0e1c06..50cd47f 100644 --- a/src/API2Client/Setters/OrderCreatedFactory.php +++ b/src/API2Client/Setters/OrderCreatedFactory.php @@ -31,7 +31,9 @@ public function create ($data) $orderCreated->setStatus ($this->getValue ('status', $data, '')); $orderCreated->setPaymentReference($this->getValue ('payment_reference', $data, '')); $orderCreated->setPaymentToken($this->getValue ('payment_token', $data, '')); + $orderCreated->setTransactionId($this->getValue ('transactionId', $data, '')); + $orderCreated->setBToken($this->getValue ('b_token', $data, '')); return $orderCreated; } -} \ No newline at end of file +} diff --git a/src/API2Client/Setters/OrderStatusesFactory.php b/src/API2Client/Setters/OrderStatusesFactory.php index 601ab23..aac3717 100644 --- a/src/API2Client/Setters/OrderStatusesFactory.php +++ b/src/API2Client/Setters/OrderStatusesFactory.php @@ -17,11 +17,11 @@ class OrderStatusesFactory extends FactoryAbstract implements FactoryInterface { /** * @param array $data - * @return Status + * @return array */ public function create ($data) { - $statusesArrayList = []; + $statusesArrayList = array(); foreach ($data as $status) { @@ -36,4 +36,4 @@ public function create ($data) return $statusesArrayList; } -} \ No newline at end of file +} diff --git a/src/API2Client/Setters/SubscriptionResultFactory.php b/src/API2Client/Setters/SubscriptionResultFactory.php index db7c061..dc6a726 100644 --- a/src/API2Client/Setters/SubscriptionResultFactory.php +++ b/src/API2Client/Setters/SubscriptionResultFactory.php @@ -21,6 +21,7 @@ public function create ($data) $created->setPaymentReference ($this->getValue ('payment_reference', $data, '')); $created->setClientSecret ($this->getValue ('client_secret', $data, '')); $created->setStatus ($this->getValue ('status', $data, false)); + $created->setBToken($this->getValue ('b_token', $data, '')); $dataSubscription = $this->getValue ('subscription', $data, array ()); @@ -37,7 +38,6 @@ public function create ($data) $created->setMessages ($messages); } - return $created; } From c28495b8204d3fc05a4553d9c7278d43e7b76064 Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 14 Nov 2025 19:36:59 +0200 Subject: [PATCH 2/6] TMONE-1055 - Added Make subscription payment, order payment for google/apple pay. --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index 6ae695b..ebdef9e 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,10 @@ { "name": "kolomiets", "email": "kolomiets.dev@gmail.com" + }, + { + "name": "Pavlo Titkov", + "email": "ptitkov@gmail.com" } ], "minimum-stability": "dev", From 82e09841ab833b58cfc39d9d033aff56946385db Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 14 Nov 2025 19:40:36 +0200 Subject: [PATCH 3/6] TMONE-1055 - Added Make subscription payment, order payment for google/apple pay. --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ebdef9e..e101dcb 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,7 @@ { "name": "templatemonster/api2-client", "description": "TemplateMonster API client", - "version": "1.2.0", - "license": "Apache License, Version 2.0", + "version": "1.2.0-pre", "authors": [ { "name": "kolomiets", From 94e0d03a18eae462040cee0012945090c5620ebe Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 14 Nov 2025 19:48:49 +0200 Subject: [PATCH 4/6] TMONE-1055 - Added Make subscription payment, order payment for google/apple pay. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3daa42b..e6e33de 100644 --- a/README.md +++ b/README.md @@ -272,5 +272,5 @@ catch (\API2Client\Client\APIException $e) [CHANGELOG]: ./CHANGELOG.md -[version-badge]: https://img.shields.io/badge/version-1.1.2-green.svg +[version-badge]: https://img.shields.io/badge/version-1.2.0-green.svg [php-version]:https://img.shields.io/static/v1?label=php&message=>=5.3&color=green From 534c6a2dbd45e8428a16ac45200edb32734c2efe Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 30 Jan 2026 12:30:27 +0200 Subject: [PATCH 5/6] TMONE-1151 - Added trackers parameter to create subscription. --- CHANGELOG.md | 1 + composer.json | 2 +- src/API2Client/Entities/Subscription.php | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25df27b..c82f7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. ### Added - Make subscription payment - Make order payment +- trackers parameter to create subscription ## [1.1.2] - 2025-04-16 ### Added diff --git a/composer.json b/composer.json index e101dcb..7fabe0c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "templatemonster/api2-client", "description": "TemplateMonster API client", - "version": "1.2.0-pre", + "version": "1.2.0-pre1", "authors": [ { "name": "kolomiets", diff --git a/src/API2Client/Entities/Subscription.php b/src/API2Client/Entities/Subscription.php index ca13480..d41505a 100644 --- a/src/API2Client/Entities/Subscription.php +++ b/src/API2Client/Entities/Subscription.php @@ -163,6 +163,11 @@ class Subscription /** @var string */ protected $customerId; + /** + * @var array + */ + protected $trackers; + /** * @return string */ @@ -708,6 +713,22 @@ public function setCustomerId($customerId) return $this; } + /** + * @return array + */ + public function getTrackers() + { + return $this->trackers; + } + + /** + * @param array $trackers + */ + public function setTrackers($trackers) + { + $this->trackers = $trackers; + } + /** * @return array @@ -743,6 +764,7 @@ public function toArray() 'customer_id' => $this->getCustomerId(), 'discountInfoList' => array(), 'productInfoList' => array(), + 'trackers' => $this->getTrackers(), ); foreach ($this->getProductInfoList() as $productInfo) { From fea8c6c07c5e9935f9a701f5d4b205dfbf05c239 Mon Sep 17 00:00:00 2001 From: ch Date: Fri, 30 Jan 2026 14:29:32 +0200 Subject: [PATCH 6/6] TMONE-1151 - Added metadata parameter to create subscription. --- CHANGELOG.md | 1 + src/API2Client/Entities/Order.php | 25 +++++++++++++++++++++++- src/API2Client/Entities/Subscription.php | 22 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c82f7b8..d6efac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. - Make subscription payment - Make order payment - trackers parameter to create subscription +- metadata parameter to create subscription ## [1.1.2] - 2025-04-16 ### Added diff --git a/src/API2Client/Entities/Order.php b/src/API2Client/Entities/Order.php index 39f02dd..8bfbfe2 100644 --- a/src/API2Client/Entities/Order.php +++ b/src/API2Client/Entities/Order.php @@ -74,6 +74,11 @@ class Order */ protected $cartId; + /** + * @var array + */ + protected $metadata; + /** * @param float $amount */ @@ -250,7 +255,8 @@ public function toArray() 'trackingInfo' => $this->getTrackingInfo()->toArray(), 'discountInfoList' => array(), 'payment_options' => $this->getPaymentOptions(), - 'cartId' => $this->getCartId() + 'cartId' => $this->getCartId(), + 'metadata' => $this->getMetadata() ); $data['productInfoList'] = array(); @@ -305,4 +311,21 @@ public function getCartId() { return $this->cartId; } + + /** + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * @param array $metadata + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + } + } diff --git a/src/API2Client/Entities/Subscription.php b/src/API2Client/Entities/Subscription.php index d41505a..3ee0e0b 100644 --- a/src/API2Client/Entities/Subscription.php +++ b/src/API2Client/Entities/Subscription.php @@ -168,6 +168,11 @@ class Subscription */ protected $trackers; + /** + * @var array + */ + protected $metadata; + /** * @return string */ @@ -729,6 +734,22 @@ public function setTrackers($trackers) $this->trackers = $trackers; } + /** + * @return array + */ + public function getMetadata() + { + return $this->metadata; + } + + /** + * @param array $metadata + */ + public function setMetadata($metadata) + { + $this->metadata = $metadata; + } + /** * @return array @@ -765,6 +786,7 @@ public function toArray() 'discountInfoList' => array(), 'productInfoList' => array(), 'trackers' => $this->getTrackers(), + 'metadata' => $this->getMetadata(), ); foreach ($this->getProductInfoList() as $productInfo) {