Overview

Classes

  • Syspay_Merchant_AstroPayBanksRequest
  • Syspay_Merchant_BillingAgreementCancellationRequest
  • Syspay_Merchant_BillingAgreementInfoRequest
  • Syspay_Merchant_BillingAgreementListRequest
  • Syspay_Merchant_BillingAgreementRequest
  • Syspay_Merchant_ChargebackInfoRequest
  • Syspay_Merchant_ChargebackListRequest
  • Syspay_Merchant_Client
  • Syspay_Merchant_ConfirmRequest
  • Syspay_Merchant_EMS
  • Syspay_Merchant_Entity
  • Syspay_Merchant_Entity_AstroPayBank
  • Syspay_Merchant_Entity_BillingAgreement
  • Syspay_Merchant_Entity_Chargeback
  • Syspay_Merchant_Entity_Creditcard
  • Syspay_Merchant_Entity_Customer
  • Syspay_Merchant_Entity_Eterminal
  • Syspay_Merchant_Entity_Payment
  • Syspay_Merchant_Entity_PaymentMethod
  • Syspay_Merchant_Entity_PaymentRecipient
  • Syspay_Merchant_Entity_Plan
  • Syspay_Merchant_Entity_Refund
  • Syspay_Merchant_Entity_Subscription
  • Syspay_Merchant_Entity_SubscriptionEvent
  • Syspay_Merchant_EterminalRequest
  • Syspay_Merchant_IpAddressesRequest
  • Syspay_Merchant_PaymentInfoRequest
  • Syspay_Merchant_PaymentListRequest
  • Syspay_Merchant_PaymentRequest
  • Syspay_Merchant_PlanInfoRequest
  • Syspay_Merchant_PlanRequest
  • Syspay_Merchant_PlanUpdateRequest
  • Syspay_Merchant_RebillRequest
  • Syspay_Merchant_Redirect
  • Syspay_Merchant_RefundInfoRequest
  • Syspay_Merchant_RefundListRequest
  • Syspay_Merchant_RefundRequest
  • Syspay_Merchant_Request
  • Syspay_Merchant_SubscriptionCancellationRequest
  • Syspay_Merchant_SubscriptionInfoRequest
  • Syspay_Merchant_SubscriptionRebillRequest
  • Syspay_Merchant_SubscriptionRequest
  • Syspay_Merchant_Utils
  • Syspay_Merchant_VoidRequest

Interfaces

  • Syspay_Merchant_Entity_ReturnedEntityInterface

