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 payment
  5:  *
  6:  * @see https://app.syspay.com/bundles/emiuser/doc/merchant_api.html#hosted-payment-request
  7:  * @see https://app.syspay.com/bundles/emiuser/doc/merchant_api.html#server-to-server-credit-card-payment
  8:  */
  9: class Syspay_Merchant_PaymentRequest extends Syspay_Merchant_Request
 10: {
 11:     const FLOW_API     = 'API';
 12:     const FLOW_BUYER   = 'BUYER';
 13:     const FLOW_SELLER  = 'SELLER';
 14: 
 15:     const MODE_BOTH     = 'BOTH';
 16:     const MODE_ONLINE   = 'ONLINE';
 17:     const MODE_TERMINAL = 'TERMINAL';
 18: 
 19:     const METHOD_ASTROPAY_BANKTRANSFER   = 'ASTROPAY_BANKTRANSFER';
 20:     const METHOD_ASTROPAY_BOLETOBANCARIO = 'ASTROPAY_BOLETOBANCARIO';
 21:     const METHOD_ASTROPAY_DEBITCARD      = 'ASTROPAY_DEBITCARD';
 22:     const METHOD_CLICKANDBUY             = 'CLICKANDBUY';
 23:     const METHOD_CREDITCARD              = 'CREDITCARD';
 24:     const METHOD_IDEAL                   = 'IDEAL';
 25:     const METHOD_PAYSAFECARD             = 'PAYSAFECARD';
 26:     const METHOD_POSTFINANCE             = 'POSTFINANCE';
 27: 
 28:     const METHOD = 'POST';
 29:     const PATH   = '/api/v1/merchant/payment';
 30: 
 31:     /**
 32:      * @var string
 33:      */
 34:     private $flow;
 35:     /**
 36:      * @var string
 37:      */
 38:     private $mode;
 39: 
 40:     /**
 41:      * @var string
 42:      */
 43:     private $paymentMethod;
 44: 
 45: 
 46:     /**
 47:      * @var string
 48:      */
 49:     private $threatMetrixSessionId;
 50: 
 51:     /**
 52:      * @var boolean
 53:      */
 54:     private $billingAgreement = false;
 55: 
 56:     /**
 57:      * @var string
 58:      */
 59:     private $emsUrl;
 60: 
 61:     /**
 62:      * @var string
 63:      */
 64:     private $redirectUrl;
 65: 
 66:     /**
 67:      * @var string
 68:      */
 69:     private $website;
 70: 
 71:     /**
 72:      * @var string
 73:      */
 74:     private $agent;
 75: 
 76:     /**
 77:      * @var integer
 78:      */
 79:     private $allowedRetries;
 80: 
 81:     /**
 82:      * @var Syspay_Merchant_Entity_Payment
 83:      */
 84:     private $payment;
 85: 
 86:     /**
 87:      * @var Syspay_Merchant_Entity_Customer
 88:      */
 89:     private $customer;
 90: 
 91:     /**
 92:      * @var Syspay_Merchant_Entity_Creditcard
 93:      */
 94:     private $creditcard;
 95: 
 96:     /**
 97:      * @var array
 98:      */
 99:     private $notify;
100: 
101:     /**
102:      * @var string
103:      */
104:     private $bankCode;
105: 
106:     /**
107:      * Construct
108:      *
109:      * @param string $flow
110:      */
111:     public function __construct($flow)
112:     {
113:         if (!in_array($flow, array(self::FLOW_API, self::FLOW_BUYER, self::FLOW_SELLER))) {
114:             throw new InvalidArgumentException('Invalid flow: ' . $flow);
115:         }
116: 
117:         $this->flow = $flow;
118:     }
119: 
120:     /**
121:      * {@inheritDoc}
122:      */
123:     public function getMethod()
124:     {
125:         return self::METHOD;
126:     }
127: 
128:     /**
129:      * {@inheritDoc}
130:      */
131:     public function getPath()
132:     {
133:         return self::PATH;
134:     }
135: 
136:     /**
137:      * {@inheritDoc}
138:      */
139:     public function buildResponse(stdClass $response)
140:     {
141:         if (!isset($response->payment)) {
142:             throw new Syspay_Merchant_UnexpectedResponseException(
143:                 'Unable to retrieve "payment" data from response',
144:                 $response
145:             );
146:         }
147: 
148:         $payment = Syspay_Merchant_Entity_Payment::buildFromResponse($response->payment);
149: 
150:         if (isset($response->redirect) && !empty($response->redirect)) {
151:             $payment->setRedirect($response->redirect);
152:         }
153: 
154:         return $payment;
155:     }
156: 
157:     /**
158:      * {@inheritDoc}
159:      */
160:     public function getData()
161:     {
162:         $data = array();
163:         $data['flow'] = $this->flow;
164: 
165:         if (false === empty($this->billingAgreement)) {
166:             $data['billing_agreement'] = $this->billingAgreement?1:0;
167:         }
168: 
169:         if (false === empty($this->mode)) {
170:             $data['mode'] = $this->mode;
171:         }
172: 
173:         if (false == empty($this->threatMetrixSessionId)) {
174:             $data['threatmetrix_session_id'] = $this->threatMetrixSessionId;
175:         }
176: 
177:         if (false === empty($this->paymentMethod)) {
178:             $data['method'] = $this->paymentMethod;
179:         }
180: 
181:         if (false === empty($this->website)) {
182:             $data['website'] = intval($this->website);
183:         }
184: 
185:         if (false === empty($this->agent)) {
186:             $data['agent'] = intval($this->agent);
187:         }
188: 
189: 
190:         if (false === empty($this->redirectUrl)) {
191:             $data['redirect_url'] = $this->redirectUrl;
192:         }
193: 
194:         if (false === empty($this->emsUrl)) {
195:             $data['ems_url'] = $this->emsUrl;
196:         }
197: 
198:         if (false === empty($this->creditcard)) {
199:             $data['creditcard'] = $this->creditcard->toArray();
200:         }
201: 
202:         if (false === empty($this->customer)) {
203:             $data['customer'] = (array) $this->customer->toArray();
204:         }
205: 
206:         if (false === empty($this->payment)) {
207:             $data['payment'] = (array) $this->payment->toArray();
208:         }
209: 
210:         if (false === empty($this->allowedRetries)) {
211:             $data['allowed_retries'] = intval($this->allowedRetries);
212:         }
213: 
214:         if (false === empty($this->notify)) {
215:             $data['notify'] = $this->notify;
216:         }
217: 
218:         if (false === empty($this->bankCode)) {
219:             $data['bank_code'] = $this->bankCode;
220:         }
221: 
222:         return $data;
223:     }
224: 
225:     /**
226:      * Gets the value of flow.
227:      *
228:      * @return string
229:      */
230:     public function getFlow()
231:     {
232:         return $this->flow;
233:     }
234: 
235:     /**
236:      * Sets the value of flow.
237:      *
238:      * @param string $flow the flow
239:      *
240:      * @return self
241:      */
242:     public function setFlow($flow)
243:     {
244:         $this->flow = $flow;
245: 
246:         return $this;
247:     }
248: 
249:     /**
250:      * Get the value of mode
251:      *
252:      * @return string
253:      */
254:     public function getMode()
255:     {
256:         return $this->mode;
257:     }
258:     /**
259:      * Sets the value of mode
260:      *
261:      * @param string $mode
262:      *
263:      * @return self
264:      */
265:     public function setMode($mode)
266:     {
267:         $this->mode = $mode;
268: 
269:         return $this;
270:     }
271: 
272:     /**
273:      * Sets the value of threatMetrixSessionId
274:      *
275:      * @param string $threatMetrixSessionId
276:      *
277:      * @return self
278:      */
279:     public function setThreatMetrixSessionId($threatMetrixSessionId)
280:     {
281:         $this->threatMetrixSessionId = $threatMetrixSessionId;
282: 
283:         return $this;
284:     }
285: 
286:     /**
287:      * Get the value of threatMetrixSessionId
288:      *
289:      * @return string
290:      */
291:     public function getThreatMetrixSessionId()
292:     {
293:         return $this->threatMetrixSessionId;
294:     }
295: 
296: 
297:     /**
298:      * Gets the value of billingAgreement.
299:      *
300:      * @return boolean
301:      */
302:     public function getBillingAgreement()
303:     {
304:         return $this->billingAgreement;
305:     }
306: 
307:     /**
308:      * Sets the value of billingAgreement.
309:      *
310:      * @param boolean $billingAgreement the billingAgreement
311:      *
312:      * @return self
313:      */
314:     public function setBillingAgreement($billingAgreement)
315:     {
316:         $this->billingAgreement = $billingAgreement;
317: 
318:         return $this;
319:     }
320: 
321:     /**
322:      * Gets the value of emsUrl.
323:      *
324:      * @return string
325:      */
326:     public function getEmsUrl()
327:     {
328:         return $this->emsUrl;
329:     }
330: 
331:     /**
332:      * Sets the value of emsUrl.
333:      *
334:      * @param string $emsUrl the emsUrl
335:      *
336:      * @return self
337:      */
338:     public function setEmsUrl($emsUrl)
339:     {
340:         $this->emsUrl = $emsUrl;
341: 
342:         return $this;
343:     }
344: 
345:     /**
346:      * Gets the value of redirectUrl.
347:      *
348:      * @return string
349:      */
350:     public function getRedirectUrl()
351:     {
352:         return $this->redirectUrl;
353:     }
354: 
355:     /**
356:      * Sets the value of redirectUrl.
357:      *
358:      * @param string $redirectUrl the redirectUrl
359:      *
360:      * @return self
361:      */
362:     public function setRedirectUrl($redirectUrl)
363:     {
364:         $this->redirectUrl = $redirectUrl;
365: 
366:         return $this;
367:     }
368: 
369:     /**
370:      * Gets the value of payment.
371:      *
372:      * @return Syspay_Merchant_Entity_Payment
373:      */
374:     public function getPayment()
375:     {
376:         return $this->payment;
377:     }
378: 
379:     /**
380:      * Sets the value of payment.
381:      *
382:      * @param Syspay_Merchant_Entity_Payment $payment the payment
383:      *
384:      * @return self
385:      */
386:     public function setPayment(Syspay_Merchant_Entity_Payment $payment)
387:     {
388:         $this->payment = $payment;
389: 
390:         return $this;
391:     }
392: 
393:     /**
394:      * Gets the value of customer.
395:      *
396:      * @return Syspay_Merchant_Entity_Customer
397:      */
398:     public function getCustomer()
399:     {
400:         return $this->customer;
401:     }
402: 
403:     /**
404:      * Sets the value of customer.
405:      *
406:      * @param Syspay_Merchant_Entity_Customer $customer the customer
407:      *
408:      * @return self
409:      */
410:     public function setCustomer(Syspay_Merchant_Entity_Customer $customer)
411:     {
412:         $this->customer = $customer;
413: 
414:         return $this;
415:     }
416: 
417:     /**
418:      * Gets the value of creditcard.
419:      *
420:      * @return Syspay_Merchant_Entity_Creditcard
421:      */
422:     public function getCreditcard()
423:     {
424:         return $this->creditcard;
425:     }
426: 
427:     /**
428:      * Sets the value of creditcard.
429:      *
430:      * @param Syspay_Merchant_Entity_Creditcard $creditcard the creditcard
431:      *
432:      * @return self
433:      */
434:     public function setCreditcard(Syspay_Merchant_Entity_Creditcard $creditcard)
435:     {
436:         $this->creditcard = $creditcard;
437: 
438:         return $this;
439:     }
440: 
441:     /**
442:      * Gets the value of paymentMethod.
443:      *
444:      * @return string
445:      */
446:     public function getPaymentMethod()
447:     {
448:         return $this->paymentMethod;
449:     }
450: 
451:     /**
452:      * Sets the value of paymentMethod.
453:      *
454:      * @param string $paymentMethod the paymentMethod
455:      *
456:      * @return self
457:      */
458:     public function setPaymentMethod($paymentMethod)
459:     {
460:         $this->paymentMethod = $paymentMethod;
461: 
462:         return $this;
463:     }
464: 
465:     /**
466:      * Gets the value of website.
467:      *
468:      * @return string
469:      */
470:     public function getWebsite()
471:     {
472:         return $this->website;
473:     }
474: 
475:     /**
476:      * Sets the value of website.
477:      *
478:      * @param string $website the website
479:      *
480:      * @return self
481:      */
482:     public function setWebsite($website)
483:     {
484:         $this->website = $website;
485: 
486:         return $this;
487:     }
488: 
489:     /**
490:      * Gets the agent
491:      * @return string
492:      */
493:     public function getAgent()
494:     {
495:         return $this->agent;
496:     }
497: 
498:     /**
499:      * Sets the value of agent.
500:      *
501:      * @param string $agent the agent id
502:      *
503:      * @return self
504:      */
505:     public function setAgent($agent)
506:     {
507:         $this->agent = $agent;
508: 
509:         return $this;
510:     }
511: 
512:     /**
513:      * Gets the value of allowedRetries.
514:      *
515:      * @return integer
516:      */
517:     public function getAllowedRetries()
518:     {
519:         return $this->allowedRetries;
520:     }
521: 
522:     /**
523:      * Sets the value of allowedRetries.
524:      *
525:      * @param integer $allowedRetries the allowed retries
526:      *
527:      * @return self
528:      */
529:     public function setAllowedRetries($allowedRetries)
530:     {
531:         $this->allowedRetries = $allowedRetries;
532: 
533:         return $this;
534:     }
535: 
536:     /**
537:      * Gets the values of notify.
538:      *
539:      * @return array
540:      */
541:     public function getNotify()
542:     {
543:         return $this->notify;
544:     }
545: 
546: 
547:     /**
548:      * Sets the value of notify.
549:      *
550:      * @param array $notify
551:      *
552:      * @return self
553:      */
554:     public function setNotify(array $notify)
555:     {
556:         $this->notify = $notify;
557: 
558:         return $this;
559:     }
560: 
561: 
562:     /**
563:      * Gets the value of bankCode.
564:      *
565:      * @return string
566:      */
567:     public function getBankCode()
568:     {
569:         return $this->bankCode;
570:     }
571: 
572:     /**
573:      * Sets the value of bankCode.
574:      *
575:      * @param string $bankCode the bank code
576:      *
577:      * @return self
578:      */
579:     public function setBankCode($bankCode)
580:     {
581:         $this->bankCode = $bankCode;
582: 
583:         return $this;
584:     }
585: }
586: 
Syspay Merchant SDK API documentation generated by ApiGen 2.8.0