Skip to content

Commit 432763d

Browse files
authored
Merge pull request #182 from unzerdev/feature/CC-730/clicktopay
feature/CC-730/clicktopay
2 parents 76f1679 + 6431b35 commit 432763d

File tree

8 files changed

+499
-0
lines changed

8 files changed

+499
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres
66
to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## UNRELEASED
9+
10+
Click To Pay payment method is added to Java SDK.
11+
12+
### Added
13+
14+
* Added `\UnzerSDK\Resources\PaymentTypes\ClickToPay` payment method.
15+
* Added tests for Click To Pay
16+
17+
818
## [3.5.0](https://github.com/unzerdev/php-sdk/compare/3.4.1..3.5.0)
919

1020
This version adds support for Google Pay.

src/Constants/IdStrings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class IdStrings
2525
public const EPS = 'eps';
2626
public const GIROPAY = 'gro';
2727
public const GOOGLE_PAY = 'gop';
28+
public const CLICK_TO_PAY = 'ctp';
2829
public const HIRE_PURCHASE_DIRECT_DEBIT = 'hdd';
2930
public const IDEAL = 'idl';
3031
public const INSTALLMENT_SECURED = 'ins';
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace UnzerSDK\Resources\PaymentTypes;
4+
5+
use UnzerSDK\Adapter\HttpAdapterInterface;
6+
use UnzerSDK\Resources\PaymentTypes\BasePaymentType;
7+
use UnzerSDK\Traits\CanAuthorize;
8+
use UnzerSDK\Traits\CanDirectCharge;
9+
10+
class Clicktopay extends BasePaymentType
11+
{
12+
13+
use CanDirectCharge;
14+
use CanAuthorize;
15+
16+
protected $mcCorrelationId;
17+
protected $mcCxFlowId;
18+
protected $mcMerchantTransactionId;
19+
protected $brand;
20+
21+
22+
public function __construct(
23+
?string $mcCorrelationId = null,
24+
?string $mcCxFlowId = null,
25+
?string $mcMerchantTransactionId = null,
26+
?string $brand = null
27+
)
28+
{
29+
$this->mcCorrelationId = $mcCorrelationId;
30+
$this->mcCxFlowId = $mcCxFlowId;
31+
$this->mcMerchantTransactionId = $mcMerchantTransactionId;
32+
$this->brand = $brand;
33+
}
34+
35+
36+
public function getMcCorrelationId() : ?string
37+
{
38+
return $this->mcCorrelationId;
39+
}
40+
41+
42+
public function getMcCxFlowId(): ?string
43+
{
44+
return $this->mcCxFlowId;
45+
}
46+
47+
48+
public function getBrand(): ?string
49+
{
50+
return $this->brand;
51+
}
52+
53+
54+
public function getMcMerchantTransactionId(): ?string
55+
{
56+
return $this->mcMerchantTransactionId;
57+
}
58+
59+
60+
public function setMcCxFlowId($mcCxFlowId): self
61+
{
62+
$this->mcCxFlowId = $mcCxFlowId;
63+
return $this;
64+
}
65+
66+
67+
public function setMcCorrelationId($mcCorrelationId): self
68+
{
69+
$this->mcCorrelationId = $mcCorrelationId;
70+
return $this;
71+
}
72+
73+
74+
public function setMcMerchantTransactionId($mcMerchantTransactionId): self
75+
{
76+
$this->mcMerchantTransactionId = $mcMerchantTransactionId;
77+
return $this;
78+
}
79+
80+
81+
public function setBrand($brand): self
82+
{
83+
$this->brand = $brand;
84+
return $this;
85+
}
86+
87+
88+
}

src/Services/ResourceService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use UnzerSDK\Exceptions\UnzerApiException;
1111
use UnzerSDK\Resources\Config;
1212
use UnzerSDK\Resources\PaymentTypes\Applepay;
13+
use UnzerSDK\Resources\PaymentTypes\Clicktopay;
1314
use UnzerSDK\Resources\PaymentTypes\Googlepay;
1415
use UnzerSDK\Resources\PaymentTypes\Klarna;
1516
use UnzerSDK\Resources\PaymentTypes\PaylaterDirectDebit;
@@ -824,6 +825,9 @@ public static function getTypeInstanceFromIdString($typeId): BasePaymentType
824825
case IdStrings::GOOGLE_PAY:
825826
$paymentType = new Googlepay();
826827
break;
828+
case IdStrings::CLICK_TO_PAY:
829+
$paymentType = new Clicktopay();
830+
break;
827831
case IdStrings::HIRE_PURCHASE_DIRECT_DEBIT:
828832
case IdStrings::INSTALLMENT_SECURED:
829833
$paymentType = new InstallmentSecured();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"mcCorrelationId": "corr12345",
3+
"mcCxFlowId": "34f4a04b.5ab95e32-30f7-483f-846f-a08230a6d2ed.1618397078",
4+
"mcMerchantTransactionId": "0a4e0d3.34f4a04b.894125b16ddd1f1b3a58273d63a0894179ac3535",
5+
"brand": "mastercard"
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"id": "s-ctp-q0nucec6itwe",
3+
"method": "card",
4+
"recurring": false,
5+
"geoLocation": {
6+
"clientIp": "0:0:0:0:0:0:0:1",
7+
"countryIsoA2": ""
8+
},
9+
"processing": {
10+
"uniqueId": "31HA07BC8127DC45EE6946C3B070FF71",
11+
"shortId": "5550.0369.6888",
12+
"traceId": "24c0a2ecbe3d54a838c76444d4bdcd1f"
13+
}
14+
}

0 commit comments

Comments
 (0)