Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check user is trying to checkout with current cart #2901

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/Http/Controllers/Store/CheckoutController.php
Expand Up @@ -87,12 +87,20 @@ public function show()
public function store()
{
$order = $this->userCart();
$orderId = get_int(request('orderId'));
$provider = request('provider');

if ($order->isEmpty()) {
return ujs_redirect(route('store.cart.show'));
}

$provider = Request::input('provider');
// check that we aren't checking out using some ancient cart;
// otherwise the Xsolla client will use the stale cart.
if ($order->order_id !== $orderId) {
return $this->setAndRedirectCheckoutError(
trans('store.checkout.old_cart')
);
}

$checkout = new OrderCheckout($order, $provider);
$checkout->beginCheckout();
Expand Down
3 changes: 2 additions & 1 deletion resources/assets/lib/store-checkout.coffee
Expand Up @@ -37,13 +37,14 @@ export class StoreCheckout

$(@CHECKOUT_SELECTOR).on 'click.checkout', (event) =>
provider = event.target.dataset.provider
orderId = event.target.dataset.orderId

This comment was marked as off-topic.

This comment was marked as off-topic.

# sanity
return unless provider?
LoadingOverlay.show()
LoadingOverlay.show.flush()

init[provider]?.then =>
$.post laroute.route('store.checkout.store'), provider: provider
$.post laroute.route('store.checkout.store'), { provider, orderId }
.done =>
@startPayment(event.target.dataset)

Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/store.php
Expand Up @@ -28,6 +28,7 @@
'cart_problems_edit' => 'Click here to go edit it.',
'declined' => 'The payment was cancelled.',
'error' => 'There was a problem completing your checkout :(',
'old_cart' => 'Your cart appears to be out of date and has been reloaded, please try again.',
'pay' => 'Checkout with Paypal',
'pending_checkout' => [
'line_1' => 'A previous checkout was started but did not finish.',
Expand Down
1 change: 1 addition & 0 deletions resources/views/store/_checkout_centili.blade.php
Expand Up @@ -21,6 +21,7 @@
<button type="button"
class="js-store-checkout-button store-payment-button store-payment-button--centili"
data-provider="centili"
data-order-id="{{ $order->order_id }}"
data-url="{{ $checkout->getCentiliPaymentLink() }}"
>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/views/store/_checkout_free.blade.php
Expand Up @@ -19,6 +19,7 @@
<button type="button"
class="js-store-checkout-button btn-osu btn-osu-danger"
data-provider="free"
data-order-id="{{ $order->order_id }}"
data-order-number="{{ $order->getOrderNumber() }}"
>
Complete Order
Expand Down
1 change: 1 addition & 0 deletions resources/views/store/_checkout_xsolla.blade.php
Expand Up @@ -21,6 +21,7 @@
<button type="button"
class="js-store-checkout-button store-payment-button store-payment-button--xsolla"
data-provider="xsolla"
data-order-id="{{ $order->order_id }}"
data-order-number="{{ $order->getOrderNumber() }}"
>
</button>
Expand Down