定制 fastaar/fastaar-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fastaar/fastaar-php

Composer 安装命令:

composer require fastaar/fastaar-php

包简介

PHP SDK for the Fastaar payment gateway — accept bKash & Nagad payments in Bangladesh.

README 文档

README

Accept bKash & Nagad payments on any PHP website via Fastaar.

Install

composer require fastaar/fastaar-php

Create a payment & redirect to checkout

use Fastaar\FastaarClient;

$fastaar = new FastaarClient(apiKey: getenv('FASTAAR_API_KEY')); // fk_live_... or fk_test_...

$payment = $fastaar->createPayment([
    'amount' => 1250,
    'invoice_id' => 'ORDER-42',                         // your order reference
    'success_url' => 'https://shop.example.com/thanks', // optional, customer returns here
    'cancel_url' => 'https://shop.example.com/cart',    // optional
]);

header('Location: '.$payment['checkout_url']);
exit;

Passing the same invoice_id again returns the existing payment instead of creating a duplicate, so a retried request never double-charges.

Confirm the order from a webhook

use Fastaar\WebhookSignature;

$rawBody = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FASTAAR_SIGNATURE'] ?? '';

if (! WebhookSignature::verify(getenv('FASTAAR_WEBHOOK_SECRET'), $rawBody, $signature)) {
    http_response_code(400);
    exit;
}

$event = json_decode($rawBody, true);

if ($event['event'] === 'payment.completed') {
    $orderId = $event['data']['invoice_id'];
    // mark the order as paid, idempotently (use $event['data']['id'] as the key)
}

http_response_code(200);

Other calls

$payment = $fastaar->getPayment('01jxyz...');                 // retrieve one
$payment = $fastaar->findByInvoiceId('ORDER-42');             // look up by your reference
$payments = $fastaar->listPayments(['status' => 'completed']);

Errors throw Fastaar\FastaarException with ->errorType (e.g. authentication_error, subscription_required, transaction_limit_reached) and ->statusCode.

Test mode

Use an fk_test_ key: payments auto-complete on the checkout page without real money, and webhooks fire exactly like production with "livemode": false.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固