bitsika/merchant-sdk-php
Composer 安装命令:
composer require bitsika/merchant-sdk-php
包简介
This package fluent way to use the bitsika merchant api.
README 文档
README
The Bitsika PHP library gives convenient access to the Console Merchant API for applications written in the PHP language. Devs and merchants alike can use our API and corresponding dashboard to create invoices that any Bitsika user can instantly pay. Learn more here: https://console.bitsika.africa. Our raw API documentation: https://documenter.getpostman.com/view/12690520/UUy39RrV. Small video demo.
General Requirements
- PHP version 7.0 or greater.
- Composer for installing packages.
- The binding relies on Guzzle to work fine. This package comes pre-installed with Guzzle.
Installation
Install the Bitsika PHP Library. Version to install is dev-main.
composer require bitsika/merchant-sdk-php
You can also install these packages using the composer install command from your composer.json file.
{
"require": {
"bitsika/merchant-sdk-php": "1.0.9"
}
}
To use the bindings, use Composer's autoload.
require_once __DIR__ . '/vendor/autoload.php';
Getting Started
To get started, create an instance of the Merchant class. You will need a copy of your Bitsika API Secret Key. This can be found on the Keys and Security page of our Console.
require_once __DIR__ . '/vendor/autoload.php'; use Bitsika\Merchant; $merchant = new Merchant('PUT_YOUR_SECRET_KEY_HERE');
The variable $merchant is now an instance of the Merchant class and can be used to perform any of the multiple tasks available to merchants.
Merchant Methods
Get merchant detail.
This method returns basic data related to the merchant company whose Secret Key you’re currently using. Data returned includes company name, Bitsika username, profile picture URL, KYC status, balances across multiple currencies and much more.
$response = $merchant->detail(); var_dump($response);
Get merchant statistics.
This method returns transaction statistics pertaining to the respective merchant company. It returns data like number of unique users, sum of successful transactions, sum of all transactions, etc.
$response = $merchant->statistics(); var_dump($response);
Invoice Methods
Create invoice.
This method returns basic data for a newly created invoice including (most importantly) the invoice / payment web link URL. This invoice can we paid by any Bitsika user who opens the payment link. They can pay the invoice with any currency balance in their Bitsika app. You, the merchant, will get settled instantly in the currency you specify when creating the invoice below.
$response = $merchant->invoices()->create([ "title" => "Vanilla Ice-Cream", "description" => "2 scoops of vanilla ice-cream, chocolate biscuits and coconut shavings.", "amount" => 2000000, "currency" => "NGN", "recipient_email" => "test@example.com", "photo_url" => "https://image.com/test.jpg" ]); var_dump($response);
| Param | Required | About | Validation |
|---|---|---|---|
| title | Yes | Title of the invoice. Here, provide a heading of the service you rendered to your customer. For example "Vanilla ice-cream with coconut shavings". | String. Minimum number of characters = 4. Maximum number of characters = 50. |
| description | Yes | Provide more info on the service your customer is about to pay for. Example: "2 scoops of vanilla ice-cream, chocolate biscuits and coconut shavings. Large cup size". | String. Minimum number of characters = 4. Maximum number of characters = 280. |
| amount | Yes | Amount number that the service costs. | Integer. Minimum amount: 1. Maximum amount: 10000000. 2 decimal places, if used. It is important to note that because of KYC, fraud control and best practices, we suggest that the amount of your invoice doesn't exceed the equivalent of $1,000 in its respective currency. |
| currency | Yes | Denote the currency you / your company would like the payment of this invoice to be settled in. | String. Provide one of the following currencies: NGN, USD, XOF, XAF, GHS |
| recipient_email | No | Who should a copy of this invoice be sent to upon creation? | String / Email format. Minimum number of characters = 4. Maximum number of characters = 50. |
| photo_url | No | Provide the URL of your product's / service's item photo. | String / URL format. Minimum number of characters = 4. Maximum number of characters = 280. |
Get invoice by id.
This method is used to query an invoice’s data any time in the future. You can use this method to manually check on the state (if it’s been paid or not) or expiry status of an invoice.
$invoiceId = 'INVOICE_ID_HERE'; $response = $merchant->invoices()->get($invoiceId); var_dump($response);
Send cash.
Your merchant company needs to be verified (KYC verification) before you can successfully call this method.
Use this method to send money from your company’s merchant balances to any Bitsika user or merchant with a $username or $cashtag. All such transfers are instant and free.
$response = $merchant->transaction()->sendCash([ "platform" => "bitsika", "amount" => 100, "currency" => "USD", "username" => "davido", "debit_from" => "USD", "purpose" => "" ]); var_dump($response);
| Param | Required | About | Validation |
|---|---|---|---|
| platform | Yes | What network are you transferring the money on? | String. bitsika |
| amount | Yes | Numerical value of amount to be transferred. | Integer. Minimum amount: 1. Maximum amount: 10000000. 2 decimal places, if used. It is important to note that because of KYC, fraud control and best practices, we suggest that the amount of your invoice doesn't exceed the equivalent of $1,000 in its respective currency. |
| currency | Yes | Denote the currency you / your company would like the end user to receive the transfer in. | String. Provide one of the following currencies: NGN, USD, XOF, XAF, GHS |
| username | Yes | Provide the username or cashtag of the Bitsika user or merchant you're making the transfer to. |
String. Example: davido, taylorswift13. Do not include the $ infront of the username when writing it. |
| debit_from | Yes | Denote the currency balance you / your company would like the transfer to be deducted from. You can make a transfer in one currency, debited from another. For example: you can send a user 100 USD, but choose to deduct the debit from your NGN balance. | String. Provide one of the following currencies: NGN, USD, XOF, XAF, GHS |
| purpose | No | A comment or note to accompany the transfer. | String. Minimum number of characters = 4. Maximum number of characters = 255. |
Verify transaction.
Use this method to verify the status of transfers you make with the Send Cash method above.
$transactionId = "YOUR_TRANSACTION_ID_HERE"; $response = $merchant->transaction()->get($transactionId); var_dump($response);
Search for a user.
Use this method to search for a bitsika user, and verify is they exist.
$username = "USERNAME_HERE"; $response = $merchant->customer()->search($username); var_dump($response);
Virtual card
Merchants can generate virtual cards for their account. Here's a list of operations that can be performed pertaining to a virtual card.
Create Card
This method is used to create a virtual card
| Param | Required | About | Validation |
|---|---|---|---|
| name | Yes | The virtual card name | String |
| currency | Yes | The currency the generated card will have | String. NGN, USD, GHS |
| amount | Yes | The amount to fund the card with upon creation | Integer. numeric |
| debit_from | Yes | The wallet currency to be debited from upon creation | String.NGN, USD, GHS |
$response = $merchant->virtualCard()->create([ "name" => "Tommie Nii Darku", "currency" => "USD", "amount" => 11, "debit_from" => "GHS" ]); var_dump($response);
Get all virtual cards
You can fetch all the available virtual cards with the method below
$response = $merchant->virtualCard()->all(); var_dump($response);
Get virtual card by id
You can get a virtual card by it's id with the method below
$cardId = 113; $response = $merchant->virtualCard()->get($cardId); var_dump($response);
Top-up virtual card by id
You can top up a virtual card by it's id with the method below
| Param | Required | About | Validation |
|---|---|---|---|
| amount | Yes | The amount to fund the card with | Integer. numeric |
| currency | Yes | The currency to fund the card with | String. NGN, USD, GHS |
| debit_from | Yes | The wallet currency to be debited from | String.NGN, USD, GHS |
$cardId = 113; $response = $merchant->virtualCard()->topUp($cardId, [ "amount" => "10", "currency" => "USD", "debit_from" => "GHS" ]); var_dump($response);
Withdraw from card by id
You can withdraw from a virtual card by it's id with the method below
$cardId = 113; $response = $merchant->virtualCard()->withdraw($cardId, [ "amount" => "5" ]); var_dump($response);
Get card Transactions
You can fetch a virtual card's transaction by it's id with the method below
$cardId = 113; $response = $merchant->virtualCard()->transactions($cardId); var_dump($response);
Freeze Card
You can freeze a virtual card by it's id with the method below
$cardId = 113; $response = $merchant->virtualCard()->freeze($cardId); var_dump($response);
Unfreeze Card
You can unfreeze a virtual card by it's id with the method below
$cardId = 113; $response = $merchant->virtualCard()->unfreeze($cardId); var_dump($response);
Invoice Webhooks
Whenever invoices are paid, notifications are sent to the webhook URL you provided on the Keys and Security page of your Bitsika Console account. Your webhook URL is expected to be an unauthenticated POST request URL.
Once payments are recieved, weather Initiated, Failed or Successful, we make a Post request containing the event object to your webhook URL.
The request object contains the event, invoice_id and transaction details.
The event key will be invoice.payment_failed for failed payments, or invoice.payment_success for successful payments.
The invoice_id is the id of the invoice being paid for, while the transaction key contains a JSON object of the payment.
Verifying webhooks
(Optional) Everytime a request is made to your webhook url, for security reasons, we also send a x-bitsika-signature in the header. This contains a HMAC SHA512 hash of the payload signed using your secret key.
if($_SERVER['HTTP_X_BITSIKA_SIGNATURE'] !== hash_hmac('sha512', $input, YOUR_SECRET_KEY_HERE)) exit();
Sample Response - An example of the JSON response to expect:
{
"id": 935,
"reference": "87-1601554148-1530",
"currency": "USD",
"status": "Successful",
"amount": 50,
"type": "Out",
"created_at": "2020-10-01 12:09:08",
"updated_at": "2020-10-01 12:09:08",
"from_account": {
"id": 87,
"name": "Tom Tom Darku",
"username": "tdlover"
}
}
License
The MIT License (MIT). Please see License File for more information.
bitsika/merchant-sdk-php 适用场景与选型建议
bitsika/merchant-sdk-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 134 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bitsika」 「bitsika merchant」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bitsika/merchant-sdk-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bitsika/merchant-sdk-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bitsika/merchant-sdk-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Payyo Gateway for the Omnipay payment processing library
PaySimple driver for the Omnipay payment processing library
Yandex.Kassa driver for Omnipay payment processing library
Some pre-defined rules for validation in Omnipay payment processing library.
BluePay gateway for the Omnipay payment processing library
Paymentech Orbital driver for the Omnipay payment processing library
统计信息
- 总下载量: 134
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-01-04