|
13 | 13 | ); |
14 | 14 | $merchant_api = new MerchantApi($api_client); |
15 | 15 |
|
| 16 | +//test('Invalid endpoint', function() { |
| 17 | +// global $api_client; |
| 18 | +// try { |
| 19 | +// $api_client->call('GET', '/invalid', ['some' => 'data']); |
| 20 | +// expect(true)->toBeFalse(); // make sure we don't hit this line |
| 21 | +// } catch (SettleApiException $e) { |
| 22 | +// expect($e->getCode())->toBe(404); |
| 23 | +// expect($e->getMessage())->toBe("The resource could not be found."); |
| 24 | +// } |
| 25 | +//}); |
| 26 | + |
16 | 27 | test('API: Api Keys', function() { |
17 | 28 | global $merchant_api; |
18 | 29 |
|
|
159 | 170 | expect($outcome['status'])->toBe('fail'); |
160 | 171 | }); |
161 | 172 |
|
| 173 | +test('Permission Requests', function() { |
| 174 | + global $merchant_api; |
| 175 | + |
| 176 | + $request = $merchant_api->permission_requests->get('e5t4uwmmxz2rygtvwcse382xt3ddv4zd'); |
| 177 | + expect($request['customer'])->toBe('token:5647354929610752'); |
| 178 | + |
| 179 | + $request = $merchant_api->permission_requests->outcome('e5t4uwmmxz2rygtvwcse382xt3ddv4zd'); |
| 180 | + expect($request['status'])->toBe('ok'); |
| 181 | +}); |
| 182 | + |
162 | 183 | test('API [not working]: Settlements', function() { |
163 | 184 | global $merchant_api; |
164 | 185 |
|
|
206 | 227 |
|
207 | 228 | test('API: Links', function() { |
208 | 229 | global $api_client, $merchant_api; |
| 230 | + $deepLinkBase = 'https://settledemo.page.link?apn=eu.settle.app.sandbox&ibi=eu.settle.app.sandbox&isi=1453180781&ius=eu.settle.app.firebaselink&link=https%3A%2F%2Fsettle-demo%3A%2F%2Fqr%2F'; |
209 | 231 | $api_client->setIsSandbox(true); |
| 232 | + $requests_api = $merchant_api->payment_requests; |
| 233 | + $short_links_api = $merchant_api->short_links; |
210 | 234 |
|
211 | 235 | // Global |
212 | | - expect($api_client->createLink('missing'))->toBe(SettleApiClient::SETTLE_LINK); |
213 | | - expect($api_client->createLink(SettleApiClient::LINK_TEMPLATE_PAYMENT))->toBe(SettleApiClient::PAYMENT_LINK); |
214 | | - expect($api_client->createLink(SettleApiClient::LINK_TEMPLATE_SHORT_LINK))->toBe(SettleApiClient::SHORT_LINK_LINK); |
215 | | - |
216 | | - // Payment Requests |
217 | | - $api = $merchant_api->payment_requests; |
218 | | - expect($api->getLink('pcqghkrpztq1'))->toBe('http://settle.eu/p/pcqghkrpztq1/'); |
219 | | - expect($api->getLink('pcqghkrpztq1', ['a' => 'b', 'c' => 1]))->toBe('http://settle.eu/p/pcqghkrpztq1/a=b&c=1'); |
220 | | - |
221 | | - // Deep links |
222 | | - $deepLink = 'https://settledemo.page.link?apn=eu.settle.app.sandbox&ibi=eu.settle.app.sandbox&isi=1453180781&ius=eu.settle.app.firebaselink&link=https%3A%2F%2Fsettle-demo%3A%2F%2Fqr%2Fhttp%3A%2F%2Fsettle.eu%2Fp%2Fpypz44mcswz3%2F'; |
223 | | - expect($api->getDeepLink('pypz44mcswz3'))->toBe($deepLink); |
224 | | - expect($api_client->getDeepLink('http://settle.eu/p/pypz44mcswz3/'))->toBe($deepLink); |
225 | | - |
| 236 | + expect($api_client->getLink('missing'))->toBe(SettleApiClient::SETTLE_LINK); |
| 237 | + expect($api_client->getLink(SettleApiClient::LINK_TEMPLATE_PAYMENT))->toBe(SettleApiClient::PAYMENT_LINK); |
| 238 | + expect($api_client->getLink(SettleApiClient::LINK_TEMPLATE_SHORT_LINK))->toBe(SettleApiClient::SHORT_LINK_LINK); |
| 239 | + |
| 240 | + // Payment Request Link |
| 241 | + $payment_request_link = 'http://settle.eu/p/pcqghkrpztq1/'; |
| 242 | + expect($requests_api->getLink('pcqghkrpztq1'))->toBe($payment_request_link); |
| 243 | + |
| 244 | + $extra_data = ['a' => 'b', 'c' => 1]; |
| 245 | + expect($requests_api->getLink('pcqghkrpztq1', $extra_data)) |
| 246 | + ->toBe($payment_request_link . http_build_query($extra_data)); |
| 247 | + |
| 248 | + // Payment Request Deep link |
| 249 | + $deepLink = $deepLinkBase . urlencode($payment_request_link); |
| 250 | + expect($requests_api->getDeepLink('pcqghkrpztq1'))->toBe($deepLink); |
| 251 | + expect($api_client->getDeepLink($payment_request_link))->toBe($deepLink); |
| 252 | + |
| 253 | + // Short Links |
| 254 | + $short_link = 'http://settle.eu/s/N4JEV/'; |
| 255 | + expect($short_links_api->getLink('N4JEV'))->toBe($short_link); |
| 256 | + expect($short_links_api->getDeepLink('N4JEV'))->toBe($deepLinkBase . urlencode($short_link)); |
226 | 257 | }); |
227 | 258 |
|
228 | 259 | test('API: Utility', function() { |
|
0 commit comments