24
24
namespace Adyen \Tests \Unit ;
25
25
26
26
use Adyen \Service \PaymentsApp \PaymentsAppApi ;
27
+ use Adyen \Model \PaymentsApp \BoardingTokenRequest ;
27
28
use Adyen \AdyenException ;
28
29
29
30
class PaymentsAppTest extends TestCaseMock
@@ -37,13 +38,14 @@ public function testGeneratePaymentsAppBoardingTokenForMerchantSuccess($jsonFile
37
38
38
39
$ paymentsAppApi = new PaymentsAppApi ($ client );
39
40
40
- $ requestParams = [
41
- 'boardingRequestToken ' => 'mockedRequestToken '
42
- ];
41
+ $ json = '{[
42
+ "boardingRequestToken": "mockedRequestToken"
43
+ ]} ' ;
44
+ $ params = new BoardingTokenRequest (json_decode ($ json , true ));
43
45
44
46
$ response = $ paymentsAppApi ->generatePaymentsAppBoardingTokenForMerchant (
45
47
"MerchantAccount123 " ,
46
- $ requestParams
48
+ $ params
47
49
);
48
50
49
51
$ this ->assertNotNull ($ response );
@@ -59,20 +61,21 @@ public function testGeneratePaymentsAppBoardingTokenForMerchantError($jsonFile,
59
61
$ client = $ this ->createMockClient ($ jsonFile , $ httpStatus );
60
62
$ paymentsAppApi = new PaymentsAppApi ($ client );
61
63
62
- $ requestParams = [
63
- 'boardingRequestToken ' => 'mockedRequestToken '
64
- ];
64
+ $ json = '{[
65
+ "boardingRequestToken": "mockedRequestToken"
66
+ ]} ' ;
67
+ $ params = new BoardingTokenRequest (json_decode ($ json , true ));
65
68
66
69
try {
67
70
$ paymentsAppApi ->generatePaymentsAppBoardingTokenForMerchant (
68
71
"MerchantAccount123 " ,
69
- $ requestParams
72
+ $ params
70
73
);
71
74
$ this ->fail (AdyenException::class . " expected " );
72
75
} catch (AdyenException $ e ) {
73
76
$ this ->assertEquals (403 , $ e ->getStatus ()); // Assuming AdyenException has getStatus() or public status $status
74
77
// Assumes the error message from boardingToken-error-403.json contains "PA001"
75
- $ this ->assertStringContainsString ("PA001 " , $ e ->getMessage ());
78
+ $ this ->assertStringContainsString ("PA001 " , $ e ->getAdyenErrorCode ());
76
79
}
77
80
}
78
81
@@ -84,14 +87,15 @@ public function testGeneratePaymentsAppBoardingTokenForStoreSuccess($jsonFile, $
84
87
$ client = $ this ->createMockClient ($ jsonFile , $ httpStatus );
85
88
$ paymentsAppApi = new PaymentsAppApi ($ client );
86
89
87
- $ requestParams = [
88
- 'boardingRequestToken ' => 'mockedRequestToken '
89
- ];
90
+ $ json = '{[
91
+ "boardingRequestToken": "mockedRequestToken"
92
+ ]} ' ;
93
+ $ params = new BoardingTokenRequest (json_decode ($ json , true ));
90
94
91
95
$ response = $ paymentsAppApi ->generatePaymentsAppBoardingTokenForStore (
92
96
"MerchantAccount123 " ,
93
97
"StoreEU " ,
94
- $ requestParams
98
+ $ params
95
99
);
96
100
97
101
$ this ->assertNotNull ($ response );
@@ -107,20 +111,21 @@ public function testGeneratePaymentsAppBoardingTokenForStoreError($jsonFile, $ht
107
111
$ client = $ this ->createMockClient ($ jsonFile , $ httpStatus );
108
112
$ paymentsAppApi = new PaymentsAppApi ($ client );
109
113
110
- $ requestParams = [
111
- 'boardingRequestToken ' => 'mockedRequestToken '
112
- ];
114
+ $ json = '{[
115
+ "boardingRequestToken": "mockedRequestToken"
116
+ ]} ' ;
117
+ $ params = new BoardingTokenRequest (json_decode ($ json , true ));
113
118
114
119
try {
115
120
$ paymentsAppApi ->generatePaymentsAppBoardingTokenForStore (
116
121
"MerchantAccount123 " ,
117
122
"StoreEU " ,
118
- $ requestParams
123
+ $ params
119
124
);
120
125
$ this ->fail (AdyenException::class . " expected " );
121
126
} catch (AdyenException $ e ) {
122
127
$ this ->assertEquals (403 , $ e ->getStatus ());
123
- $ this ->assertStringContainsString ("PA001 " , $ e ->getMessage ());
128
+ $ this ->assertStringContainsString ("Merchant not permitted for this action. " , $ e ->getMessage ());
124
129
}
125
130
}
126
131
@@ -154,7 +159,7 @@ public function testListPaymentsAppForMerchantError($jsonFile, $httpStatus)
154
159
} catch (AdyenException $ e ) {
155
160
$ this ->assertEquals (500 , $ e ->getStatus ());
156
161
// Assumes the error message from paymentsAppList-error-500.json contains "PA002"
157
- $ this ->assertStringContainsString ("PA002 " , $ e ->getMessage ());
162
+ $ this ->assertStringContainsString ("PA002 " , $ e ->getAdyenErrorCode ());
158
163
}
159
164
}
160
165
0 commit comments