1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Stripe\Tests; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class GatewayTest |
7
|
|
|
* @package ByTIC\Payments\Stripe\Tests |
8
|
|
|
*/ |
9
|
|
|
class GatewayTest extends AbstractTest |
10
|
|
|
{ |
11
|
|
|
public function test_purchase_redirect() |
12
|
|
|
{ |
13
|
|
|
$gateway = new \ByTIC\Payments\Stripe\Gateway(); |
14
|
|
|
$gateway->initialize(require TEST_FIXTURE_PATH . '/enviromentParams.php'); |
15
|
|
|
|
16
|
|
|
$parameters = require TEST_FIXTURE_PATH . '/requests/Purchase/baseRequest.php'; |
17
|
|
|
|
18
|
|
|
$parameters['returnUrl'] = 'http://test.com'; |
19
|
|
|
$request = $gateway->purchase($parameters); |
20
|
|
|
$response = $request->send(); |
21
|
|
|
|
22
|
|
|
$sessionId = $response->getSessionID(); |
|
|
|
|
23
|
|
|
$content = $response->getViewContent(); |
|
|
|
|
24
|
|
|
self::assertContains('stripe.redirectToCheckout({', $content); |
25
|
|
|
self::assertContains('sessionId:', $content); |
26
|
|
|
self::assertContains($sessionId, $content); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function test_purchase_connected_account() |
30
|
|
|
{ |
31
|
|
|
$gateway = new \ByTIC\Payments\Stripe\Gateway(); |
32
|
|
|
$gateway->initialize(require TEST_FIXTURE_PATH . '/enviromentParams.php'); |
33
|
|
|
|
34
|
|
|
$parameters = require TEST_FIXTURE_PATH . '/requests/Purchase/baseRequest.php'; |
35
|
|
|
$parameters['returnUrl'] = 'http://test.com'; |
36
|
|
|
|
37
|
|
|
$parameters['application_fee_amount'] = '3.0'; |
38
|
|
|
$accountId = getenv('STRIPE_CONNECTED_ID'); |
39
|
|
|
$parameters['on_behalf_of'] = $accountId; |
40
|
|
|
|
41
|
|
|
$request = $gateway->purchase($parameters); |
42
|
|
|
$response = $request->send(); |
43
|
|
|
|
44
|
|
|
$sessionId = $response->getSessionID(); |
45
|
|
|
$content = $response->getViewContent(); |
46
|
|
|
self::assertContains('stripe.redirectToCheckout({', $content); |
47
|
|
|
self::assertContains('sessionId:', $content); |
48
|
|
|
self::assertContains($sessionId, $content); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|