vahidkaargar / bamboo-card-portal
This is Bamboocardportal.com package
Requires
- php: >=7.4
- guzzlehttp/guzzle: ^7.2
- illuminate/support: ^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- josantonius/http-status-code: ^1.0|^2.0
Requires (Dev)
- orchestra/testbench: ^8.10
- phpunit/phpunit: ^10|^11
README
Bamboo Card Portal API is a Laravel package that offers seamless integration with the Bamboo API. Bamboo is a trusted provider of digital prepaid products and reward fulfillment services, making it a valuable solution for businesses operating in the Middle East.
Table of Contents
About Bamboo
BAMBOO ELECTRONIC CARDS TRADING LLC is a leading distributor of digital prepaid products and a recognized rewards fulfillment agency. This package simplifies the interaction with their platform, enabling developers to manage and distribute digital products effectively.
Requirements
- Laravel Framework: 8.x or higher
- PHP: 7.4 or higher
- Composer: Latest version
Installation
To install the Bamboo Card Portal API package, use the following Composer command:
composer require "vahidkaargar/bamboo-card-portal"
configuration
After installation, configure the package by setting the following environment variables in your Laravel project's .env
file:
BAMBOO_SANDBOX_USERNAME= BAMBOO_SANDBOX_PASSWORD= BAMBOO_SANDBOX_MODE= BAMBOO_PRODUCTION_USERNAME= BAMBOO_PRODUCTION_PASSWORD= # In seconds BAMBOO_CONNECTION_TIMEOUT=360
Publish config file
This will generate a configuration file at config/bamboo.php
, where you can further customize the settings. (Like Sandbox etc.)
php artisan vendor:publish --tag=bamboo-config
Usage
There are two primary ways to use this package:
1. Using the Helper Function
$bamboo = bamboo(); $bamboo = bamboo('username', 'password', false);
2. Using the Bamboo Class Directly
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); $bamboo = new Bamboo('username', 'password', true);
Catalogs
Catalogs have two versions
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); // Version 1 $catalogs = $bamboo->catalogs()->get(); // Version 2 $catalogs = $bamboo->catalogs() ->setVersion(2) ->setName('playstation germany') ->setProductId(114111) ->setBrandId(100) ->setCountryCode('US') ->setCurrencyCode('USD') ->setModifiedDate('2022-08-21') ->setPageIndex(default: 0) ->setPageSize(default: 150) ->get();
Account
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); $account = $bamboo->accounts()->get();
Order
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = (new Bamboo())->orders(); /* * checkout and create an order * you can add multiple products */ $requestedId = Str::uuid(); $checkout = $bamboo->setRequestId($requestedId) ->setAccountId($accountId) ->setProducts([ ["ProductId" => $productId, "Quantity" => $quantity, "Value" => $value], ["ProductId" => $productId2, "Quantity" => $quantity2, "Value" => $value2], ["ProductId" => $productId3, "Quantity" => $quantity3, "Value" => $value3], ]) ->setProduct($productId4, $quantity4, $value4) ->checkout(); /* * get orders between to date e.g. 2022-05-02 */ $orders = $bamboo->setStartDate('2022-05-02') ->setEndDate('2022-05-20') ->get(); /* * get orders base on $requestedId, its string */ $order = $bamboo->get($requestedId);
Exchange rate
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); $exchange = $bamboo->exchange() ->setBaseCurrency('USD') ->setCurrency('EUR') ->rate();
Transaction
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); /* * get orders between to date e.g. 2022-05-02 */ $transactions = $bamboo->transactions() ->setStartDate('2022-05-02') ->setEndDate('2022-05-20') ->get();
Notification
For create a notification listener:
- You must set a callback URL address from your website
- You must set a secret key for passing the right notifications
use vahidkaargar\BambooCardPortal\Bamboo; $bamboo = new Bamboo(); /* * get notification that you created */ $notification = $bamboo->notifications()->get(); /* * create notification listener */ $notification = $bamboo->notifications() ->setNotificationUrl('https://your-website.com/notification-listener') ->setSecretKey('your-secret-key') ->create();
Test
./vendor/bin/phpunit