|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * eWAY Rapid Shared Page Create Card Request |
| 4 | + */ |
| 5 | + |
| 6 | +namespace Omnipay\Eway\Message; |
| 7 | + |
| 8 | +/** |
| 9 | + * eWAY Rapid Shared Page Create Card Request |
| 10 | + * |
| 11 | + * Creates a payment URL using eWAY's Responsive Shared Page |
| 12 | + * |
| 13 | + * @link https://eway.io/api-v3/#responsive-shared-page |
| 14 | + */ |
| 15 | +class RapidCreateCardRequest extends RapidPurchaseRequest |
| 16 | +{ |
| 17 | + protected $action; |
| 18 | + |
| 19 | + /** |
| 20 | + * @return string|NULL |
| 21 | + */ |
| 22 | + public function getAction() |
| 23 | + { |
| 24 | + return $this->action; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * @param string $action |
| 29 | + */ |
| 30 | + public function setAction($action) |
| 31 | + { |
| 32 | + $this->action = $action; |
| 33 | + } |
| 34 | + |
| 35 | + public function getData() |
| 36 | + { |
| 37 | + $this->validate('returnUrl'); |
| 38 | + |
| 39 | + $data = $this->getBaseData(); |
| 40 | + |
| 41 | + $data['TransactionType'] = 'Purchase'; |
| 42 | + $data['RedirectUrl'] = $this->getReturnUrl(); |
| 43 | + |
| 44 | + // Shared page parameters (optional) |
| 45 | + $data['CancelUrl'] = $this->getCancelUrl(); |
| 46 | + |
| 47 | + $data['Payment'] = array(); |
| 48 | + |
| 49 | + if ($this->getAction() === 'Purchase') { |
| 50 | + $data['Payment']['TotalAmount'] = (int) $this->getAmountInteger(); |
| 51 | + $data['Payment']['InvoiceNumber'] = $this->getTransactionId(); |
| 52 | + $data['Payment']['InvoiceDescription'] = $this->getDescription(); |
| 53 | + $data['Payment']['CurrencyCode'] = $this->getCurrency(); |
| 54 | + $data['Payment']['InvoiceReference'] = $this->getInvoiceReference(); |
| 55 | + $data['Method'] = 'TokenPayment'; |
| 56 | + } else { |
| 57 | + $data['Method'] = 'CreateTokenCustomer'; |
| 58 | + $data['Payment']['TotalAmount'] = 0; |
| 59 | + } |
| 60 | + |
| 61 | + return $data; |
| 62 | + } |
| 63 | +} |
0 commit comments