alphaolomi/swahilies-php

PHP版的Swahilies

v0.1.0 2023-01-17 12:45 UTC

README

Latest Version on Packagist Tests Total Downloads

安装

您可以通过composer安装此包

composer require alphaolomi/swahilies-php

用法

use Alphaolomi\Swahilies\Swahilies;

$swahilies = new Swahilies([]);
// Or
$swahilies = Swahilies::create([
    'apiKey' => 'csdheruvhhjdhvjadmvjehrve',
    'username' => 'Company name',
    'isLive' => false, // ie. sandbox mode
]);

$response = $swahilies->payments()->request([
    // TZS by default
    'amount' => 50000,
    // 255 is country code for Tanzania, Only Tanzania is supported for now
    'orderId' => $order->id,
    'phoneNumber' => "255783262616",
    'cancelUrl' => "https://yoursite.com/cancel",
    'webhookUrl' => "https://yoursite.com/response",
    'successUrl' => "https://yoursite.com/success",
    'metadata' => [],
]);

print_r($response);

// Output:
// [
//     "payment_url" => "https://swahiliespay.invict.site/make-payment-1.html?order=jdhvjadmvjehrve"
// ]
// Webhooks
// You can use the following code to verify the webhook signature

$requestBody = /** get the request body from the webhook request **/;

$isValid = $swahilies->webhooks()
    ->verify($request->getContent()); // true/false

可用的API

支付

  • all() - 获取所有支付交易
  • directRequest($data) - 从您的应用程序发送直接USSD
  • request($data) - 发起支付请求
  • find($id) - 获取支付交易信息

Webhooks

🚧 进行中

  • getDisget($data) - 生成重新查询体摘要
  • verify($data) - 验证请求体

测试

使用 PestPHP 进行测试。

composer test

变更日志

请参阅 CHANGELOG 了解最近更改的更多信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全漏洞

请审查 我们的安全策略 了解如何报告安全漏洞。

致谢

许可证

MIT许可证(MIT)。请参阅 许可证文件 了解更多信息。