Skip to content

Commit 3878249

Browse files
Add trial_end option for CreateSubscription (#182)
1 parent a91faeb commit 3878249

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/Message/CreateSubscriptionRequest.php

+25
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,28 @@ public function getTaxPercent()
4545
return $this->getParameter('tax_percent');
4646
}
4747

48+
49+
/**
50+
* Get the the trial end timestamp
51+
*
52+
* @return int
53+
*/
54+
public function getTrialEnd()
55+
{
56+
return $this->getParameter('trial_end');
57+
}
58+
59+
/**
60+
* Set the trial end timestamp.
61+
*
62+
* @param int $value
63+
* @return \Omnipay\Common\Message\AbstractRequest|CreateSubscriptionRequest
64+
*/
65+
public function setTrialEnd($value)
66+
{
67+
return $this->setParameter('trial_end', $value);
68+
}
69+
4870
/**
4971
* Set the tax percentage
5072
*
@@ -72,6 +94,9 @@ public function getData()
7294
$data['metadata'] = $this->getMetadata();
7395
}
7496

97+
if ($this->getTrialEnd()) {
98+
$data['trial_end'] = $this->getTrialEnd();
99+
}
75100
return $data;
76101
}
77102

src/Message/PaymentIntents/AuthorizeRequest.php

-20
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,6 @@ public function getConfirm()
127127
return $this->getParameter('confirm');
128128
}
129129

130-
/**
131-
* Set the confirm parameter.
132-
*
133-
* @param $value
134-
*/
135-
public function setOffSession($value)
136-
{
137-
$this->setParameter('offSession', $value);
138-
}
139-
140-
/**
141-
* Get the confirm parameter.
142-
*
143-
* @return mixed
144-
*/
145-
public function getOffSession()
146-
{
147-
return $this->getParameter('offSession');
148-
}
149-
150130
/**
151131
* @return mixed
152132
*/

tests/Message/CreateSubscriptionRequestTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function setUp()
1313
{
1414
$this->request = new CreateSubscriptionRequest($this->getHttpClient(), $this->getHttpRequest());
1515
$this->request->setCustomerReference('cus_7lqqgOm33t4xSU');
16+
$this->request->setTrialEnd(1606460031);
1617
$this->request->setPlan('basic');
1718
}
1819

tests/Mock/CreateSubscriptionSuccess.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ Cache-Control: no-cache, no-store
3636
"start": 1453672798,
3737
"status": "active",
3838
"tax_percent": null,
39-
"trial_end": null,
40-
"trial_start": null
41-
}
39+
"trial_end": 1606460031,
40+
"trial_start": 1593241598
41+
}

0 commit comments

Comments
 (0)