Skip to content

Implement BillingId support #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"omnipay/common": "~3.0"
},
"require-dev": {
"omnipay/tests": "~3.0"
"omnipay/tests": "~3.0",
"squizlabs/php_codesniffer": "^3.2"
},
"extra": {
"branch-alias": {
Expand Down
28 changes: 27 additions & 1 deletion src/Message/PxPayAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,30 @@ public function setTransactionData3($value)
return $this->setParameter('transactionData3', $value);
}

/**
* Get the PxPay BillingId where this is used instead of the DpsBillingId
* for storing or retrieving a saved card profile.
*
* @see getCardReference() for DpsBillingId
* @return mixed
*/
public function getBillingId()
{
return $this->getParameter('billingId');
}

/**
* Set a BillingId for use of a stored card with a local reference as an
* alternative to using cardReference (which uses DPS' generated reference instead)
*
* @param string $value Max 32 bytes
* @return $this
*/
public function setBillingId($value)
{
return $this->setParameter('billingId', $value);
}

/**
* Get the transaction data
*
Expand Down Expand Up @@ -217,6 +241,8 @@ public function getData()

if ($this->getCardReference()) {
$data->DpsBillingId = $this->getCardReference();
} elseif ($this->getBillingId()) {
$data->BillingId = $this->getBillingId();
}

return $data;
Expand All @@ -230,7 +256,7 @@ public function getData()
*/
public function sendData($data)
{
$httpResponse = $this->httpClient->request('POST' ,$this->getEndpoint(), [], $data->asXML());
$httpResponse = $this->httpClient->request('POST', $this->getEndpoint(), [], $data->asXML());

return $this->createResponse($httpResponse->getBody()->getContents());
}
Expand Down
26 changes: 26 additions & 0 deletions src/Message/PxPostAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ public function setTransactionData3($value)
return $this->setParameter('transactionData3', $value);
}

/**
* Get the PxPost BillingId where this is used instead of the DpsBillingId
* for storing or retrieving a saved card profile.
*
* @see getCardReference() for DpsBillingId
* @return mixed
*/
public function getBillingId()
{
return $this->getParameter('billingId');
}

/**
* Set a BillingId for use of a stored card with a local reference as an
* alternative to using cardReference (which uses DPS' generated reference instead)
*
* @param string $value Max 32 bytes
* @return $this
*/
public function setBillingId($value)
{
return $this->setParameter('billingId', $value);
}

protected function getBaseData()
{
$data = new \SimpleXMLElement('<Txn />');
Expand Down Expand Up @@ -172,6 +196,8 @@ public function getData()

if ($this->getCardReference()) {
$data->DpsBillingId = $this->getCardReference();
} elseif ($this->getBillingId()) {
$data->BillingId = $this->getBillingId();
} elseif ($this->getCard()) {
$this->getCard()->validate();
$data->CardNumber = $this->getCard()->getNumber();
Expand Down