Skip to content

Commit 0869619

Browse files
authored
CC-897/add tra exemption type (#189)
* [CC-897] Add constant for tra (transaction risk analysis).
1 parent cf42c95 commit 0869619

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Click To Pay payment method is added to SDK.
1212
### Added
1313

1414
* Added `\UnzerSDK\Resources\PaymentTypes\ClickToPay` payment method.
15+
* Added constant `\UnzerSDK\Constants\ExemptionType::TRANSACTION_RISK_ANALYSIS` for exemption type "tra".
1516

1617
## [3.6.0](https://github.com/unzerdev/php-sdk/compare/3.5.0..3.6.0)
1718

src/Constants/ExemptionType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
/**
66
* This file contains valid exemption type values
7-
*
8-
* @link https://dev.unzer.com/
9-
*
107
*/
118
class ExemptionType
129
{
1310
public const LOW_VALUE_PAYMENT = 'lvp';
11+
public const TRANSACTION_RISK_ANALYSIS = 'tra';
1412
}

src/Resources/PaymentTypes/Clicktopay.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22

33
namespace UnzerSDK\Resources\PaymentTypes;
44

5-
use UnzerSDK\Adapter\HttpAdapterInterface;
6-
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
75
use UnzerSDK\Traits\CanAuthorize;
86
use UnzerSDK\Traits\CanDirectCharge;
97

108
class Clicktopay extends BasePaymentType
119
{
12-
1310
use CanDirectCharge;
1411
use CanAuthorize;
1512

@@ -18,71 +15,59 @@ class Clicktopay extends BasePaymentType
1815
protected $mcMerchantTransactionId;
1916
protected $brand;
2017

21-
2218
public function __construct(
2319
?string $mcCorrelationId = null,
2420
?string $mcCxFlowId = null,
2521
?string $mcMerchantTransactionId = null,
2622
?string $brand = null
27-
)
28-
{
23+
) {
2924
$this->mcCorrelationId = $mcCorrelationId;
3025
$this->mcCxFlowId = $mcCxFlowId;
3126
$this->mcMerchantTransactionId = $mcMerchantTransactionId;
3227
$this->brand = $brand;
3328
}
3429

35-
36-
public function getMcCorrelationId() : ?string
30+
public function getMcCorrelationId(): ?string
3731
{
3832
return $this->mcCorrelationId;
3933
}
4034

41-
4235
public function getMcCxFlowId(): ?string
4336
{
4437
return $this->mcCxFlowId;
4538
}
4639

47-
4840
public function getBrand(): ?string
4941
{
5042
return $this->brand;
5143
}
5244

53-
5445
public function getMcMerchantTransactionId(): ?string
5546
{
5647
return $this->mcMerchantTransactionId;
5748
}
5849

59-
6050
public function setMcCxFlowId($mcCxFlowId): self
6151
{
6252
$this->mcCxFlowId = $mcCxFlowId;
6353
return $this;
6454
}
6555

66-
6756
public function setMcCorrelationId($mcCorrelationId): self
6857
{
6958
$this->mcCorrelationId = $mcCorrelationId;
7059
return $this;
7160
}
7261

73-
7462
public function setMcMerchantTransactionId($mcMerchantTransactionId): self
7563
{
7664
$this->mcMerchantTransactionId = $mcMerchantTransactionId;
7765
return $this;
7866
}
7967

80-
8168
public function setBrand($brand): self
8269
{
8370
$this->brand = $brand;
8471
return $this;
8572
}
86-
87-
88-
}
73+
}

test/integration/PaymentTypes/CardTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ public function cardShouldBeChargeableWithRecurrenceType($recurrenceType, $isrec
132132
*
133133
* @test
134134
*
135+
* @param mixed $recurrenceType
135136
* @throws UnzerApiException
136137
*
137138
* @dataProvider invalidRecurrenceTypesDP
138139
*
139-
* @param mixed $recurrenceType
140140
*/
141141
public function invalidRecurrenceTypeShouldThrowApiException($recurrenceType): void
142142
{
@@ -259,22 +259,24 @@ public function cardWith3dsFlagShouldSetItAlsoInTransactions(): void
259259
* Verfify card transaction can be used with exemptionType
260260
*
261261
* @test
262+
*
263+
* @dataProvider cardTransactionAcceptsExemptionTypeDP
262264
*/
263-
public function cardTransactionAcceptsExemptionType(): void
265+
public function cardTransactionAcceptsExemptionType(string $exemptionType): void
264266
{
265267
$card = $this->createCardObject();
266268
/** @var Card $card */
267269
$card = $this->unzer->createPaymentType($card);
268270
$charge = new Charge(12.34, 'EUR', 'https://docs.unzer.com');
269271
$cardTransactionData = (new CardTransactionData())
270-
->setExemptionType(ExemptionType::LOW_VALUE_PAYMENT);
272+
->setExemptionType($exemptionType);
271273

272274
$charge->setCardTransactionData($cardTransactionData);
273275
$this->getUnzerObject()->performCharge($charge, $card);
274276

275277
// Verify lvp value gets mapped from response
276278
$fetchedCharge = $this->unzer->fetchChargeById($charge->getPaymentId(), $charge->getId());
277-
$this->assertEquals(ExemptionType::LOW_VALUE_PAYMENT, $fetchedCharge->getCardTransactionData()->getExemptionType());
279+
$this->assertEquals($exemptionType, $fetchedCharge->getCardTransactionData()->getExemptionType());
278280
}
279281

280282
/**
@@ -721,4 +723,12 @@ public function cardTransactionReturnsLiabilityIndicatorDP()
721723
'4012001037461114' => ['4012001037461114']
722724
];
723725
}
726+
727+
public function cardTransactionAcceptsExemptionTypeDP()
728+
{
729+
return [
730+
'lvp' => [ExemptionType::LOW_VALUE_PAYMENT],
731+
'tra' => [ExemptionType::TRANSACTION_RISK_ANALYSIS]
732+
];
733+
}
724734
}

0 commit comments

Comments
 (0)