rafaelrogerio/mpesa-dependency

使用mpesa网关的在线支付管理器

v2.0 2024-05-13 02:07 UTC

This package is not auto-updated.

Last update: 2024-09-30 03:51:49 UTC


README

用于消费mpesa API的依赖项

安装

要安装此依赖项,只需运行以下命令

composer require rafaelrogerio/mpesa-dependency

使用

要使用此管理器,只需按照以下示例操作

C2B

<?php

require __DIR__.'/../../vendor/autoload.php';

use \Bluteki\MpesaGateway\Mpesa;

// configuring api access credentials
Mpesa::config(
    'enter you api key',
    'enter your public key',
    'host',
    'origin',
    'port',
    'service_provider_code'
);

$transactionReference = bin2hex(random_bytes(6)); 
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::c2b(1, '258849549369', $transactionReference, $thirdPartyReference);

echo '<pre>';
print_r($response->toArray());

B2C

<?php

require __DIR__.'/../../vendor/autoload.php';

use \Bluteki\MpesaGateway\Mpesa;

// configuring api access credentials
Mpesa::config(
    'enter you api key',
    'enter your public key',
    'host',
    'origin',
    'port',
    'service_provider_code'
);

$transactionReference = bin2hex(random_bytes(6)); 
$thirdPartyReference = bin2hex(random_bytes(6));
$response = Mpesa::b2c(1, '258849549369', $transactionReference, $thirdPartyReference);

echo '<pre>';
print_r($response->toArray());

要求

  • 需要PHP 8.0或更高版本