Skip to content

Commit

Permalink
keep internal package routes and test them
Browse files Browse the repository at this point in the history
  • Loading branch information
RoduanKD committed Feb 19, 2022
1 parent 436ac3e commit 8b2980f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion resources/views/init.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
// Default: ['creditcard', 'applepay', 'stcpay']
methods: @json($methods ?? config('moyasar.methods')),
on_complete: {{ $on_complete ?? route(config('moyasar.on_complete_url')) }}
on_complete: '{{ $on_complete ?? route(config('moyasar.on_complete_url')) }}'
})
</script>
10 changes: 7 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

use Illuminate\Support\Facades\Route;

// Route::get('memberships/{membership}/payment/thanks', function () {
// return 'working';
// })->name('moyasar.callback');
Route::get('/payment/thanks', function () {
return 'working';
})->name('moyasar.callback');

Route::post('/checkout/save-payment', function () {
return response('', 201);
})->name('moyasar.complete');
2 changes: 1 addition & 1 deletion src/LaravelMoyasarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function configurePackage(Package $package): void
->name('laravel-moyasar')
->hasViews()
->hasViewComponents('moyasar', Init::class)
// ->hasRoute('web')
->hasRoute('web')
->hasConfigFile('moyasar');
// ->hasMigration('create_laravel-moyasar_table')
// ->hasCommand(LaravelMoyasarCommand::class);
Expand Down
4 changes: 3 additions & 1 deletion tests/BladeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
// Required
// This URL is used to redirect the user when payment process has completed
// Payment can be either a success or a failure, which you need to verify on you system (We will show this in a couple of lines)
callback_url: 'http://localhost/moyasar/thanks',
callback_url: 'http://localhost/payment/thanks',
// Optional
// Required payments methods
// Default: ['creditcard', 'applepay', 'stcpay']
methods: [\"creditcard\",\"applepay\",\"stcpay\"],
on_complete: 'http://localhost/checkout/save-payment'
})
</script>
";
Expand Down
16 changes: 11 additions & 5 deletions tests/CallbackTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<?php

// it('can record payment info', function () {
// $response = $this->get(route('moyasar.callback', ['id' => 'ae5e8c6a-1622-45a5-b7ca-9ead69be722e', 'status' => 'paid', 'message' => 'success', 'amount' => 100]));
//
// $response->assertStatus(200);
// });
it('can show payment thanks page', function () {
$response = $this->get(route('moyasar.callback', ['id' => 'ae5e8c6a-1622-45a5-b7ca-9ead69be722e', 'status' => 'paid', 'message' => 'success', 'amount' => 100]));

$response->assertStatus(200);
});

it('can save payment info', function () {
$response = $this->post(route('moyasar.complete'), ['id' => 'ae5e8c6a-1622-45a5-b7ca-9ead69be722e', 'status' => 'paid']);

$response->assertStatus(201);
});

0 comments on commit 8b2980f

Please sign in to comment.