Skip to content

Commit

Permalink
Merge pull request #21 from Plasma-Platform/feature/TMONE-894/checkout
Browse files Browse the repository at this point in the history
TMONE-894 - Add discounts and products list in subscriptions
  • Loading branch information
dimanovoseltsev authored Feb 6, 2025
2 parents b10a280 + 7038ee5 commit aefdede
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 115 deletions.
42 changes: 42 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Changelog

All notable changes to this project will be documented in this file.

## [1.1.0] - 2025-02-07
### Added
- Add parameters discounts, products and cartId list in subscriptions

## [1.0.9] - 2025-02-06
### Added
- Add trackers

## [1.0.8] - 2025-02-05
### Added
- Add membership and support products for order

## [1.0.7] - 2024-04-11
### Added
- Billing portal links

## [1.0.6] - 2022-10-14
### Added
- Get customer management portal link

## [1.0.5] - 2022-02-14
### Added
- Added cancel order

## [1.0.4] - 2021-10-06
### Added
- Google & Apple pay.

## [1.0.3] - 2020-05-09
### Fixed
- fix screenshots

## [1.0.0] - 2019-02-19
### Added
- Payment Subscriptions

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
TemplateMonster API2 Client
===========================

[![version][version-badge]][CHANGELOG] ![php-version]

Installation
------------

Expand Down Expand Up @@ -267,3 +269,8 @@ catch (\API2Client\Client\APIException $e)
}

