-
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 pull request #8 from incarnate/eway_rapid_direct
Add eWAY Rapid Direct Connection
- Loading branch information
Showing
36 changed files
with
1,684 additions
and
33 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
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
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,68 @@ | ||
<?php | ||
/** | ||
* eWAY Rapid Capture Request | ||
*/ | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
/** | ||
* eWAY Rapid Capture Request | ||
* | ||
* This is a request to capture and process a previously created authorisation. | ||
* | ||
* Example - note this example assumes that the authorisation has been successful | ||
* and that the Transaction ID returned from the authorisation is held in $txn_id. | ||
* See RapidDirectAuthorizeRequest for the first part of this example. | ||
* | ||
* <code> | ||
* // Once the transaction has been authorized, we can capture it for final payment. | ||
* $transaction = $gateway->capture(array( | ||
* 'amount' => '10.00', | ||
* 'currency' => 'AUD', | ||
* )); | ||
* $transaction->setTransactionReference($txn_id); | ||
* $response = $transaction->send(); | ||
* </code> | ||
* | ||
* @link https://eway.io/api-v3/#pre-auth | ||
* @see RapidDirectAuthorizeRequest | ||
*/ | ||
class RapidCaptureRequest extends AbstractRequest | ||
{ | ||
public function getData() | ||
{ | ||
$this->validate('amount', 'transactionReference'); | ||
|
||
$data = array(); | ||
|
||
$data['Payment'] = array(); | ||
$data['Payment']['TotalAmount'] = $this->getAmountInteger(); | ||
$data['Payment']['InvoiceNumber'] = $this->getTransactionId(); | ||
$data['Payment']['InvoiceDescription'] = $this->getDescription(); | ||
$data['Payment']['CurrencyCode'] = $this->getCurrency(); | ||
$data['Payment']['InvoiceReference'] = $this->getInvoiceReference(); | ||
|
||
$data['TransactionId'] = $this->getTransactionReference(); | ||
|
||
return $data; | ||
} | ||
|
||
public function getEndpoint() | ||
{ | ||
return $this->getEndpointBase().'/CapturePayment'; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
// This request uses the REST endpoint and requires the JSON content type header | ||
$httpResponse = $this->httpClient->post( | ||
$this->getEndpoint(), | ||
array('content-type' => 'application/json'), | ||
json_encode($data) | ||
) | ||
->setAuth($this->getApiKey(), $this->getPassword()) | ||
->send(); | ||
|
||
return $this->response = new RapidResponse($this, $httpResponse->json()); | ||
} | ||
} |
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,107 @@ | ||
<?php | ||
/** | ||
* eWAY Rapid Direct Abstract Request | ||
*/ | ||
|
||
namespace Omnipay\Eway\Message; | ||
|
||
/** | ||
* eWAY Rapid Direct Abstract Request | ||
* | ||
* This class forms the base class for eWAY Rapid Direct requests. | ||
* | ||
* @link https://eway.io/api-v3/#direct-connection | ||
*/ | ||
abstract class RapidDirectAbstractRequest extends AbstractRequest | ||
{ | ||
public function getEncryptedCardNumber() | ||
{ | ||
return $this->getParameter('encryptedCardNumber'); | ||
} | ||
|
||
/** | ||
* Sets the encrypted card number, for use when submitting card data | ||
* encrypted using eWAY's client side encryption. | ||
* | ||
* @param string $value | ||
* @return RapidDirectAbstractRequest | ||
*/ | ||
public function setEncryptedCardNumber($value) | ||
{ | ||
return $this->setParameter('encryptedCardNumber', $value); | ||
} | ||
|
||
public function getEncryptedCardCvv() | ||
{ | ||
return $this->getParameter('encryptedCardCvv'); | ||
} | ||
|
||
/** | ||
* Sets the encrypted card cvv, for use when submitting card data | ||
* encrypted using eWAY's client side encryption. | ||
* | ||
* @param string $value | ||
* @return RapidDirectAbstractRequest | ||
*/ | ||
public function setEncryptedCardCvv($value) | ||
{ | ||
return $this->setParameter('encryptedCardCvv', $value); | ||
} | ||
|
||
protected function getBaseData() | ||
{ | ||
|
||
$data = parent::getBaseData(); | ||
$data['TransactionType'] = $this->getTransactionType(); | ||
|
||
if ($this->getCardReference()) { | ||
$data['Customer']['TokenCustomerID'] = $this->getCardReference(); | ||
} else { | ||
$this->validate('card'); | ||
} | ||
|
||
if ($this->getCard()) { | ||
$data['Customer']['CardDetails'] = array(); | ||
$data['Customer']['CardDetails']['Name'] = $this->getCard()->getName(); | ||
$data['Customer']['CardDetails']['ExpiryMonth'] = $this->getCard()->getExpiryDate('m'); | ||
$data['Customer']['CardDetails']['ExpiryYear'] = $this->getCard()->getExpiryDate('y'); | ||
$data['Customer']['CardDetails']['CVN'] = $this->getCard()->getCvv(); | ||
|
||
if ($this->getEncryptedCardNumber()) { | ||
$data['Customer']['CardDetails']['Number'] = $this->getEncryptedCardNumber(); | ||
} else { | ||
$data['Customer']['CardDetails']['Number'] = $this->getCard()->getNumber(); | ||
} | ||
|
||
if ($this->getEncryptedCardCvv()) { | ||
$data['Customer']['CardDetails']['CVN'] = $this->getEncryptedCardCvv(); | ||
} else { | ||
$data['Customer']['CardDetails']['CVN'] = $this->getCard()->getCvv(); | ||
} | ||
|
||
if ($this->getCard()->getStartMonth() and $this->getCard()->getStartYear()) { | ||
$data['Customer']['CardDetails']['StartMonth'] = $this->getCard()->getStartDate('m'); | ||
$data['Customer']['CardDetails']['StartYear'] = $this->getCard()->getStartDate('y'); | ||
} | ||
|
||
if ($this->getCard()->getIssueNumber()) { | ||
$data['Customer']['CardDetails']['IssueNumber'] = $this->getCard()->getIssueNumber(); | ||
} | ||
} | ||
|
||
if ($this->getItems()) { | ||
$data['Items'] = $this->getItemData(); | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function sendData($data) | ||
{ | ||
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, json_encode($data)) | ||
->setAuth($this->getApiKey(), $this->getPassword()) | ||
->send(); | ||
|
||
return $this->response = new RapidResponse($this, $httpResponse->json()); | ||
} | ||
} |
Oops, something went wrong.