Skip to content

Commit

Permalink
Merge pull request #15 from ThePay/v1.x-spring1
Browse files Browse the repository at this point in the history
V1.x spring backup because, v1.x-spring original branch is complete fuck-up
  • Loading branch information
tymajiri authored May 19, 2022
2 parents 43eec4e + 2744e19 commit 3f747a3
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/Model/RealizeIrregularSubscriptionPaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ class RealizeIrregularSubscriptionPaymentParams extends RealizeSubscriptionPayme
* RealizeIrregularSubscriptionPaymentParams constructor.
*
* @param string $uid
* @param string|null $orderId
* @param string|null $descriptionForMerchant
*/
public function __construct($uid)
public function __construct($uid, $orderId = null, $descriptionForMerchant = null)
{
$this->uid = new Identifier($uid);
$this->orderId = $orderId;
$this->descriptionForMerchant = $descriptionForMerchant;
}
}
30 changes: 29 additions & 1 deletion src/Model/RealizePaymentBySavedAuthorizationParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,31 @@ final class RealizePaymentBySavedAuthorizationParams implements SignableRequest
/** @var CurrencyCode|null */
private $currencyCode;

/** @var string|null */
protected $orderId = null;

/** @var string|null */
protected $descriptionForMerchant = null;

/**
* RealizePaymentBySavedAuthorizationParams constructor.
*
* @param string $uid
* @param int|null $amount - payment amount in cents, if set to null it will use amount from parent payment, required if $currencyCode is present
* @param string|null $currencyCode required if $amount is present
* @param string|null $orderId
* @param string|null $descriptionForMerchant
*/
public function __construct($uid, $amount = null, $currencyCode = null)
public function __construct($uid, $amount = null, $currencyCode = null, $orderId = null, $descriptionForMerchant = null)
{
if (($amount === null && $currencyCode !== null) || ($amount !== null && $currencyCode === null)) {
throw new InvalidArgumentException('Amount and currency code is required if one of these parameters have value.');
}
$this->uid = new Identifier($uid);
$this->amount = $amount === null ? null : new Amount($amount);
$this->currencyCode = $currencyCode === null ? null : new CurrencyCode($currencyCode);
$this->orderId = $orderId;
$this->descriptionForMerchant = $descriptionForMerchant;
}

/**
Expand Down Expand Up @@ -70,6 +80,22 @@ public function getCurrencyCode()
return $this->currencyCode;
}

/**
* @return string|null
*/
public function getOrderId()
{
return $this->orderId;
}

/**
* @return string|null
*/
public function getDescriptionForMerchant()
{
return $this->descriptionForMerchant;
}

/**
* If no items will be set, the items from parent payment will be used.
*
Expand All @@ -91,6 +117,8 @@ public function toArray()
$result = array(
'uid' => $this->uid->getValue(),
'items' => null,
'orderId' => $this->orderId,
'descriptionForMerchant' => $this->descriptionForMerchant,
);

if ($this->items) {
Expand Down
6 changes: 5 additions & 1 deletion src/Model/RealizeRegularSubscriptionPaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ class RealizeRegularSubscriptionPaymentParams extends RealizeSubscriptionPayment
* RealizeRegularSubscriptionPaymentParams constructor.
*
* @param string $uid
* @param string|null $orderId
* @param string|null $descriptionForMerchant
*/
public function __construct($uid)
public function __construct($uid, $orderId = null, $descriptionForMerchant = null)
{
$this->uid = new Identifier($uid);
$this->orderId = $orderId;
$this->descriptionForMerchant = $descriptionForMerchant;
}
}
24 changes: 24 additions & 0 deletions src/Model/RealizeSubscriptionPaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ abstract class RealizeSubscriptionPaymentParams implements SignableRequest
/** @var Identifier */
protected $uid;

/** @var string|null */
protected $orderId = null;

/** @var string|null */
protected $descriptionForMerchant = null;

/**
* @return Amount
*/
Expand All @@ -40,6 +46,22 @@ public function getItems()
return $this->items;
}

/**
* @return string|null
*/
public function getOrderId()
{
return $this->orderId;
}

/**
* @return string|null
*/
public function getDescriptionForMerchant()
{
return $this->descriptionForMerchant;
}

/**
* If no items will be set, the items from parent payment will be used.
*
Expand All @@ -61,6 +83,8 @@ public function toArray()
$result = array(
'payment_uid' => $this->uid->getValue(),
'items' => null,
'order_id' => $this->orderId,
'description_for_merchant' => $this->descriptionForMerchant,
);

if ($this->items) {
Expand Down
6 changes: 5 additions & 1 deletion src/Model/RealizeUsageBasedSubscriptionPaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ class RealizeUsageBasedSubscriptionPaymentParams extends RealizeSubscriptionPaym
*
* @param string $uid
* @param int $amount - payment amount in cents
* @param string|null $orderId
* @param string|null $descriptionForMerchant
*/
public function __construct($uid, $amount)
public function __construct($uid, $amount, $orderId = null, $descriptionForMerchant = null)
{
$this->uid = new Identifier($uid);
$this->amount = new Amount($amount);
$this->orderId = $orderId;
$this->descriptionForMerchant = $descriptionForMerchant;
}
}

0 comments on commit 3f747a3

Please sign in to comment.