-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote branch 'upstream/master'
- Loading branch information
Showing
20 changed files
with
714 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway; | ||
|
||
use Omnipay\Common\AbstractGateway; | ||
|
||
/** | ||
* eWAY Direct Payments Gateway | ||
*/ | ||
class DirectGateway extends AbstractGateway | ||
{ | ||
public function getName() | ||
{ | ||
return 'eWAY Direct'; | ||
} | ||
|
||
public function getDefaultParameters() | ||
{ | ||
return array( | ||
'customerId' => '', | ||
'testMode' => false, | ||
); | ||
} | ||
|
||
public function getCustomerId() | ||
{ | ||
return $this->getParameter('customerId'); | ||
} | ||
|
||
public function setCustomerId($value) | ||
{ | ||
return $this->setParameter('customerId', $value); | ||
} | ||
|
||
public function authorize(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Eway\Message\DirectAuthorizeRequest', $parameters); | ||
} | ||
|
||
public function capture(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Eway\Message\DirectCaptureRequest', $parameters); | ||
} | ||
|
||
public function purchase(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Eway\Message\DirectPurchaseRequest', $parameters); | ||
} | ||
|
||
public function refund(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Eway\Message\DirectRefundRequest', $parameters); | ||
} | ||
|
||
public function void(array $parameters = array()) | ||
{ | ||
return $this->createRequest('\Omnipay\Eway\Message\DirectVoidRequest', $parameters); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* eWAY Direct Abstract Request | ||
*/ | ||
abstract class DirectAbstractRequest extends AbstractRequest | ||
{ | ||
|
||
public function sendData($data) | ||
{ | ||
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data->asXML())->send(); | ||
|
||
return $this->response = new DirectResponse($this, $httpResponse->xml()); | ||
} | ||
|
||
public function getCustomerId() | ||
{ | ||
return $this->getParameter('customerId'); | ||
} | ||
|
||
public function setCustomerId($value) | ||
{ | ||
return $this->setParameter('customerId', $value); | ||
} | ||
|
||
public function setOption1($value) | ||
{ | ||
return $this->setParameter('option1', $value); | ||
} | ||
|
||
public function getOption1() | ||
{ | ||
return $this->getParameter('option1'); | ||
} | ||
|
||
public function setOption2($value) | ||
{ | ||
return $this->setParameter('option2', $value); | ||
} | ||
|
||
public function getOption2() | ||
{ | ||
return $this->getParameter('option2'); | ||
} | ||
|
||
public function setOption3($value) | ||
{ | ||
return $this->setParameter('option3', $value); | ||
} | ||
|
||
public function getOption3() | ||
{ | ||
return $this->getParameter('option3'); | ||
} | ||
|
||
/** | ||
* Get End Point | ||
* | ||
* Depends on Test or Live environment | ||
* | ||
* @return string | ||
*/ | ||
public function getEndpoint() | ||
{ | ||
return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* eWAY Direct Authorize Request | ||
*/ | ||
class DirectAuthorizeRequest extends DirectAbstractRequest | ||
{ | ||
protected $liveEndpoint = 'https://www.eway.com.au/gateway_cvn/xmlauth.asp'; | ||
protected $testEndpoint = 'https://www.eway.com.au/gateway_cvn/xmltest/authtestpage.asp'; | ||
|
||
public function getData() | ||
{ | ||
$this->validate('card'); | ||
|
||
$xml = '<?xml version="1.0"?><ewaygateway></ewaygateway>'; | ||
$sxml = new \SimpleXMLElement($xml); | ||
|
||
/* eWAY Customer Id */ | ||
$sxml->addChild('ewayCustomerID', $this->getCustomerId()); | ||
|
||
/* eWAY Transaction Details */ | ||
$sxml->addChild('ewayTotalAmount', $this->getAmountInteger()); | ||
$sxml->addChild('ewayTrxnNumber', $this->getTransactionId()); | ||
|
||
/* Card Holder Details */ | ||
$card = $this->getCard(); | ||
$sxml->addChild('ewayCardHoldersName', $card->getName()); | ||
$sxml->addChild('ewayCardNumber', $card->getNumber()); | ||
$sxml->addChild('ewayCardExpiryMonth', $card->getExpiryDate('m')); | ||
$sxml->addChild('ewayCardExpiryYear', $card->getExpiryDate('y')); | ||
$sxml->addChild('ewayCVN', $card->getCVV()); | ||
|
||
/* Customer Details */ | ||
$sxml->addChild('ewayCustomerFirstName', $card->getFirstName()); | ||
$sxml->addChild('ewayCustomerLastName', $card->getLastName()); | ||
$sxml->addChild('ewayCustomerEmail', $card->getEmail()); | ||
$sxml->addChild('ewayCustomerAddress', $card->getAddress1().' '.$card->getAddress2()); | ||
$sxml->addChild('ewayCustomerPostcode', $card->getPostCode()); | ||
|
||
$sxml->addChild('ewayOption1', $this->getOption1()); | ||
$sxml->addChild('ewayOption2', $this->getOption2()); | ||
$sxml->addChild('ewayOption3', $this->getOption3()); | ||
|
||
$sxml->addChild('ewayCustomerInvoiceDescription', $this->getDescription()); | ||
$sxml->addChild('ewayCustomerInvoiceRef', $this->getTransactionReference()); | ||
|
||
return $sxml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* eWAY Direct Capture Request | ||
*/ | ||
class DirectCaptureRequest extends DirectAbstractRequest | ||
{ | ||
protected $liveEndpoint = 'https://www.eway.com.au/gateway/xmlauthcomplete.asp'; | ||
protected $testEndpoint = 'https://www.eway.com.au/gateway/xmltest/authcompletetestpage.asp'; | ||
|
||
public function getData() | ||
{ | ||
$this->validate('transactionId'); | ||
|
||
$xml = '<?xml version="1.0"?><ewaygateway></ewaygateway>'; | ||
$sxml = new \SimpleXMLElement($xml); | ||
|
||
/* eWAY Customer Id */ | ||
$sxml->addChild('ewayCustomerID', $this->getCustomerId()); | ||
|
||
/* eWAY Transaction Details */ | ||
$sxml->addChild('ewayTotalAmount', $this->getAmountInteger()); | ||
$sxml->addChild('ewayAuthTrxnNumber', $this->getTransactionId()); | ||
|
||
$sxml->addChild('ewayCardExpiryMonth', null); // optional field | ||
$sxml->addChild('ewayCardExpiryYear', null); // optional field | ||
|
||
$sxml->addChild('ewayOption1', $this->getOption1()); | ||
$sxml->addChild('ewayOption2', $this->getOption2()); | ||
$sxml->addChild('ewayOption3', $this->getOption3()); | ||
|
||
return $sxml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* eWAY Direct Purchase Request | ||
*/ | ||
class DirectPurchaseRequest extends DirectAbstractRequest | ||
{ | ||
protected $liveEndpoint = 'https://www.eway.com.au/gateway_cvn/xmlpayment.asp'; | ||
protected $testEndpoint = 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp'; | ||
|
||
public function getData() | ||
{ | ||
$this->validate('card'); | ||
|
||
$xml = '<?xml version="1.0"?><ewaygateway></ewaygateway>'; | ||
$sxml = new \SimpleXMLElement($xml); | ||
|
||
/* eWAY Customer Id */ | ||
$sxml->addChild('ewayCustomerID', $this->getCustomerId()); | ||
|
||
/* eWAY Transaction Details */ | ||
$sxml->addChild('ewayTotalAmount', $this->getAmountInteger()); | ||
$sxml->addChild('ewayTrxnNumber', $this->getTransactionId()); | ||
|
||
/* Card Holder Details */ | ||
$card = $this->getCard(); | ||
$sxml->addChild('ewayCardHoldersName', $card->getName()); | ||
$sxml->addChild('ewayCardNumber', $card->getNumber()); | ||
$sxml->addChild('ewayCardExpiryMonth', $card->getExpiryDate('m')); | ||
$sxml->addChild('ewayCardExpiryYear', $card->getExpiryDate('y')); | ||
$sxml->addChild('ewayCVN', $card->getCVV()); | ||
|
||
/* Customer Details */ | ||
$sxml->addChild('ewayCustomerFirstName', $card->getFirstName()); | ||
$sxml->addChild('ewayCustomerLastName', $card->getLastName()); | ||
$sxml->addChild('ewayCustomerEmail', $card->getEmail()); | ||
$sxml->addChild('ewayCustomerAddress', $card->getAddress1().' '.$card->getAddress2()); | ||
$sxml->addChild('ewayCustomerPostcode', $card->getPostCode()); | ||
|
||
$sxml->addChild('ewayOption1', $this->getOption1()); | ||
$sxml->addChild('ewayOption2', $this->getOption2()); | ||
$sxml->addChild('ewayOption3', $this->getOption3()); | ||
|
||
$sxml->addChild('ewayCustomerInvoiceDescription', $this->getDescription()); | ||
$sxml->addChild('ewayCustomerInvoiceRef', $this->getTransactionReference()); | ||
|
||
return $sxml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractRequest; | ||
|
||
/** | ||
* eWAY Direct Refund Request | ||
*/ | ||
class DirectRefundRequest extends DirectAbstractRequest | ||
{ | ||
protected $liveEndpoint = 'https://www.eway.com.au/gateway/xmlpaymentrefund.asp'; | ||
protected $testEndpoint = 'https://www.eway.com.au/gateway/xmltest/refund_test.asp'; | ||
|
||
public function setRefundPassword($value) | ||
{ | ||
return $this->setParameter('refundPassword', $value); | ||
} | ||
|
||
public function getRefundPassword() | ||
{ | ||
return $this->getParameter('refundPassword'); | ||
} | ||
|
||
public function getData() | ||
{ | ||
$this->validate('refundPassword', 'transactionId'); | ||
|
||
$xml = '<?xml version="1.0"?><ewaygateway></ewaygateway>'; | ||
$sxml = new \SimpleXMLElement($xml); | ||
|
||
/* eWAY Customer Id */ | ||
$sxml->addChild('ewayCustomerID', $this->getCustomerId()); | ||
|
||
/* eWAY Transaction Details */ | ||
$sxml->addChild('ewayTotalAmount', $this->getAmountInteger()); | ||
$sxml->addChild('ewayOriginalTrxnNumber', $this->getTransactionId()); | ||
|
||
/* Card Holder Details */ | ||
$card = $this->getCard(); | ||
$sxml->addChild('ewayCardExpiryMonth', $card->getExpiryDate('m')); | ||
$sxml->addChild('ewayCardExpiryYear', $card->getExpiryDate('y')); | ||
|
||
$sxml->addChild('ewayOption1', $this->getOption1()); | ||
$sxml->addChild('ewayOption2', $this->getOption2()); | ||
$sxml->addChild('ewayOption3', $this->getOption3()); | ||
|
||
$sxml->addChild('ewayRefundPassword', $this->getRefundPassword()); | ||
$sxml->addChild('ewayCustomerInvoiceRef', $this->getTransactionReference()); | ||
|
||
return $sxml; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
use Omnipay\Common\Message\AbstractResponse; | ||
use Omnipay\Common\Message\RequestInterface; | ||
use Omnipay\Common\Exception\InvalidResponseException; | ||
|
||
/** | ||
* eWAY Direct Response | ||
*/ | ||
class DirectResponse extends AbstractResponse | ||
{ | ||
public function isSuccessful() | ||
{ | ||
return "True" === (string) $this->data->ewayTrxnStatus; | ||
} | ||
|
||
public function isRedirect() | ||
{ | ||
return false; | ||
} | ||
|
||
public function getTransactionReference() | ||
{ | ||
if (empty($this->data->ewayTrxnNumber)) { | ||
return null; | ||
} | ||
|
||
return (int) $this->data->ewayTrxnNumber; | ||
} | ||
|
||
public function getMessage() | ||
{ | ||
return (string) $this->data->ewayTrxnError; | ||
} | ||
} |
Oops, something went wrong.