diff --git a/composer.json b/composer.json index 447e0b5..d9f18f2 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "laravel-tebex-checkout" ], "homepage": "https://github.com/useshimmer/laravel-tebex-checkout", - "license": "MIT", + "license": "GPLv3", "authors": [ { "name": "Robert Dennis", diff --git a/tests/CheckoutTest.php b/tests/CheckoutTest.php new file mode 100644 index 0000000..5893a9d --- /dev/null +++ b/tests/CheckoutTest.php @@ -0,0 +1,38 @@ + MockResponse::fixture('create.checkout.request') + ]); + + $checkout = new TebexCheckout('foo', 'bar'); + $checkout->withMockClient($mockClient); + + $request = new CreateCheckoutRequest( + basket: [ + 'return_url' => 'http://foo.com', + 'complete_url' => 'http://bar.com', + 'custom' => [ + 'baz' => 'buzz' + ] + ], + items: [ + [ + 'package' => [ + 'name' => 'foobar', + 'price' => 12.34 + ] + ] + ] + ); + + $response = $checkout->send($request); + + expect($response->successful())->toBeTrue(); + expect($response->json())->toHaveKey('price', 12.34); +}); diff --git a/tests/ExampleTest.php b/tests/ExampleTest.php deleted file mode 100644 index 5d36321..0000000 --- a/tests/ExampleTest.php +++ /dev/null @@ -1,5 +0,0 @@ -toBeTrue(); -}); diff --git a/tests/Fixtures/Saloon/create.checkout.request.json b/tests/Fixtures/Saloon/create.checkout.request.json new file mode 100644 index 0000000..dc1009d --- /dev/null +++ b/tests/Fixtures/Saloon/create.checkout.request.json @@ -0,0 +1 @@ +{"statusCode":200,"headers":{"Date":"Fri, 31 Mar 2023 00:09:25 GMT","Content-Type":"application\/json","Transfer-Encoding":"chunked","Connection":"keep-alive","CF-Ray":"fake-EWR","Cache-Control":"no-cache, private","Strict-Transport-Security":"max-age=31536000;","CF-Cache-Status":"DYNAMIC","TB-Node":"fake","X-Frame-Options":"SAMEORIGIN","X-VAT-Mode":"exclusive","Set-Cookie":"fake; path=\/; expires=Fri, 31-Mar-23 00:39:25 GMT; domain=.tebex.io; HttpOnly; Secure; SameSite=None","Server":"cloudflare"},"data":"{\"ident\":\"bgew6k-e5479e0f75f302b23947defa7219256a00055e75\",\"expire\":\"2023-04-05 00:09:25\",\"price\":12.34,\"priceDetails\":{\"fullPrice\":12.34,\"subTotal\":12.34,\"discounts\":[],\"total\":12.34,\"surcharges\":[],\"tax\":0,\"balance\":12.34,\"sales\":[],\"giftcards\":[],\"recurring\":null,\"roundUp\":null},\"type\":\"single\",\"recurring\":false,\"recurringPeriod\":null,\"complete\":false,\"tax\":null,\"username\":null,\"discounts\":null,\"coupons\":[],\"giftcards\":[],\"address\":{\"name\":null,\"first_name\":null,\"last_name\":null,\"address\":null,\"email\":null,\"state_id\":null,\"country\":\"XX\",\"postal_code\":null},\"actions\":null,\"game_currency\":null,\"tebex_account_id\":null,\"verified\":null,\"rows\":[{\"id\":151356931,\"basket\":692696684,\"package\":null,\"override\":0,\"quantity\":1,\"server\":null,\"price\":12.34,\"gift_username_id\":null,\"options\":null,\"meta\":{\"name\":\"foobar\",\"rowprice\":12.34,\"initialprice\":12.34,\"isCumulative\":false,\"requiredPackages\":[],\"requiresAny\":false,\"category\":false,\"producesGiftCard\":false,\"allowsGiftCards\":true,\"servers\":[],\"limits\":{\"user\":{\"enabled\":false,\"timestamp\":0,\"limit\":false},\"global\":{\"enabled\":false,\"timestamp\":0,\"limit\":false},\"packageExpiryTime\":0},\"hasDeliverables\":false,\"hasSellerProtection\":true,\"itemType\":null,\"revenue_share\":[],\"realprice\":12.34},\"custom\":null}],\"fingerprint\":null,\"creator_code\":\"\",\"roundup\":null,\"custom\":{\"baz\":\"buzz\"},\"links\":{\"checkout\":\"https:\\\/\\\/checkout.tebex.io\\\/checkout\\\/fake\"}}"} \ No newline at end of file