PHP code example of devability / laravel-cafebazaar

1. Go to this page and download the library: Download devability/laravel-cafebazaar 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/ */

    

devability / laravel-cafebazaar example snippets

bash
php artisan vendor:publish
# select [10] Provider: Devability\LaravelCafebazaar\LaravelCafebazaarServiceProvider
 php

// add a redirect route for example routes/api.php
Route::get('/iap/redirect', function(Illuminate\Http\Request $request) {
    return \Devability\LaravelCafebazaar\LaravelCafebazaar::handleRedirect($request);
});

bash
php artisan Cafebazaar code
 php


namespace App\Http\Controllers;

use Devability\LaravelCafebazaar\LaravelCafebazaar;

...

class MyController extends Controller {
    function check() {
        $cafebazaar = new LaravelCafebazaar();
        $purchase = $cafebazaar->verifyPurchase('ir.devability.package_id', 'product_id', 'purchase_token');
        if($purchase->isValid()) {
            echo 'yay!';
        }
    }
}