Skip to content

Commit

Permalink
Get params from URL & send order data as found in the MSP response fo…
Browse files Browse the repository at this point in the history
…r checkout success (#4)
  • Loading branch information
Jade-GG authored Feb 27, 2023
1 parent cc67938 commit a0253eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
20 changes: 15 additions & 5 deletions resources/js/components/MSPPending.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
<script>
export default {
props: {
order: Object
},
data() {
return {
completed: false,
order: {},
}
},
Expand All @@ -24,9 +21,22 @@
methods: {
async checkStatus() {
magento.get(`/multisafepay/orders/${this.order.increment_id}/${this.order.secure_token}`).then(response => {
this.params = Object.fromEntries(new URLSearchParams(window.location.search).entries());
let token = this.params.secureToken ?? null;
let orderId = this.params.orderId ?? null;
if(!token || !orderId) {
return;
}
magento.get(`/multisafepay/orders/${orderId}/${token}`).then(response => {
if(['processing', 'success'].includes(response.data?.status)) {
this.completed = true;
this.order = {
increment_id: orderId,
payment_method: response.data.payment.method,
shipping_method: response.data.shipping_description,
email: response.data.customer_email,
}
} else {
window.setTimeout(this.checkStatus, 2000);
}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/success.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

@section('content')
<div class="container">
<msp-pending :order='@json($t_order)' v-cloak>
<msp-pending v-cloak>
<div slot-scope="{ completed, order }">
<div v-if="completed">
@include('rapidez::checkout.steps.success')
Expand Down
10 changes: 1 addition & 9 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Route;

Route::middleware('web')->group(function () {
Route::get('/msp-return/success', function(Request $request) {
$order = (object)[
'increment_id' => $request->get('orderId'),
'secure_token' => $request->get('secureToken'),
'payment_method' => $request->get('paymentCode'),
];

return view('multisafepay::success', ['t_order' => $order]);
return view('multisafepay::success');
})->name('multisafepay.success');
Route::get('/msp-return/cancel', function(Request $request) {
return view('multisafepay::cancel', ['quoteId' => $request->get('quoteId')]);
Expand Down

0 comments on commit a0253eb

Please sign in to comment.