Skip to content

Commit

Permalink
CS-3763 showing 'Null' When Accepting a pending order (Charleston Zip…
Browse files Browse the repository at this point in the history
…-line Adventure) (#21)

* CS-3763 showing 'Null' When Accepting a pending order (Charleston Zip-line Adventure)

* CS-3763 renamed test

* CS-3763 using a constant to check the description length

* CS-3763 using a constant to check the description length

* CS-3763 using self to use constant
  • Loading branch information
DerickMathew authored and rushi committed May 8, 2019
1 parent 6b39872 commit 9f3e0ff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
class AIMAuthorizeRequest extends AIMAbstractRequest
{
const MAX_DESCRIPTION_LENGTH = 255;
protected $action = 'authOnlyTransaction';

public function getData()
Expand Down Expand Up @@ -52,7 +53,10 @@ protected function addDescription(\SimpleXMLElement $data)
/** @var mixed $req */
$req = $data->transactionRequest;

$description = $this->getDescription();
$description = trim($this->getDescription());
if (strlen($description) > self::MAX_DESCRIPTION_LENGTH) {
$description = substr($description, 0, self::MAX_DESCRIPTION_LENGTH);
}
if (!empty($description)) {
$req->order->description = $description;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/Message/CIMAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ public function testGetData()
$this->assertEquals('Test authorize transaction', $data->transactionRequest->order->description);
}

public function testShouldTruncateLongDescription()
{
$description = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
$truncatedDescription = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has su";

$this->request = new CIMAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'cardReference' => '{"customerProfileId":"28972085","customerPaymentProfileId":"26317841","customerShippingAddressId":"27057151"}',
'amount' => '12.00',
'description' => $description,
'clientIp' => '10.0.0.1'
)
);
$data = $this->request->getData();
$this->assertEquals($truncatedDescription, $data->transactionRequest->order->description);
}

public function testShouldUseTrackDataIfCardPresent()
{
$card = $this->getValidCard();
Expand Down

1 comment on commit 9f3e0ff

@judgej
Copy link

@judgej judgej commented on 9f3e0ff Dec 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you fancy submitting this as a pull request?

Please sign in to comment.