General | Application | Subscription | PaymentRequest | Payment | Refund | Example
- Create a new laravel application.
laravel new laravel-tikkie-example
If you don't have laravel cli installed, then checkout the laravel installation documentation.
- Enter the directory.
cd laravel-tikkie-example
- Install the laravel-tikkie package.
composer require jwiegant/laravel-tikkie
- Publish the tikkie configuration.
php artisan vendor:publish --tag=tikkie-config
- Edit your
.env
file and add the Tikkie information.
For this example we'll use the sandbox, insert your own api key. Which can be found under My Apps in your account.
TIKKIE_SANDBOX=true
TIKKIE_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
TIKKIE_APP_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
Important: In a production environment, App token is created in the Tikkie Business Portal.
- Open
routes/web.php
and at the top the use statement.
use Cloudmazing\Tikkie\Tikkie;
- Add in
routes/web.php
the following application creation route at the bottom.
Route::get('/tikkie-application', function(Tikkie $tikkie) {
$application = $tikkie->application()->create();
dd($application);
});
- Start the your laravel app with
php artisen serve
, open your browser and point it tohttp://127.0.0.1:8000/tikkie-application
.
If you've done all the step, you'll get a appToken in the response. If you get an error, please read it carefully and review the steps above.
Cloudmazing\Tikkie\Response\ApplicationResponse {#259 ▼
#appToken: "c5d814ab-bbf7-4cac-8387-7cd24c3dd4fc"
#casts: []
}
- Enter the
appToken
in your.env
file.
Important: Restart your laravel application, otherwise your added app token won't be used.
- Add in
routes/web.php
the following payment request route at the bottom.
Route::get('/tikkie-create', function(Tikkie $tikkie) {
// Set your description.
$description = 'Example description';
// Set your reference, this can be anything. Commonly you would use
// something like an OrderId.
$reference = 'MyReference';
// The amount that has to be paid.
$amount = 12.50;
// Date after which the payment request will expire and cannot be paid.
$expiryDate = Carbon::now()->addDays(7);
// Create the request
$request = $tikkie->paymentRequest()->create($description, $reference,
$expiryDate, $amount);
// Redirect the user to the payment Url.
return redirect($request->getUrl());
});
- Point your browser to
http://127.0.0.1:8000/tikkie-create
. A Tikkie payment will be created, and you'll be redirected to the Tikkie payment page.
This concludes our little example.