Skip to content

Commit

Permalink
Merge pull request #335 from FatchipRobert/MAG2-165-TransactionParam
Browse files Browse the repository at this point in the history
MAG2-165 TransactionParam
  • Loading branch information
hreinberger authored Aug 12, 2020
2 parents dae7ffd + d9afee0 commit 36f6876
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Model/Api/Request/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ protected function setPaymentParameters(PayoneMethod $oPayment, Order $oOrder)
$sNarrativeText = $this->toolkitHelper->getNarrativeText($oOrder, $oPayment);
if (!empty($sNarrativeText)) {// narrative text existing?
$this->addParameter('narrative_text', $sNarrativeText); // add narrative text parameter
if ($oPayment->needsTransactionParam() === true) {
$this->addParameter('transaction_param', preg_replace('/[^0-9A-Z._\/\-]/i', "", $sNarrativeText));
}
}
$aPaymentParams = $oPayment->getPaymentSpecificParameters($oOrder); // get payment params specific to the payment type
$this->aParameters = array_merge($this->aParameters, $aPaymentParams); // merge payment params with other params
Expand Down
7 changes: 7 additions & 0 deletions Model/Methods/BaseMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ abstract class BaseMethod extends AbstractMethod
*/
protected $blNeedsRedirectUrls = false;

/**
* Determines if the transaction_param-parameter has to be added to the authorization-request
*
* @var bool
*/
protected $blNeedsTransactionParam = false;

/**
* Determines if the invoice information has to be added
* to the authorization-request
Expand Down
10 changes: 10 additions & 0 deletions Model/Methods/PayoneMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ public function needsRedirectUrls()
return $this->blNeedsRedirectUrls;
}

/**
* Return if transaction_param has to be added to the authroization request
*
* @return bool
*/
public function needsTransactionParam()
{
return $this->blNeedsTransactionParam;
}

/**
* Return if invoice data has to be added to the authroization request
*
Expand Down
7 changes: 7 additions & 0 deletions Model/Methods/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ class Paypal extends PayoneMethod
*/
protected $blNeedsRedirectUrls = true;

/**
* Determines if the transaction_param-parameter has to be added to the authorization-request
*
* @var bool
*/
protected $blNeedsTransactionParam = true;

/**
* Return success url for redirect payment types
*
Expand Down
1 change: 1 addition & 0 deletions Test/Unit/Model/Api/Request/AuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private function getPaymentMock()
$payment->method('getClearingtype')->willReturn('wlt');
$payment->method('getPaymentSpecificParameters')->willReturn([]);
$payment->method('needsRedirectUrls')->willReturn(true);
$payment->method('needsTransactionParam')->willReturn(true);
$payment->method('getSuccessUrl')->willReturn('http://testdomain.com');
$payment->method('getErrorUrl')->willReturn('http://testdomain.com');
$payment->method('getCancelUrl')->willReturn('http://testdomain.com');
Expand Down
6 changes: 6 additions & 0 deletions Test/Unit/Model/Methods/PayoneMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public function testNeedsRedirectUrls()
$this->assertTrue($result);
}

public function testNeedsTransactionParam()
{
$result = $this->classToTest->needsTransactionParam();
$this->assertFalse($result);
}

public function testNeedsProductInfo()
{
$result = $this->classToTest->needsProductInfo();
Expand Down

0 comments on commit 36f6876

Please sign in to comment.