algoetech/openapi_mpesa

为 Laravel 应用程序提供简单的 OpenAPI 集成

0.01 2024-06-23 17:13 UTC

This package is not auto-updated.

Last update: 2024-10-01 20:39:34 UTC


README

Latest Version on Packagist Total Downloads

与移动货币运营商(如Vodacom的M-Pesa)无缝集成,轻松添加到您的Laravel应用程序中。💰

文档

🚧 进行中

有关包使用的详细说明,请参阅以下示例readme:这里

🚀 安装

您可以通过Composer安装此包

composer require algoetech/openapi_mpesa

💼 使用方法

使用外观

*Web|api 路由

    Route::post('/pay', [PaymentController::class, 'payment'])->name('payments_api');

*控制器 [ PaymentController ]

use Openpesa\Pesa\Facades\Pesa;

// This function will be mapped to web|api route: `your-URL/api/pay`
// assuming you have data captured from a form 
public function payment(PaymentApiRequest $req) {
    $response = Pesa::c2b([
        'input_Amount' => $req->price, // Amount to be charged
        'input_Country' => 'TZN',
        'input_Currency' => 'TZS',
        'input_CustomerMSISDN' => '255'.$req->msisdn, // assuming you capture phone number without country code and zero
        'input_ServiceProviderCode' => '000001', // Replace with your service provider code given by M-Pesa
        'input_ThirdPartyConversationID' => 'mpesatz', // Unique [use a rand function to isolate ConversationId]
        'input_TransactionReference' => 'imethibitishwa', // Unique []
        'input_PurchasedItemsDesc' => $req->item
    ]);
    
    // make your logics to handle responses here
    return $response;
};

💼 使用方法

composer test

👥 致谢

📄 许可证

MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件