1. Go to this page and download the library: Download dubems/laravel-amplify library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Route::post('/pay', 'PaymentController@redirectToGateway')->name('pay'); // Laravel 5.1.17 and above
Route::get('/payment/callback', 'PaymentController@handleGatewayCallback');
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Amplify;
class PaymentController extends Controller
{
/**
* Redirect the User to Amplify Payment Page
* @return Url
*/
public function redirectToGateway()
{
return Amplify::getAuthorizationUrl()->redirect();
}
/**
* Get Amplify payment information
* @return void
*/
public function handleGatewayCallback()
{
$response = Amplify::handlePaymentCallback();
dd($response);
// Now you have the payment details,
// you can store the authorization_code in your db to allow for recurrent subscriptions
// you can then redirect or do whatever you want
}
}
/** Create Subscription */
public function createSubscription()
{
$data = ['planName' => 'Sliver members', 'frequency' => 'Weekly'];
$response = Amplify::createSubscription($data);
dd($response);
}
/** Delete a particular subscription */ */
public function deleteSubscription()
{
$id = 'xyz';
$response = Amplify::deleteSubscription($id);
dd($response);
}
/** Update a particular subscription */
public function updateSubscription()
{
$data = ['planName' => 'Gold members', 'frequency' => 'Weekly'];
$planId = 'xyz';
$response = Amplify::updateSubscription($planId, $data);
dd($response);
}
/** Get a particular subscription */
public function fetchSubscription()
{
$id = 'id';
$response = Amplify::fetchSubscription($id);
dd($response);
}
/** Fetch all subscription */
public function fetchAllSubscription()
{
$allSub = Amplify::fetchAllSubscription();
dd($allSub);
}