|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\Eway\Message; |
| 4 | + |
| 5 | +use Omnipay\Common\Message\AbstractRequest; |
| 6 | + |
| 7 | +/** |
| 8 | + * eWAY Direct Authorize Request |
| 9 | + */ |
| 10 | +class DirectAuthorizeRequest extends DirectAbstractRequest |
| 11 | +{ |
| 12 | + protected $liveEndpoint = 'https://www.eway.com.au/gateway_cvn/xmlauth.asp'; |
| 13 | + protected $testEndpoint = 'https://www.eway.com.au/gateway_cvn/xmltest/authtestpage.asp'; |
| 14 | + |
| 15 | + public function getData() |
| 16 | + { |
| 17 | + $this->validate('card'); |
| 18 | + |
| 19 | + $xml = '<?xml version="1.0"?><ewaygateway></ewaygateway>'; |
| 20 | + $sxml = new \SimpleXMLElement($xml); |
| 21 | + |
| 22 | + /* eWAY Customer Id */ |
| 23 | + $sxml->addChild('ewayCustomerID', $this->getCustomerId()); |
| 24 | + |
| 25 | + /* eWAY Transaction Details */ |
| 26 | + $sxml->addChild('ewayTotalAmount', $this->getAmountInteger()); |
| 27 | + $sxml->addChild('ewayTrxnNumber', $this->getTransactionId()); |
| 28 | + |
| 29 | + /* Card Holder Details */ |
| 30 | + $card = $this->getCard(); |
| 31 | + $sxml->addChild('ewayCardHoldersName', $card->getName()); |
| 32 | + $sxml->addChild('ewayCardNumber', $card->getNumber()); |
| 33 | + $sxml->addChild('ewayCardExpiryMonth', $card->getExpiryDate('m')); |
| 34 | + $sxml->addChild('ewayCardExpiryYear', $card->getExpiryDate('y')); |
| 35 | + $sxml->addChild('ewayCVN', $card->getCVV()); |
| 36 | + |
| 37 | + /* Customer Details */ |
| 38 | + $sxml->addChild('ewayCustomerFirstName', $card->getFirstName()); |
| 39 | + $sxml->addChild('ewayCustomerLastName', $card->getLastName()); |
| 40 | + $sxml->addChild('ewayCustomerEmail', $card->getEmail()); |
| 41 | + $sxml->addChild('ewayCustomerAddress', $card->getAddress1().' '.$card->getAddress2()); |
| 42 | + $sxml->addChild('ewayCustomerPostcode', $card->getPostCode()); |
| 43 | + |
| 44 | + $sxml->addChild('ewayOption1', $this->getOption1()); |
| 45 | + $sxml->addChild('ewayOption2', $this->getOption2()); |
| 46 | + $sxml->addChild('ewayOption3', $this->getOption3()); |
| 47 | + |
| 48 | + $sxml->addChild('ewayCustomerInvoiceDescription', $this->getDescription()); |
| 49 | + $sxml->addChild('ewayCustomerInvoiceRef', $this->getTransactionReference()); |
| 50 | + |
| 51 | + return $sxml; |
| 52 | + } |
| 53 | +} |
0 commit comments