kevinpurwito/laravel-rajabiller

Rajabiller integration for Laravel

v2.0.7 2022-09-27 04:30 UTC

This package is auto-updated.

Last update: 2024-05-27 20:00:35 UTC


README

Tests Code Style Psalm Latest Version on Packagist Total Downloads

Laravel Rajabiller is a package that integrates Rajabiller for Laravel.

Refer to this docs & this postman

Installation

You can install the package via composer:

composer require kevinpurwito/laravel-rajabiller

Configuration

The vendor:publish command will publish a file named kp_rajabiller.php within your laravel project config folder config/kp_rajabiller.php.

Published Config File Contents

[
    'env' => strtolower(env('KP_RB_ENV', 'dev')), // dev or prod

    'url' => strtolower(env('KP_RB_URL', 'https://rajabiller.fastpay.co.id/transaksi/json_devel.php')),

    'uid' => env('KP_RB_UID'),

    'pin' => env('KP_RB_PIN'),
];

Alternatively you can ignore the above publish command and add this following variables to your .env file.

KP_RB_ENV=dev
KP_RB_UID=user
KP_RB_PIN=secret

Auto Discovery

If you're using Laravel 5.5+ you don't need to manually add the service provider or facade. This will be Auto-Discovered. For all versions of Laravel below 5.5, you must manually add the ServiceProvider & Facade to the appropriate arrays within your Laravel project config/app.php

Provider

[
    Kevinpurwito\LaravelRajabiller\RajabillerServiceProvider::class,
];

Alias / Facade

[
    'Rajabiller' => Kevinpurwito\LaravelRajabiller\Facades\Rajabiller::class,
];

Publishing the migration

Aside from migrations, you shouldn't need to publish the others, such as seeders and config; unless you want to customize them

php artisan vendor:publish --provider=Kevinpurwito\LaravelRajabiller\RajabillerServiceProvider --tag=rb-migrations

Running the seeders

php artisan db:seed --class=Kevinpurwito\LaravelRajabiller\Database\Seeders\RbSeeder

Dev Credentials

UID=FA9919
PIN=123321

Using the command

This package comes with a built-in command for you to call to sync items in the database to Rajabiller's servers. This command maintains the pricing and availability of the items. You can call this command in Laravel CronJob.

php artisan rb-sync-items

Usage

use Kevinpurwito\LaravelRajabiller\Facades\Rajabiller;

// returns the balance that you have
Rajabiller::getBalance();

// returns the list of orders you created in certain date (accepts date in Y-m-d format)
Rajabiller::orders('2021-01-20');

// returns the list of items under certain group (accepts string groupCode)
Rajabiller::groupItems('TELKOMSEL');

// returns the details of item (accepts string itemCode)
Rajabiller::item('S5H'); // telkomsel pulsa 5rb

// purchase an item, either pulsa or game voucher
Rajabiller::purchase('TXxxx', 'S5H', '628xxxx', 'pulsa'); // telkomsel pulsa 5rb

// inquiry for ppob (PLN, TELKOM, etc) price before paying
Rajabiller::inquiry('TXxxx', 'PLN', '123xxxx');

// pay for ppob (PLN, TELKOM, etc)
Rajabiller::pay('TXxxx', 'PLN', '123xxxx');

Be careful! You can only do 3 inquiries per day for 1 customerId for each item. For example. you can only inquire about a PLN charge for 1 customerId 3 times, after that you have to pay it or inquire again tomorrow.

Handling the response

use Kevinpurwito\LaravelRajabiller\Facades\Rajabiller;

$response = Rajabiller::item('S5H'); // telkomsel pulsa 5rb

if ($response->getStatusCode() == 200) {
    // if you want to check the response body, such as `HARGA` you can do this:
    $content = json_decode($response->getBody()->getContents());
    dump($content);
//    {
//      "KODE_PRODUK": "S5H",
//      "UID": "UID",
//      "PIN": "PIN",
//      "STATUS": "00",
//      "KET": "SUKSES",
//      "HARGA": "5435",
//      "ADMIN": "",
//      "KOMISI": "0",
//      "PRODUK": "TELKOMSEL SIMPATI / AS 5RB",
//      "STATUS_PRODUK": "AKTIF",
//    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email kevin.purwito@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the PHP Package Boilerplate by Beyond Code with some modifications inspired from PHP Package Skeleton by spatie.