```

[CHANGELOG]: ./CHANGELOG.md

[version-badge]: https://img.shields.io/badge/version-1.1.0-green.svg
[php-version]:https://img.shields.io/static/v1?label=php&message=>=5.3&color=green
43 changes: 23 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"name": "templatemonster/api2-client",
"description": "TemplateMonster API client",
"license": "Apache License, Version 2.0",
"authors": [
{
"name": "kolomiets",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
"NewRelic": "src/"
},
"classmap": [
"./"
]
"name": "templatemonster/api2-client",
"description": "TemplateMonster API client",
"version": "1.1.0",
"license": "Apache License, Version 2.0",
"authors": [
{
"name": "kolomiets",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"php": ">=5.3.0",
"ext-curl": "*",
"ext-json": "*"
},
"autoload": {
"psr-0": {
"NewRelic": "src/"
},
"classmap": [
"./"
]
}
}
121 changes: 69 additions & 52 deletions src/API2Client/Entities/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,201 +69,204 @@ class Order
*/
protected $paymentOptions;

/**
* @var string
*/
protected $cartId;

/**
* @param float $amount
*/
public function setAmount ($amount)
public function setAmount($amount)
{
$this->amount = $amount;
}

/**
* @return float
*/
public function getAmount ()
public function getAmount()
{
return $this->amount;
}

/**
* @param \API2Client\Entities\Order\BillingInfo $billingInfo
* @param BillingInfo $billingInfo
*/
public function setBillingInfo (BillingInfo $billingInfo)
public function setBillingInfo(BillingInfo $billingInfo)
{
$this->billingInfo = $billingInfo;
}

/**
* @return \API2Client\Entities\Order\BillingInfo
* @return BillingInfo
*/
public function getBillingInfo ()
public function getBillingInfo()
{
return $this->billingInfo ? $this->billingInfo : new BillingInfo ();
return $this->billingInfo ? $this->billingInfo : new BillingInfo();
}

/**
* @param float $bonusesAmount
*/
public function setBonusesAmount ($bonusesAmount)
public function setBonusesAmount($bonusesAmount)
{
$this->bonusesAmount = $bonusesAmount;
}

/**
* @return float
*/
public function getBonusesAmount ()
public function getBonusesAmount()
{
return $this->bonusesAmount;
}

/**
* @param $discountInfo
*/
public function addDiscountInfo ($discountInfo)
public function addDiscountInfo($discountInfo)
{
$this->discountInfoList [] = $discountInfo;
}

/**
* @return array
*/
public function getDiscountInfoList ()
public function getDiscountInfoList()
{
return $this->discountInfoList;
}

/**
* @param \API2Client\Entities\Order\PaymentInfo $paymentInfo
* @param PaymentInfo $paymentInfo
*/
public function setPaymentInfo ($paymentInfo)
public function setPaymentInfo($paymentInfo)
{
$this->paymentInfo = $paymentInfo;
}

/**
* @return \API2Client\Entities\Order\PaymentInfo
* @return PaymentInfo
*/
public function getPaymentInfo ()
public function getPaymentInfo()
{
return $this->paymentInfo;
}

/**
* @param ProductInfo $productInfo
*/
public function addProductInfo (ProductInfo $productInfo)
public function addProductInfo(ProductInfo $productInfo)
{
$this->productInfoList[] = $productInfo;
}

/**
* @return array
*/
public function getProductInfoList ()
public function getProductInfoList()
{
return $this->productInfoList;
}

/**
* @param int $projectId
*/
public function setProjectId ($projectId)
public function setProjectId($projectId)
{
$this->projectId = $projectId;
}

/**
* @return float
*/
public function getProjectId ()
public function getProjectId()
{
return $this->projectId;
}

/**
* @param mixed TrackingInfo $trackingInfo
*/
public function setTrackingInfo (TrackingInfo $trackingInfo)
public function setTrackingInfo(TrackingInfo $trackingInfo)
{
$this->trackingInfo = $trackingInfo;
}

/**
* @return TrackingInfo
*/
public function getTrackingInfo ()
public function getTrackingInfo()
{
return $this->trackingInfo ? $this->trackingInfo : new TrackingInfo ();
}

/**
* @return boolean
*/
public function isGift ()
public function isGift()
{
return $this->gift;
}

/**
* @param boolean $gift
*/
public function setGift ($gift)
public function setGift($gift)
{
$this->gift = $gift;
}

/**
* @return array
*/
protected function getPaymentWithGift ()
protected function getPaymentWithGift()
{
if ($this->isGift () === true)
{
if ($this->isGift() === true) {
$paymentData = new PaymentInfo ();

return $paymentData
->setCurrencyId (0)
->setCurrencyRate (1)
->setPaymentId (Payment::GIFT_METHOD)
->toArray ();
->setCurrencyId(0)
->setCurrencyRate(1)
->setPaymentId(Payment::GIFT_METHOD)
->toArray();
}

return $this->getPaymentInfo ()->toArray ();
return $this->getPaymentInfo()->toArray();
}

/**
* @return array
*/
public function toArray ()
public function toArray()
{
$data = array(
'projectId' => $this->getProjectId (),
'amount' => $this->getAmount (),
'bonusesAmount' => $this->getBonusesAmount (),
'billingInfo' => $this->getBillingInfo ()->toArray (),
'paymentInfo' => $this->getPaymentWithGift (),
'trackingInfo' => $this->getTrackingInfo ()->toArray (),
'discountInfoList' => array (),
'payment_options' => $this->getPaymentOptions(),
$data = array(
'projectId' => $this->getProjectId(),
'amount' => $this->getAmount(),
'bonusesAmount' => $this->getBonusesAmount(),
'billingInfo' => $this->getBillingInfo()->toArray(),
'paymentInfo' => $this->getPaymentWithGift(),
'trackingInfo' => $this->getTrackingInfo()->toArray(),
'discountInfoList' => array(),
'payment_options' => $this->getPaymentOptions(),
'cartId' => $this->getCartId()
);

$data['productInfoList'] = array ();
$data['productInfoList'] = array();

/**
* @var ProductInfo $productInfo
*/
foreach ($this->getProductInfoList () as $productInfo)
{
$data['productInfoList'][] = $productInfo->toArray ();
foreach ($this->getProductInfoList() as $productInfo) {
$data['productInfoList'][] = $productInfo->toArray();
}

$discountList = array ();
$discountList = array();

/** @var DiscountInfo $discount */
foreach ($this->getDiscountInfoList () as $discount)
{
$discountList = array_merge ($discountList, $discount->toArray ());
foreach ($this->getDiscountInfoList() as $discount) {
$discountList = array_merge($discountList, $discount->toArray());
}

$data['discountInfoList'] = $discountList;
Expand All @@ -286,6 +289,20 @@ public function setPaymentOptions($paymentOptions)
{
$this->paymentOptions = $paymentOptions;
}


}

/**
* @param string $cartId
*/
public function setCartId($cartId)
{
$this->cartId = $cartId;
}

/**
* @return string
*/
public function getCartId()
{
return $this->cartId;
}
}
Loading

0 comments on commit aefdede

Please sign in to comment.