Skip to content

Commit 624dbbe

Browse files
committed
PHPSDK-178: Extend PaymentDetails object, including Card Payment related information (#385)
1 parent d1557ac commit 624dbbe

File tree

13 files changed

+649
-5
lines changed

13 files changed

+649
-5
lines changed

src/Api/Transactions/TransactionResponse/PaymentDetails.php

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
namespace MultiSafepay\Api\Transactions\TransactionResponse;
88

99
use MultiSafepay\Api\Base\DataObject;
10+
use MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails\CardAuthenticationDetails;
11+
use MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails\CardAuthenticationResult;
1012

1113
/**
1214
* Class PaymentDetails
@@ -118,4 +120,108 @@ public function getCaptureRemain(): int
118120
{
119121
return (int)$this->get('capture_remain');
120122
}
123+
124+
/**
125+
* @return string
126+
*/
127+
public function getRecurringFlow(): string
128+
{
129+
return (string)$this->get('recurring_flow');
130+
}
131+
132+
/**
133+
* @return string
134+
*/
135+
public function getRecurringModel(): string
136+
{
137+
return (string)$this->get('recurring_model');
138+
}
139+
140+
/**
141+
* @return string
142+
*/
143+
public function getResponseCode(): string
144+
{
145+
return (string)$this->get('response_code');
146+
}
147+
148+
/**
149+
* @return string
150+
*/
151+
public function getAuthorizationCode(): string
152+
{
153+
return (string)$this->get('authorization_code');
154+
}
155+
156+
/**
157+
* @return string
158+
*/
159+
public function getCardAcceptorId(): string
160+
{
161+
return (string)$this->get('card_acceptor_id');
162+
}
163+
164+
/**
165+
* @return string
166+
*/
167+
public function getCardAcceptorLocation(): string
168+
{
169+
return (string)$this->get('card_acceptor_location');
170+
}
171+
172+
/**
173+
* @return string
174+
*/
175+
public function getCardAcceptorName(): string
176+
{
177+
return (string)$this->get('card_acceptor_name');
178+
}
179+
180+
/**
181+
* @return string
182+
*/
183+
public function getCardEntryMode(): string
184+
{
185+
return (string)$this->get('card_entry_mode');
186+
}
187+
188+
/**
189+
* @return string
190+
*/
191+
public function getCardVerificationResult(): string
192+
{
193+
return (string)$this->get('card_verification_result');
194+
}
195+
196+
/**
197+
* @return string
198+
*/
199+
public function getMcc(): string
200+
{
201+
return (string)$this->get('mcc');
202+
}
203+
204+
/**
205+
* @return string
206+
*/
207+
public function getSchemeReferenceId(): string
208+
{
209+
return (string)$this->get('scheme_reference_id');
210+
}
211+
212+
/**
213+
* @return CardAuthenticationDetails
214+
*/
215+
public function getCardAuthenticationDetails(): CardAuthenticationDetails
216+
{
217+
return new CardAuthenticationDetails((array)$this->get('card_authentication_details'));
218+
}
219+
220+
/**
221+
* @return CardAuthenticationResult
222+
*/
223+
public function getCardAuthenticationResult(): CardAuthenticationResult
224+
{
225+
return new CardAuthenticationResult((array)$this->get('card_authentication_result'));
226+
}
121227
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* Copyright © MultiSafepay, Inc. All rights reserved.
4+
* See DISCLAIMER.md for disclaimer details.
5+
*/
6+
7+
namespace MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails;
8+
9+
use MultiSafepay\Api\Base\DataObject;
10+
11+
/**
12+
* Class CardAuthenticationDetails
13+
* @package MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails
14+
*/
15+
class CardAuthenticationDetails extends DataObject
16+
{
17+
/**
18+
* Get the card authentication flow.
19+
*
20+
* @return string|null
21+
*/
22+
public function getFlow(): ?string
23+
{
24+
return $this->get('flow');
25+
}
26+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* Copyright © MultiSafepay, Inc. All rights reserved.
4+
* See DISCLAIMER.md for disclaimer details.
5+
*/
6+
7+
namespace MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails;
8+
9+
use MultiSafepay\Api\Base\DataObject;
10+
11+
/**
12+
* Class CardAuthenticationResult
13+
* @package MultiSafepay\Api\Transactions\TransactionResponse\PaymentDetails
14+
*/
15+
class CardAuthenticationResult extends DataObject
16+
{
17+
/**
18+
* Get the ACS transaction ID.
19+
*
20+
* @return string|null
21+
*/
22+
public function getAcsTransactionId(): ?string
23+
{
24+
return $this->get('acs_transaction_id');
25+
}
26+
27+
/**
28+
* Get the chargeback liability.
29+
*
30+
* @return string|null
31+
*/
32+
public function getChargebackLiability(): ?string
33+
{
34+
return $this->get('chargeback_liability');
35+
}
36+
37+
/**
38+
* Get the DS transaction ID.
39+
*
40+
* @return string|null
41+
*/
42+
public function getDsTransactionId(): ?string
43+
{
44+
return $this->get('ds_transaction_id');
45+
}
46+
47+
/**
48+
* Get the status of the card authentication result.
49+
*
50+
* @return string|null
51+
*/
52+
public function getStatus(): ?string
53+
{
54+
return $this->get('status');
55+
}
56+
57+
/**
58+
* Get the version of the card authentication result.
59+
*
60+
* @return string|null
61+
*/
62+
public function getVersion(): ?string
63+
{
64+
return $this->get('version');
65+
}
66+
67+
/**
68+
* Get the CAVV (Cardholder Authentication Verification Value).
69+
*
70+
* @return string|null
71+
*/
72+
public function getCavv(): ?string
73+
{
74+
return $this->get('cavv');
75+
}
76+
77+
/**
78+
* Get the ECI (Electronic Commerce Indicator).
79+
*
80+
* @return string|null
81+
*/
82+
public function getEci(): ?string
83+
{
84+
return $this->get('eci');
85+
}
86+
87+
/**
88+
* Get the challenge cancel status.
89+
*
90+
* @return string|null
91+
*/
92+
public function getChallengeCancel(): ?string
93+
{
94+
return $this->get('challenge_cancel');
95+
}
96+
97+
/**
98+
* Get the transaction status reason.
99+
*
100+
* @return string|null
101+
*/
102+
public function getTransactionStatusReason(): ?string
103+
{
104+
return $this->get('transaction_status_reason');
105+
}
106+
}

src/Api/Transactions/TransactionResponse/RelatedTransaction.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,20 @@ public function getTransactionId(): string
8686
{
8787
return (string)$this->get('transaction_id');
8888
}
89+
90+
/**
91+
* @return string
92+
*/
93+
public function getType(): string
94+
{
95+
return (string)$this->get('type');
96+
}
97+
98+
/**
99+
* @return string
100+
*/
101+
public function getOrderId(): string
102+
{
103+
return (string)$this->get('order_id');
104+
}
89105
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* Copyright © MultiSafepay, Inc. All rights reserved.
4+
* See DISCLAIMER.md for disclaimer details.
5+
*/
6+
7+
namespace MultiSafepay\Tests\Fixtures\OrderRequest\Arguments;
8+
9+
use Faker\Factory as FakerFactory;
10+
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\GatewayInfo\Creditcard;
11+
use MultiSafepay\Tests\Utils\Locale;
12+
13+
/**
14+
* Trait CreditCardGatewayInfoFixture
15+
* @package MultiSafepay\Tests\Fixtures\OrderRequest\Arguments
16+
*/
17+
trait CreditCardGatewayInfoFixture
18+
{
19+
/**
20+
* @return Creditcard
21+
*/
22+
public function createCreditCardGatewayInfoFixture(): Creditcard
23+
{
24+
$countryCode = $this->createCountryCodeFixture();
25+
$faker = FakerFactory::create(Locale::getLocaleByCountryCode($countryCode));
26+
27+
return (new Creditcard)
28+
->addCardHolderName($faker->name)
29+
->addCardNumberAsString('4111111111111111')
30+
->addCardExpiryDateAsString($faker->date('Y-m-d', '5 years from now'))
31+
->addCvcAsString($faker->numerify('###'));
32+
}
33+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php declare(strict_types=1);
2+
namespace MultiSafepay\Tests\Functional\Api\Transactions;
3+
4+
use MultiSafepay\Api\Transactions\OrderRequest;
5+
use MultiSafepay\Exception\ApiException;
6+
use MultiSafepay\Tests\Fixtures\Api\Gateways\GatewayFixture;
7+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\CheckoutOptionsFixture;
8+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\CreditCardGatewayInfoFixture;
9+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\CustomerDetailsFixture;
10+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\DescriptionFixture;
11+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\PaymentOptionsFixture;
12+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\PluginDetailsFixture;
13+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\ShoppingCartFixture;
14+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\ShoppingCartWithTaxFixture;
15+
use MultiSafepay\Tests\Fixtures\OrderRequest\Arguments\TaxTableFixture;
16+
use MultiSafepay\Tests\Fixtures\OrderRequest\GenericOrderRequestFixture;
17+
use MultiSafepay\Tests\Fixtures\ValueObject\AddressFixture;
18+
use MultiSafepay\Tests\Fixtures\ValueObject\CountryFixture;
19+
use MultiSafepay\Tests\Fixtures\ValueObject\PhoneNumberFixture;
20+
use MultiSafepay\Tests\Functional\AbstractTestCase;
21+
use MultiSafepay\ValueObject\Amount;
22+
use MultiSafepay\ValueObject\Currency;
23+
use Psr\Http\Client\ClientExceptionInterface;
24+
25+
/**
26+
* Class CreateVisaDirectOrderTest
27+
* @package MultiSafepay\Tests\Functional\Api\Transactions
28+
*/
29+
class CreateVisaDirectOrderTest extends AbstractTestCase
30+
{
31+
use GenericOrderRequestFixture;
32+
use CustomerDetailsFixture;
33+
use PaymentOptionsFixture;
34+
use AddressFixture;
35+
use ShoppingCartFixture;
36+
use ShoppingCartWithTaxFixture;
37+
use TaxTableFixture;
38+
use CreditCardGatewayInfoFixture;
39+
use PluginDetailsFixture;
40+
use DescriptionFixture;
41+
use CheckoutOptionsFixture;
42+
use PhoneNumberFixture;
43+
use CountryFixture;
44+
45+
/**
46+
* @throws ClientExceptionInterface
47+
*/
48+
public function testCreateVisaDirectOrder()
49+
{
50+
try {
51+
$requestOrder = $this->createOrderRequest();
52+
$response = $this->getClient()->createPostRequest('json/orders', $requestOrder);
53+
} catch (ApiException $apiException) {
54+
$this->assertTrue(false, $apiException->getDetails());
55+
return;
56+
}
57+
58+
$data = $response->getResponseData();
59+
$this->assertIsNumeric($data['order_id']);
60+
$this->assertNotEmpty($data['transaction_id']);
61+
$this->assertNotEmpty($data['payment_url']);
62+
}
63+
64+
/**
65+
* @return OrderRequest
66+
*/
67+
private function createOrderRequest(): OrderRequest
68+
{
69+
return $this->createGenericOrderRequestFixture()
70+
->addType('direct')
71+
->addAmount(new Amount(10000))
72+
->addCurrency(new Currency('EUR'))
73+
->addGatewayCode(GatewayFixture::VISA)
74+
->addGatewayInfo($this->createCreditCardGatewayInfoFixture())
75+
->addPaymentOptions($this->createPaymentOptionsFixture());
76+
}
77+
}

tests/Integration/Api/Transactions/OrderRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See DISCLAIMER.md for disclaimer details.
55
*/
66

7-
namespace MultiSafepay\Tests\Api\Integration\Transactions;
7+
namespace MultiSafepay\Tests\Integration\Api\Transactions;
88

99
use Faker\Factory as FakerFactory;
1010
use MultiSafepay\Api\Transactions\OrderRequest\Arguments\ShoppingCart;

0 commit comments

Comments
 (0)