1: <?php
2:
3: /**
4: * Issue a manual rebill on a subscription
5: *
6: * @see https://app.syspay.com/docs/api/merchant_subscription.html#issue-a-manual-rebill-on-a-subscription
7: */
8: class Syspay_Merchant_SubscriptionRebillRequest extends Syspay_Merchant_Request
9: {
10: const METHOD = 'POST';
11: const PATH = '/api/v1/merchant/subscription/%d/rebill';
12:
13: /**
14: * @var integer
15: */
16: private $subscriptionId;
17:
18: /**
19: * @var string
20: */
21: private $reference;
22:
23: /**
24: * @var integer
25: */
26: private $amount;
27:
28: /**
29: * @var string
30: */
31: private $currency;
32:
33: /**
34: * @var string
35: */
36: private $description;
37:
38: /**
39: * @var string
40: */
41: private $emsUrl;
42:
43: /**
44: * @var string
45: */
46: private $extra;
47:
48: public function __construct($subscriptionId = null)
49: {
50: if (null !== $subscriptionId) {
51: $this->setSubscriptionId($subscriptionId);
52: }
53: }
54:
55: /**
56: * {@inheritDoc}
57: */
58: public function getMethod()
59: {
60: return self::METHOD;
61: }
62:
63: /**
64: * {@inheritDoc}
65: */
66: public function getPath()
67: {
68: return sprintf(self::PATH, $this->subscriptionId);
69: }
70:
71: /**
72: * {@inheritDoc}
73: */
74: public function buildResponse(stdClass $response)
75: {
76: if (!isset($response->payment)) {
77: throw new Syspay_Merchant_UnexpectedResponseException(
78: 'Unable to retrieve "payment" data from response',
79: $response
80: );
81: }
82:
83: $payment = Syspay_Merchant_Entity_Payment::buildFromResponse($response->payment);
84:
85: return $payment;
86: }
87:
88: /**
89: * {@inheritDoc}
90: */
91: public function getData()
92: {
93: $data = array();
94:
95: if (false === empty($this->reference)) {
96: $data['reference'] = $this->reference;
97: }
98:
99: if (false === empty($this->amount)) {
100: $data['amount'] = $this->amount;
101: }
102:
103: if (false === empty($this->currency)) {
104: $data['currency'] = $this->currency;
105: }
106:
107: if (false === empty($this->description)) {
108: $data['description'] = $this->description;
109: }
110:
111: if (false === empty($this->extra)) {
112: $data['extra'] = $this->extra;
113: }
114:
115: if (false === empty($this->emsUrl)) {
116: $data['ems_url'] = $this->emsUrl;
117: }
118:
119: return $data;
120: }
121:
122: /**
123: * Gets the value of subscriptionId.
124: *
125: * @return integer
126: */
127: public function getSubscriptionId()
128: {
129: return $this->subscriptionId;
130: }
131:
132: /**
133: * Sets the value of subscriptionId.
134: *
135: * @param integer $subscriptionId the subscriptionId
136: *
137: * @return self
138: */
139: public function setSubscriptionId($subscriptionId)
140: {
141: $this->subscriptionId = $subscriptionId;
142:
143: return $this;
144: }
145:
146: /**
147: * Gets the value of reference.
148: *
149: * @return string
150: */
151: public function getReference()
152: {
153: return $this->reference;
154: }
155:
156: /**
157: * Sets the value of reference.
158: *
159: * @param string $reference the reference
160: *
161: * @return self
162: */
163: public function setReference($reference)
164: {
165: $this->reference = $reference;
166:
167: return $this;
168: }
169:
170: /**
171: * Gets the value of amount.
172: *
173: * @return integer
174: */
175: public function getAmount()
176: {
177: return $this->amount;
178: }
179:
180: /**
181: * Sets the value of amount.
182: *
183: * @param integer $amount the amount
184: *
185: * @return self
186: */
187: public function setAmount($amount)
188: {
189: $this->amount = $amount;
190:
191: return $this;
192: }
193:
194: /**
195: * Gets the value of currency.
196: *
197: * @return string
198: */
199: public function getCurrency()
200: {
201: return $this->currency;
202: }
203:
204: /**
205: * Sets the value of currency.
206: *
207: * @param string $currency the currency
208: *
209: * @return self
210: */
211: public function setCurrency($currency)
212: {
213: $this->currency = $currency;
214:
215: return $this;
216: }
217:
218: /**
219: * Gets the value of description.
220: *
221: * @return string
222: */
223: public function getDescription()
224: {
225: return $this->description;
226: }
227:
228: /**
229: * Sets the value of description.
230: *
231: * @param string $description the description
232: *
233: * @return self
234: */
235: public function setDescription($description)
236: {
237: $this->description = $description;
238:
239: return $this;
240: }
241:
242: /**
243: * Gets the value of extra.
244: *
245: * @return string
246: */
247: public function getExtra()
248: {
249: return $this->extra;
250: }
251:
252: /**
253: * Sets the value of extra.
254: *
255: * @param string $extra the extra
256: *
257: * @return self
258: */
259: public function setExtra($extra)
260: {
261: $this->extra = $extra;
262:
263: return $this;
264: }
265:
266: /**
267: * Gets the value of emsUrl.
268: *
269: * @return string
270: */
271: public function getEmsUrl()
272: {
273: return $this->emsUrl;
274: }
275:
276: /**
277: * Sets the value of emsUrl.
278: *
279: * @param string $emsUrl the emsUrl
280: *
281: * @return self
282: */
283: public function setEmsUrl($emsUrl)
284: {
285: $this->emsUrl = $emsUrl;
286:
287: return $this;
288: }
289:
290: }
291: