承接 coinwaka/coinwaka-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

coinwaka/coinwaka-php

Composer 安装命令:

composer require coinwaka/coinwaka-php

包简介

Official PHP SDK for the Coinwaka Pay API.

README 文档

README

Official PHP SDK for the Coinwaka Pay API. No third-party dependencies (ext-curl + ext-json), PHP 8.1+.

composer require coinwaka/coinwaka-php

Quickstart

Create an intent, redirect the customer to its hosted checkout, and fulfil the order on the signed payment_intent.paid webhook.

use Coinwaka\Coinwaka;

$coinwaka = new Coinwaka(['apiKey' => getenv('COINWAKA_SECRET_KEY')]);

$intent = $coinwaka->paymentIntents->create([
    'amount' => '2500',
    'currency' => 'KES',
    'settlement_currency' => 'USDT',
    'payment_methods' => ['mpesa', 'card', 'coinwaka_balance'],
    'merchant_reference' => 'ORDER-1001',
]);

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

A cwk_test_… key runs in sandbox (no real money); a cwk_live_… key is live. Every create call sends an Idempotency-Key automatically, so an automatic retry (on 429/5xx) never double-charges.

Resources

$coinwaka->auth->verify();
$coinwaka->rates->retrieve();
$coinwaka->quotes->create(['source_currency' => 'KES', 'target_asset' => 'USDT', 'amount' => '2500']);

$coinwaka->paymentIntents->create($params, ['idempotencyKey' => 'order-1001']);
$coinwaka->paymentIntents->retrieve('pi_...');
$coinwaka->paymentIntents->all(['limit' => 20, 'status' => 'paid']);
$coinwaka->paymentIntents->cancel('pi_...');
$coinwaka->paymentIntents->refundRequest('pi_...', ['reason' => 'Customer returned item']);

$coinwaka->paymentLinks->create(['title' => 'Deposit', 'amount' => '15000', 'currency' => 'KES']);
$coinwaka->paymentLinks->retrieve('pl_...');

Verify webhooks

Pass the raw request body.

$payload = file_get_contents('php://input');

try {
    $event = $coinwaka->webhooks->verify(
        $payload,
        $_SERVER['HTTP_COINWAKA_SIGNATURE'],
        $_SERVER['HTTP_COINWAKA_TIMESTAMP'],
        getenv('COINWAKA_WEBHOOK_SECRET')
    );
    if ($event['type'] === 'payment_intent.paid') {
        // fulfil the order (dedupe on $event['id'])
    }
    http_response_code(200);
} catch (\Coinwaka\CoinwakaError $e) {
    http_response_code(400);
}

Errors

try {
    $coinwaka->paymentIntents->create(['amount' => '0', 'currency' => 'KES']);
} catch (\Coinwaka\CoinwakaError $e) {
    error_log($e->type . ' ' . $e->apiCode . ' ' . $e->getMessage() . ' ' . $e->getRequestId());
}

The full contract is published as OpenAPI at https://www.coinwaka.com/openapi.yaml.

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固