-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
202 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
composer.lock | ||
vendor |
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,47 @@ | ||
# Rapidez MultiSafePay | ||
|
||
## Requirements | ||
|
||
You need the [MultiSafePay Magento 2](https://github.com/MultiSafepay/Magento2) and [MultiSafePay Magento 2 GraphQL](https://github.com/MultiSafepay/magento2-graphql) modules installed in your Magento 2 installation. | ||
|
||
### Temporary notice | ||
|
||
The magento2 core package from MultiSafePay currently contains a bug that prevents guest checkout from working. You can use [version 2.19.1 from this fork](https://github.com/Jade-GG/magento2-core) until the PR fixing this has been merged into the official repository. | ||
|
||
## Installation | ||
|
||
``` | ||
composer require rapidez/multisafepay | ||
``` | ||
|
||
And import the JS into your `resources/js/app.js`: | ||
|
||
``` | ||
import 'Vendor/rapidez/multisafepay/resources/js/multisafepay.js'; | ||
``` | ||
|
||
Then, in your magento -> configuration -> multisafepay -> general settings, enable custom return urls for PWA and use the following return URLs: | ||
|
||
``` | ||
[your base rapidez url]/msp-return/cancel?quoteId={{quote.masked_id}} | ||
[your base rapidez url]/msp-return/success?secureToken={{secure_token}}&orderId={{order.increment_id}}&paymentCode={{payment.code}} | ||
``` | ||
|
||
Finally, note that MultiSafePay needs these magento URLs to work: | ||
|
||
``` | ||
[your base magento url]/multisafepay/connect/success?[...] | ||
[your base magento url]/multisafepay/connect/cancel?[...] | ||
[your base magento url]/multisafepay/connect/notification?[...] | ||
``` | ||
|
||
You will have to update your deployment to open up these specific URLs (i.e. to not redirect these to your rapidez frontend). | ||
For example, for a standard rapidez installation you can update the regex as seen in the [Rapidez docs deployment page](https://docs.rapidez.io/0.x/deployment.html#redirecting-magento-to-rapidez) to include `multisafepay`. | ||
|
||
## Views | ||
|
||
You can publish the views with the following command: | ||
|
||
``` | ||
php artisan vendor:publish --provider="Rapidez\MultiSafePay\MultiSafePayServiceProvider" --tag=views | ||
``` |
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,32 @@ | ||
{ | ||
"name": "rapidez/multisafepay", | ||
"description": "MultiSafePay support for Rapidez", | ||
"autoload": { | ||
"psr-4": { | ||
"Rapidez\\Multisafepay\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Jade Geels", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"require": { | ||
"php": "^8.0|^8.1", | ||
"illuminate/support": "^9.0", | ||
"rapidez/core": "~0.54" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Rapidez\\Multisafepay\\MultiSafePayServiceProvider" | ||
] | ||
} | ||
} | ||
} |
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,37 @@ | ||
<script> | ||
export default { | ||
props: { | ||
order: Object | ||
}, | ||
data() { | ||
return { | ||
completed: false, | ||
} | ||
}, | ||
mounted() { | ||
this.order.customer_email = window.localStorage.email; | ||
this.checkStatus(); | ||
}, | ||
render() { | ||
return this.$scopedSlots.default({ | ||
completed: this.completed, | ||
order: this.order | ||
}) | ||
}, | ||
methods: { | ||
async checkStatus() { | ||
magento.get(`/multisafepay/orders/${this.order.increment_id}/${this.order.secure_token}`).then(response => { | ||
if(['processing', 'success'].includes(response.data?.status)) { | ||
this.completed = true; | ||
} else { | ||
window.setTimeout(this.checkStatus, 2000); | ||
} | ||
}) | ||
} | ||
}, | ||
} | ||
</script> |
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,15 @@ | ||
import MSPPending from './components/MSPPending.vue' | ||
Vue.component('msp-pending', MSPPending) | ||
|
||
document.addEventListener('turbo:load', () => { | ||
window.app.$on('checkout-payment-saved', (data) => { | ||
if (!data.order.payment_method_code.includes('multisafepay_')) { | ||
return; | ||
} | ||
window.app.checkout.doNotGoToTheNextStep = true | ||
let cart = window.app.user ? 'mine' : localStorage.mask; | ||
magentoUser.get(`/multisafepay/${cart}/payment-url/${data.order.id}`).then(response => { | ||
window.location.replace(response.data); | ||
}); | ||
}); | ||
}) |
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,7 @@ | ||
@extends('rapidez::layouts.app') | ||
|
||
@section('title', 'Checkout') | ||
|
||
@section('content') | ||
<graphql query='mutation { restoreQuote(input: {cart_id:"{{ $quoteId }}"}) }' check="restoreQuote" redirect="/checkout"></graphql> | ||
@endsection |
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,3 @@ | ||
<h1 class="font-bold text-4xl mb-5">@lang('Pending payment')</h1> | ||
<p>@lang('We did not receive the payment (yet). This page will auto-update every 2 seconds.')</p> | ||
<p>@lang('Are you still seeing this page after a minute? Please contact us.')</p> |
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,18 @@ | ||
@extends('rapidez::layouts.app') | ||
|
||
@section('title', 'Checkout') | ||
|
||
@section('content') | ||
<div class="container"> | ||
<msp-pending :order='@json($t_order)' v-cloak> | ||
<div slot-scope="{ completed, order }"> | ||
<div v-if="completed"> | ||
@include('rapidez::checkout.steps.success') | ||
</div> | ||
<div v-else> | ||
@include('multisafepay::pending') | ||
</div> | ||
</div> | ||
</msp-pending> | ||
</div> | ||
@endsection |
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,21 @@ | ||
<?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]); | ||
})->name('multisafepay.success'); | ||
Route::get('/msp-return/cancel', function(Request $request) { | ||
return view('multisafepay::cancel', ['quoteId' => $request->get('quoteId')]); | ||
})->name('multisafepay.cancel'); | ||
}); |
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,20 @@ | ||
<?php | ||
|
||
namespace Rapidez\MultiSafePay; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
|
||
class MultiSafePayServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
$this->loadRoutesFrom(__DIR__.'/../routes/web.php'); | ||
$this->loadViewsFrom(__DIR__.'/../resources/views', 'multisafepay'); | ||
|
||
if($this->app->runningInConsole()) { | ||
$this->publishes([ | ||
__DIR__.'/../resources/views' => resource_path('views/vendor/multisafepay'), | ||
], 'views'); | ||
} | ||
} | ||
} |