-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from yabhq/fix/cart-payment-status-codes
Update HTTP response codes for failed payments, readme for cart.js in…
- Loading branch information
Showing
5 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Yab\ShoppingCart\Tests\Feature\Api; | ||
|
||
use Illuminate\Http\Response; | ||
use Yab\ShoppingCart\Models\Cart; | ||
use Yab\ShoppingCart\Tests\TestCase; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Yab\ShoppingCart\Payments\LocalPaymentProvider; | ||
use Yab\ShoppingCart\Payments\FailedPaymentProvider; | ||
use Yab\ShoppingCart\Payments\StripePaymentProvider; | ||
|
||
class CheckoutStripeTest extends TestCase | ||
{ | ||
use RefreshDatabase; | ||
|
||
/** @test */ | ||
public function a_failed_stripe_checkout_returns_an_error_response() | ||
{ | ||
Config::set('stripe.provider', FailedPaymentProvider::class); | ||
|
||
$cart = factory(Cart::class)->create(); | ||
|
||
$response = $this->post(route('checkout.stripe', [ $cart->id ]), [ | ||
'token' => 'tok_123456', | ||
]); | ||
|
||
$response->assertStatus(Response::HTTP_INTERNAL_SERVER_ERROR); | ||
$response->assertJson([ | ||
'message' => 'There was a problem processing the payment', | ||
]); | ||
} | ||
|
||
/** @test */ | ||
public function a_successful_stripe_checkout_returns_a_successful_response() | ||
{ | ||
Config::set('stripe.provider', LocalPaymentProvider::class); | ||
|
||
$cart = factory(Cart::class)->create(); | ||
|
||
$response = $this->post(route('checkout.stripe', [ $cart->id ]), [ | ||
'token' => 'tok_123456', | ||
]); | ||
|
||
$response->assertSuccessful(); | ||
} | ||
} |