Skip to content

Commit

Permalink
Added some fixes to resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
sudiptpa committed Dec 6, 2022
2 parents 9900c59 + 7fc4f58 commit eb1f23a
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 198 deletions.
8 changes: 4 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@

$gateway->setTestMode(true);

$card = new CreditCard(array(
$card = new CreditCard([
'firstName' => 'Sujip',
'lastName' => 'Thapa',
'number' => '4444333322221111',
'expiryMonth' => '10',
'expiryYear' => '2030',
'cvv' => '123',
));
]);

$response = $gateway->purchase(array(
$response = $gateway->purchase([
'amount' => '12.00',
'transactionId' => 'ORDER-ZYX8',
'currency' => 'AUD',
'card' => $card,
))
])
->send();

$message = sprintf(
Expand Down
4 changes: 2 additions & 2 deletions src/HostedPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class HostedPaymentGateway extends AbstractGateway
{
public function completePurchase(array $parameters = array())
public function completePurchase(array $parameters = [])
{
return $this->createRequest('\Omnipay\NABTransact\Message\HostedPaymentCompletePurchaseRequest', $parameters);
}
Expand All @@ -24,7 +24,7 @@ public function getName()
return 'NAB Hosted Payment';
}

public function purchase(array $parameters = array())
public function purchase(array $parameters = [])
{
return $this->createRequest('\Omnipay\NABTransact\Message\HostedPaymentPurchaseRequest', $parameters);
}
Expand Down
35 changes: 1 addition & 34 deletions src/Message/HostedPaymentPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@
*/
class HostedPaymentPurchaseRequest extends AbstractRequest
{
/**
* @var string
*/
public $liveEndpoint = 'https://transact.nab.com.au/test/hpp/payment';

/**
* @var string
*/
public $testEndpoint = 'https://transact.nab.com.au/live/hpp/payment';

/**
* @return mixed
*/
public function getData()
{
$this->validate(
Expand All @@ -30,7 +21,7 @@ public function getData()
'paymentAlertEmail'
);

$data = array();
$data = [];

$data['vendor_name'] = $this->getMerchantId();
$data['payment_alert'] = $this->getPaymentAlertEmail();
Expand All @@ -44,55 +35,31 @@ public function getData()
return $data;
}

/**
* @return mixed
*/
public function getMerchantId()
{
return $this->getParameter('merchantId');
}

/**
* @return mixed
*/
public function getPaymentAlertEmail()
{
return $this->getParameter('paymentAlertEmail');
}

/**
* @return mixed
*/
public function getReturnUrlText()
{
return $this->getParameter('returnUrlText');
}

/**
* @param $data
*
* @return mixed
*/
public function sendData($data)
{
return $this->response = new HostedPaymentPurchaseResponse($this, $data, $this->getEndpoint());
}

/**
* @param $value
*
* @return mixed
*/
public function setPaymentAlertEmail($value)
{
return $this->setParameter('paymentAlertEmail', $value);
}

/**
* @param $value
*
* @return mixed
*/
public function setReturnUrlText($value)
{
return $this->setParameter('returnUrlText', $value);
Expand Down
38 changes: 1 addition & 37 deletions src/Message/SecureXMLAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,28 @@
*/
abstract class SecureXMLAbstractRequest extends AbstractRequest
{
/**
* @var string
*/
public $testEndpoint = 'https://demo.transact.nab.com.au/xmlapi/payment';

/**
* @var string
*/
public $liveEndpoint = 'https://transact.nab.com.au/live/xmlapi/payment';

/**
* @var string
*/
protected $requestType = 'Payment';

/**
* @var mixed
*/
protected $txnType;

/**
* @var array
*/
protected $requiredFields = array();
protected $requiredFields = [];

/**
* Set the messageID on the request.
*
* This is returned intact on any response so you could add a local
* database ID here to ease in matching data later.
*/
public function setMessageId($value)
{
return $this->setParameter('messageId', $value);
}

/**
* Generates a SecureXML messageId.
*
* @return string
*/
public function generateMessageId()
{
$hash = hash('sha256', microtime());

return substr($hash, 0, 30);
}

/**
* Get the messageID or generated one based on timestamp.
*
* @return string
*/
public function getMessageId()
{
$messageId = $this->getParameter('messageId');
Expand All @@ -71,11 +40,6 @@ public function getMessageId()
return $this->getParameter('messageId');
}

/**
* @param $data
*
* @return mixed
*/
public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data->asXML())->send();
Expand Down
11 changes: 1 addition & 10 deletions src/Message/SecureXMLAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
*/
class SecureXMLAuthorizeRequest extends SecureXMLAbstractRequest
{
/**
* @var int
*/
protected $txnType = 10;

/**
* @var array
*/
protected $requiredFields = array('amount', 'card', 'transactionId');
protected $requiredFields = ['amount', 'card', 'transactionId'];

/**
* @return mixed
*/
public function getData()
{
return $this->getBasePaymentXMLWithCard();
Expand Down
13 changes: 1 addition & 12 deletions src/Message/SecureXMLCaptureRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@
*/
class SecureXMLCaptureRequest extends SecureXMLAbstractRequest
{
/**
* @var int
*/
protected $txnType = 11;

/**
* @var array
*/
protected $requiredFields = array('amount', 'transactionId', 'preauthId');
protected $requiredFields = ['amount', 'transactionId', 'preauthId'];

/**
* @return mixed
*/
public function getData()
{
$xml = $this->getBasePaymentXML();
Expand All @@ -37,8 +28,6 @@ public function getData()

/**
* Set the preauthId that was returned as part of the original authorize request.
*
* @return mixed
*/
public function setPreauthId($value)
{
Expand Down
6 changes: 0 additions & 6 deletions src/Message/SecureXMLEchoTestRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,8 @@
*/
class SecureXMLEchoTestRequest extends SecureXMLAbstractRequest
{
/**
* @var string
*/
protected $requestType = 'Echo';

/**
* @return mixed
*/
public function getData()
{
return $this->getBaseXML();
Expand Down
11 changes: 1 addition & 10 deletions src/Message/SecureXMLPurchaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@
*/
class SecureXMLPurchaseRequest extends SecureXMLAbstractRequest
{
/**
* @var int
*/
protected $txnType = 0;

/**
* @var array
*/
protected $requiredFields = array('amount', 'card', 'transactionId');
protected $requiredFields = ['amount', 'card', 'transactionId'];

/**
* @return mixed
*/
public function getData()
{
return $this->getBasePaymentXMLWithCard();
Expand Down
11 changes: 1 addition & 10 deletions src/Message/SecureXMLRefundRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,10 @@
*/
class SecureXMLRefundRequest extends SecureXMLAbstractRequest
{
/**
* @var int
*/
protected $txnType = 4;

/**
* @var array
*/
protected $requiredFields = array('amount', 'transactionId', 'transactionReference');
protected $requiredFields = ['amount', 'transactionId', 'transactionReference'];

/**
* @return mixed
*/
public function getData()
{
$xml = $this->getBasePaymentXML();
Expand Down
32 changes: 16 additions & 16 deletions src/Message/SecureXMLResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public function getResponseText()
public function getCode()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->responseCode
: (string) $this->data->Status->statusCode;
? (string) $this->data->Payment->TxnList->Txn->responseCode
: (string) $this->data->Status->statusCode;
}

/**
Expand All @@ -92,8 +92,8 @@ public function getCode()
public function getMessage()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->responseText
: (string) $this->data->Status->statusDescription;
? (string) $this->data->Payment->TxnList->Txn->responseText
: (string) $this->data->Status->statusDescription;
}

/**
Expand All @@ -112,8 +112,8 @@ public function getMessageTimestamp()
public function getTransactionReference()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->purchaseOrderNo
: null;
? (string) $this->data->Payment->TxnList->Txn->purchaseOrderNo
: null;
}

/**
Expand All @@ -122,8 +122,8 @@ public function getTransactionReference()
public function getTransactionId()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->txnID
: null;
? (string) $this->data->Payment->TxnList->Txn->txnID
: null;
}

/**
Expand All @@ -134,8 +134,8 @@ public function getTransactionId()
public function getTransactionAmount()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->amount
: null;
? (string) $this->data->Payment->TxnList->Txn->amount
: null;
}

/**
Expand All @@ -146,8 +146,8 @@ public function getTransactionAmount()
public function getTransactionCurrency()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->currency
: null;
? (string) $this->data->Payment->TxnList->Txn->currency
: null;
}

/**
Expand All @@ -158,8 +158,8 @@ public function getTransactionCurrency()
public function getTransactionSource()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->txnSource
: null;
? (string) $this->data->Payment->TxnList->Txn->txnSource
: null;
}

/**
Expand All @@ -170,7 +170,7 @@ public function getTransactionSource()
public function getSettlementDate()
{
return $this->hasTransaction()
? (string) $this->data->Payment->TxnList->Txn->settlementDate
: null;
? (string) $this->data->Payment->TxnList->Txn->settlementDate
: null;
}
}
Loading

0 comments on commit eb1f23a

Please sign in to comment.