Skip to content

Commit

Permalink
Changed readme and added fix for backward compability when M_INFO is not
Browse files Browse the repository at this point in the history
filled
  • Loading branch information
rosen4o committed Jul 15, 2024
1 parent a894561 commit deffffa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ $saleRequest = (new SaleRequest())
->setTerminalID('<TID - V*******>')
->setMerchantId('<MID - 15 chars>')
->setPrivateKey('\<path to certificate.key>', '<password / or use method from bottom>')
->setMInfo(array(
'email'=>'[email protected]',
'cardholderName'=>'Ivan Ivanov',
'mobilePhone'=>'359888123456'
->setMInfo(array( // Mandatory cardholderName and ( email or MobilePhone )
'email'=>'[email protected]',
'cardholderName'=>'CARDHOLDER NAME', // Max 45 chars
'mobilePhone'=> array(
'cc'=>'359', // Country code
'subscriber'=>'8939999888', // Subscriber number
),
'threeDSRequestorChallengeInd'=>'04', // Optional for Additional Authentication
))
//->setSigningSchemaMacGeneral(); // use MAC_GENERAL
//->setSigningSchemaMacExtended(); // use MAC_EXTENDED
Expand Down
5 changes: 4 additions & 1 deletion src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ public function setNonce($nonce)
*/
public function getMInfo()
{
return $this->mInfo;
if (!empty($this->mInfo)) {
return base64_encode(json_encode($this->mInfo));
}
return '';
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/SaleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class SaleRequest extends Request implements RequestInterface
*/
protected $adCustBorOrderId;

/**
* @array
*/
protected $mInfo;

/**
* Sale constructor.
*/
Expand Down Expand Up @@ -110,7 +105,7 @@ public function generateForm()
*/
public function getData()
{
return [
return array_filter([
'NONCE' => $this->getNonce(),
'P_SIGN' => $this->generateSignature(),

Expand All @@ -132,8 +127,9 @@ public function getData()
'TERMINAL' => $this->getTerminalID(),
'BACKREF' => $this->getBackRefUrl(),

'M_INFO' => base64_encode(json_encode($this->getMInfo())),
] + $this->generateAdCustBorOrderId();
'M_INFO' => $this->getMInfo(),

]) + $this->generateAdCustBorOrderId();
}

/**
Expand Down

0 comments on commit deffffa

Please sign in to comment.