Skip to content

Add support for the ClientType option to PxPay/PxPost #74

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 1 commit 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
28 changes: 28 additions & 0 deletions src/Message/PxPayAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ public function setOpt($value)
return $this->setParameter('opt', $value);
}

/**
* Get the ClientType option
*
* Optional parameter can be used to indicate the type of transaction. Feature may need to be enabled for the user.
*
* @return mixed
*/
public function getClientType()
{
return $this->getParameter('clientType');
}

/**
* Set the ClientType field on the request
*
* @param string $value The transaction type, can be one of: 'Internet'/'I' (default), 'Recurring'/'R', or 'MOTO'
*
* @return mixed
*/
public function setClientType($value)
{
return $this->setParameter('clientType', $value);
}

/**
* Get the ForcePaymentMethod Opt
*
Expand Down Expand Up @@ -273,6 +297,10 @@ public function getData()
$data->Opt = $this->getOpt();
}

if ($this->getClientType()) {
$data->ClientType = $this->getClientType();
}

if ($this->getForcePaymentMethod()) {
$data->ForcePaymentMethod = $this->getForcePaymentMethod();
}
Expand Down
28 changes: 28 additions & 0 deletions src/Message/PxPostAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ public function getEndpoint()
return $this->getTestMode() === true ? $this->testEndpoint : $this->liveEndpoint;
}

/**
* Get the ClientType option
*
* Optional parameter can be used to indicate the type of transaction. Feature may need to be enabled for the user.
*
* @return mixed
*/
public function getClientType()
{
return $this->getParameter('clientType');
}

/**
* Set the ClientType field on the request
*
* @param string $value The transaction type, can be one of: 'Internet'/'I' (default), 'Recurring'/'R', or 'MOTO'
*
* @return mixed
*/
public function setClientType($value)
{
return $this->setParameter('clientType', $value);
}

/**
* @return mixed
*/
Expand Down Expand Up @@ -150,6 +174,10 @@ public function getData()
$data->InputCurrency = $this->getCurrency();
$data->Amount = $this->getAmount();

if ($this->getClientType()) {
$data->ClientType = $this->getClientType();
}

if ($this->getDescription()) {
$data->MerchantReference = $this->getDescription();
}
Expand Down
15 changes: 15 additions & 0 deletions tests/PxPayGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public function testAuthorizeWithTransactionDataSuccess()
$this->_testSuccessfulPurchase($response);
}

public function testAuthorizeWithClientTypeSuccess()
{
$this->setMockHttpResponse('PxPayPurchaseSuccess.txt');

$options = array_merge($this->options, array('clientType' => 'MOTO'));

$request = $this->gateway->authorize($options);

$this->assertSame($options['clientType'], $request->getClientType());

$response = $request->send();

$this->_testSuccessfulPurchase($response);
}

public function testPurchaseSuccess()
{
$this->setMockHttpResponse('PxPayPurchaseSuccess.txt');
Expand Down
18 changes: 18 additions & 0 deletions tests/PxPostGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ public function testAuthorizeWithTransactionDataSuccess()
$this->assertSame('Transaction Approved', $response->getMessage());
}

public function testAuthorizeWithClientTypeSuccess()
{
$this->setMockHttpResponse('PxPostPurchaseSuccess.txt');

$options = array_merge($this->options, array('clientType' => 'MOTO'));

$request = $this->gateway->authorize($options);

$this->assertSame($options['clientType'], $request->getClientType());

$response = $request->send();

$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('000000030884cdc6', $response->getTransactionReference());
$this->assertSame('Transaction Approved', $response->getMessage());
}

public function testCaptureSuccess()
{
$this->setMockHttpResponse('PxPostPurchaseSuccess.txt');
Expand Down