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

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

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

mavunta/mavunta-php

Composer 安装命令:

composer require mavunta/mavunta-php

包简介

Official PHP SDK for the Mavunta Pay API.

README 文档

README

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

composer require mavunta/mavunta-php

Quickstart

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

use Mavunta\Mavunta;

$mavunta = new Mavunta(['apiKey' => getenv('MAVUNTA_SECRET_KEY')]);

$intent = $mavunta->paymentIntents->create([
    'amount' => '2500',
    'currency' => 'KES',
    'settlement_currency' => 'USDT',
    'payment_methods' => ['mpesa', 'card', 'mavunta_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

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

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

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

Verify webhooks

Pass the raw request body.

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

try {
    $event = $mavunta->webhooks->verify(
        $payload,
        $_SERVER['HTTP_MAVUNTA_SIGNATURE'],
        $_SERVER['HTTP_MAVUNTA_TIMESTAMP'],
        getenv('MAVUNTA_WEBHOOK_SECRET')
    );
    if ($event['type'] === 'payment_intent.paid') {
        // fulfil the order (dedupe on $event['id'])
    }
    http_response_code(200);
} catch (\Mavunta\MavuntaError $e) {
    http_response_code(400);
}

Errors

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

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

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固