Exceptions

  • Syspay_Merchant_EMSException
  • Syspay_Merchant_RedirectException
  • Syspay_Merchant_RequestException
  • Syspay_Merchant_UnexpectedResponseException
  • Overview
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Process a subscription
  5:  *
  6:  * @see https://app.syspay.com/docs/api/merchant_subscription.html#subscribe-a-customer-to-a-plan-hosted-flow
  7:  * @see https://app.syspay.com/docs/api/merchant_subscription.html#subscribe-a-customer-to-a-plan-server-2-server-flow
  8:  * @see https://app.syspay.com/docs/api/merchant_subscription.html#subscribe-a-customer-to-a-plan-by-re-using-an-existing-subscription-or-billing-agreement
  9:  */
 10: class Syspay_Merchant_SubscriptionRequest extends Syspay_Merchant_Request
 11: {
 12:     const FLOW_API     = 'API';
 13:     const FLOW_BUYER   = 'BUYER';
 14:     const FLOW_SELLER  = 'SELLER';
 15: 
 16:     const METHOD = 'POST';
 17:     const PATH   = '/api/v1/merchant/subscription';
 18: 
 19:     /**
 20:      * @var string
 21:      */
 22:     private $flow;
 23: 
 24:     /**
 25:      * @var Syspay_Merchant_Entity_Subscription
 26:      */
 27:     private $subscription;
 28: 
 29:     /**
 30:      * @var Syspay_Merchant_Entity_Customer
 31:      */
 32:     private $customer;
 33: 
 34:     /**
 35:      * @var string
 36:      */
 37:     private $paymentMethod;
 38: 
 39:     /**
 40:      * @var string
 41:      */
 42:     private $threatMetrixSessionId;
 43: 
 44:     /**
 45:      * @var Syspay_Merchant_Entity_Creditcard
 46:      */
 47:     private $creditcard;
 48: 
 49:     /**
 50:      * @var integer
 51:      */
 52:     private $useSubscription;
 53: 
 54:     /**
 55:      * @var integer
 56:      */
 57:     private $useBillingAgreement;
 58: 
 59:     /**
 60:      * {@inheritDoc}
 61:      */
 62:     public function getMethod()
 63:     {
 64:         return self::METHOD;
 65:     }
 66: 
 67:     /**
 68:      * {@inheritDoc}
 69:      */
 70:     public function getPath()
 71:     {
 72:         return self::PATH;
 73:     }
 74: 
 75:     /**
 76:      * {@inheritDoc}
 77:      */
 78:     public function getData()
 79:     {
 80:         $data = array();
 81:         $data['flow'] = $this->flow;
 82:         $data['subscription'] = $this->subscription->toArray();
 83: 
 84:         if (false === empty($this->customer)) {
 85:             $data['customer'] = $this->customer->toArray();
 86:         }
 87: 
 88:         if (false === empty($this->paymentMethod)) {
 89:             $data['method'] = $this->paymentMethod;
 90:         }
 91: 
 92:         if (false == empty($this->threatMetrixSessionId)) {
 93:             $data['threatmetrix_session_id'] = $this->threatMetrixSessionId;
 94:         }
 95: 
 96:         if (false === empty($this->creditcard)) {
 97:             $data['creditcard'] = $this->creditcard->toArray();
 98:         }
 99: 
100:         if (false === empty($this->useSubscription)) {
101:             $data['use_subscription'] = $this->useSubscription;
102:         }
103: 
104:         if (false === empty($this->useBillingAgreement)) {
105:             $data['use_billing_agreement'] = $this->useBillingAgreement;
106:         }
107: 
108:         return $data;
109:     }
110: 
111:     /**
112:      * {@inheritDoc}
113:      */
114:     public function buildResponse(stdClass $response)
115:     {
116:         if (!isset($response->subscription)) {
117:             throw new Syspay_Merchant_UnexpectedResponseException(
118:                 'Unable to retrieve "subscription" data from response',
119:                 $response
120:             );
121:         }
122: 
123:         $subscription = Syspay_Merchant_Entity_Subscription::buildFromResponse($response->subscription);
124: 
125:         if (isset($response->redirect) && !empty($response->redirect)) {
126:             $subscription->setRedirect($response->redirect);
127:         }
128: 
129:         return $subscription;
130:     }
131: 
132: 
133:     /**
134:      * Gets the value of subscription.
135:      *
136:      * @return Syspay_Merchant_Entity_Subscription
137:      */
138:     public function getSubscription()
139:     {
140:         return $this->subscription;
141:     }
142: 
143:     /**
144:      * Sets the value of subscription.
145:      *
146:      * @param Syspay_Merchant_Entity_Subscription $subscription the subscription
147:      *
148:      * @return self
149:      */
150:     public function setSubscription(Syspay_Merchant_Entity_Subscription $subscription)
151:     {
152:         $this->subscription = $subscription;
153: 
154:         return $this;
155:     }
156: 
157:     /**
158:      * Gets the value of flow.
159:      *
160:      * @return string
161:      */
162:     public function getFlow()
163:     {
164:         return $this->flow;
165:     }
166: 
167:     /**
168:      * Sets the value of flow.
169:      *
170:      * @param string $flow the flow
171:      *
172:      * @return self
173:      */
174:     public function setFlow($flow)
175:     {
176:         $this->flow = $flow;
177: 
178:         return $this;
179:     }
180: 
181:     /**
182:      * Gets the value of customer.
183:      *
184:      * @return Syspay_Merchant_Entity_Customer
185:      */
186:     public function getCustomer()
187:     {
188:         return $this->customer;
189:     }
190: 
191:     /**
192:      * Sets the value of customer.
193:      *
194:      * @param Syspay_Merchant_Entity_Customer $customer the customer
195:      *
196:      * @return self
197:      */
198:     public function setCustomer(Syspay_Merchant_Entity_Customer $customer)
199:     {
200:         $this->customer = $customer;
201: 
202:         return $this;
203:     }
204: 
205:     /**
206:      * Gets the value of paymentMethod.
207:      *
208:      * @return string
209:      */
210:     public function getPaymentMethod()
211:     {
212:         return $this->paymentMethod;
213:     }
214: 
215:     /**
216:      * Sets the value of paymentMethod.
217:      *
218:      * @param string $paymentMethod the payment method
219:      *
220:      * @return self
221:      */
222:     public function setPaymentMethod($paymentMethod)
223:     {
224:         $this->paymentMethod = $paymentMethod;
225: 
226:         return $this;
227:     }
228: 
229:     /**
230:      * Gets the value of threatMetrixSessionId.
231:      *
232:      * @return string
233:      */
234:     public function getThreatMetrixSessionId()
235:     {
236:         return $this->threatMetrixSessionId;
237:     }
238: 
239:     /**
240:      * Sets the value of threatMetrixSessionId.
241:      *
242:      * @param string $threatMetrixSessionId the threat metrix session id
243:      *
244:      * @return self
245:      */
246:     public function setThreatMetrixSessionId($threatMetrixSessionId)
247:     {
248:         $this->threatMetrixSessionId = $threatMetrixSessionId;
249: 
250:         return $this;
251:     }
252: 
253:     /**
254:      * Gets the value of creditcard.
255:      *
256:      * @return Syspay_Merchant_Entity_Creditcard
257:      */
258:     public function getCreditcard()
259:     {
260:         return $this->creditcard;
261:     }
262: 
263:     /**
264:      * Sets the value of creditcard.
265:      *
266:      * @param Syspay_Merchant_Entity_Creditcard $creditcard the creditcard
267:      *
268:      * @return self
269:      */
270:     public function setCreditcard(Syspay_Merchant_Entity_Creditcard $creditcard)
271:     {
272:         $this->creditcard = $creditcard;
273: 
274:         return $this;
275:     }
276: 
277:     /**
278:      * Gets the value of useSubscription.
279:      *
280:      * @return integer
281:      */
282:     public function getUseSubscription()
283:     {
284:         return $this->useSubscription;
285:     }
286: 
287:     /**
288:      * Sets the value of useSubscription.
289:      *
290:      * @param integer $useSubscription the use subscription
291:      *
292:      * @return self
293:      */
294:     public function setUseSubscription($useSubscription)
295:     {
296:         $this->useSubscription = $useSubscription;
297: 
298:         return $this;
299:     }
300: 
301:     /**
302:      * Gets the value of useBillingAgreement.
303:      *
304:      * @return integer
305:      */
306:     public function getUseBillingAgreement()
307:     {
308:         return $this->useBillingAgreement;
309:     }
310: 
311:     /**
312:      * Sets the value of useBillingAgreement.
313:      *
314:      * @param integer $useBillingAgreement the use billing agreement
315:      *
316:      * @return self
317:      */
318:     public function setUseBillingAgreement($useBillingAgreement)
319:     {
320:         $this->useBillingAgreement = $useBillingAgreement;
321: 
322:         return $this;
323:     }
324: }
325: 
Syspay Merchant SDK API documentation generated by ApiGen 2.8.0