PHP code example of dubems / laravel-amplify

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/ */

    

dubems / laravel-amplify example snippets


'aliases' => [
    ...
    'Amplify' => Dubems\Amplify\Facades\Amplify::class,
    ...
]



return [
   /**
    * Merchant ID gotten from your Amplify dashboard
    */

  'merchantId'=> getenv('AMPLIFY_MERCHANT_ID'),

    /**
     *  API Key from amplify dashboard
     */
    'apiKey' => getenv('AMPLIFY_API_KEY'),

    /**
     * Amplify payment Url
     */
    'paymentUrl' => getenv('AMPLIFY_PAYMENT_URL'),

    /**
     * Redirect Url after successful transaction
     */
    'redirectUrl' => getenv('AMPLIFY_REDIRECT_URL')

];

AMPLIFY_MERCHANT_ID=XXXXXXX
AMPLIFY_API_KEY=XXXXXX
AMPLIFY_PAYMENT_URL=https://api.amplifypay.com
AMPLIFY_REDIRECT_URL=https://xxxxx

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);
    }




bash
php artisan vendor:publish --provider="Dubems\Amplify\AmplifyServiceProvider"