bobospay/bobospay-php
最新稳定版本:v1.1.0
Composer 安装命令:
composer require bobospay/bobospay-php
包简介
Php sdk of Bobospay - Online payment solution by credit card and mobile money
README 文档
README
The Bobospay PHP SDK enables seamless integration with Bobospay's payment processing API for PHP applications. It provides tools for managing transactions, customers, and currencies, making it easy to process online payments via credit cards and mobile money in your PHP applications. Compatible with popular frameworks such as Laravel, Symfony, and CodeIgniter.
You can sign up for a Bobospay account at https://bobospay.com.
Requirements
- PHP 5.6 and later
- cURL extension
- JSON extension
- OpenSSL extension
Installation
Composer (Recommended)
You can install the SDK via Composer. Run the following command:
composer require bobospay/bobospay-php
Manual Installation
If you do not wish to use Composer, you can download the latest release. Then, to use the SDK, include the init.php file:
require_once('/path/to/bobospay-php/init.php');
Getting Started
Basic Configuration
First, configure your Bobospay credentials and environment:
use Bobospay\Bobospay; // Set your client credentials Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); // Set environment (sandbox for testing, live for production) Bobospay::setEnvironment('sandbox'); // or 'live'
Use Cases
Creating a Customer
use Bobospay\Bobospay; use Bobospay\Customer; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Create a customer $customer = Customer::create([ 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john.doe@example.com', 'phone' => '+22966666600' ]); echo "Customer created with ID: " . $customer->id;
Creating a Transaction
use Bobospay\Bobospay; use Bobospay\Transaction; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Create a transaction $transaction = Transaction::create([ 'note' => 'Payment for order #1234', 'amount' => 1000, // Amount in smallest currency unit (e.g., cents) 'currency' => 'XOF', 'callback_url' => 'https://example.com/callback', 'customer' => ['id' => 1] // Customer ID from previous example, you use email, or provide all customer details 'custom_data' => ['order_id' => '1234'] ]); //$transaction = Transaction::create([ // 'description' => 'Payment for order #1234', // 'amount' => 1000, // Amount in smallest currency unit (e.g., cents) // 'currency' => 'XOF', // 'callback_url' => 'https://example.com/callback', // 'customer' => [ // 'firstname' => 'John', // 'lastname' => 'Doe', // 'email' => 'john.doe@example.com', // 'phone' => '+22966666600' // ], //]); echo "Transaction created with ID: " . $transaction->id;
Retrieving a Transaction
use Bobospay\Bobospay; use Bobospay\Transaction; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Retrieve a specific transaction $transaction = Transaction::retrieve('transaction_id_here'); echo "Transaction status: " . $transaction->status;
Listing All Customers
use Bobospay\Bobospay; use Bobospay\Customer; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Get all customers $customers = Customer::all(); foreach ($customers->customers as $customer) { echo "Customer: " . $customer->firstname . " " . $customer->lastname . "\n"; }
Managing Currencies
use Bobospay\Bobospay; use Bobospay\Currency; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Get all available currencies $currencies = Currency::all(); foreach ($currencies->currencies as $currency) { echo "Currency: " . $currency->name . " (" . $currency->iso . ")\n"; } // Get a specific currency $currency = Currency::retrieve('currency_id_here'); echo "Currency details: " . $currency->name;
Generating Payment Token
use Bobospay\Bobospay; use Bobospay\Transaction; // Configure Bobospay Bobospay::setClientId('YOUR_CLIENT_ID'); Bobospay::setClientSecret('YOUR_CLIENT_SECRET'); Bobospay::setEnvironment('sandbox'); // Create transaction first $transaction = Transaction::create([ 'description' => 'Payment for order #1234', 'amount' => 1000, 'currency' => 'XOF', 'callback_url' => 'https://example.com/callback' ]); // Generate payment token $token = $transaction->generateToken(); echo "Payment token: " . $token->token;
Documentation
Please see https://docs.bobospay.com for up-to-date API documentation.
Development
Install dependencies:
composer install
Run tests:
composer test
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-26