henryejemuta/laravel-vtung

一个Laravel包,可以无缝地将VTU.ng API集成到您的Laravel应用中。VTU.ng API是一个HTTPS GET API,允许您将我们平台上的所有虚拟充值和账单支付服务集成到您的应用中(网站、桌面应用和移动应用)。您也可以通过集成我们的VTU API并重新销售我们的服务在尼日利亚开展自己的VTU业务。

v1.2.1 2021-11-16 12:34 UTC

This package is auto-updated.

Last update: 2024-09-16 19:26:01 UTC


README

Latest Version on Packagist Latest Stable Version Total Downloads License Quality Score

什么是VTU.ng

VTU.ng API是一个HTTPS GET API,允许您将我们平台上的所有虚拟充值和账单支付服务集成到您的应用中(网站、桌面应用和移动应用)。您也可以通过集成我们的VTU API并重新销售我们的服务在尼日利亚开展自己的VTU业务。

什么是Laravel VTU.ng

Laravel VTU.ng是一个Laravel包,用于无缝地将VTU.ng API集成到您的Laravel应用中。

创建VTU.ng账户 注册

查找VTU.ng API文档 API文档

安装

您可以通过composer安装此包

composer require henryejemuta/laravel-vtung

发布VTU.ng配置文件,迁移以及设置.env文件中的默认详情

php artisan vtung:init

使用方法

通过VtuDontNG外观,Laravel VTU.ng包非常易于使用

use HenryEjemuta\LaravelVtuDotNG\Facades\VtuDotNG;
use HenryEjemuta\LaravelVtuDotNG\Classes\VtuDotNGResponse;

...
//To buy Airtime
try{
    $response = VtuDotNG::purchaseAirtime('mtn', '1500', '08134567890');
}catch(VtuDotNGErrorException $ex){
    Log::error("Error while purchasing airtime\n\r" . $exception->getCode() . ": " . $exception->getMessage());
}
...

注意:为了以不同的方式处理升级警告,它被抛出为包含VTU.ng消息和错误代码401的异常

查看所有方法的概述,包括它们的作用和预期参数

    /**
     * Get Your wallet available balance, Wallet is identified by username set in vtung config or environmental variable
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function getWalletBalance(): VtuDotNGResponse

    /**
     * Purchase Airtime with py specifying the network (i.e. mtn, glo, airtel, or 9mobile to buy airtime corresponding the provided telco service code)
     * @param string $network The network_id is used to make each network unique. They include mtn, glo, airtel and etisalat. Notice that they are all in small letters.
     * @param int $amount The amount you wish to topup
     * @param string $phoneNumber The phone number that will receive the airtime
     * @return VtuDotNGResponse
     *
     * @throws VtuDotNGErrorException
     */
    public function purchaseAirtime(string $network, int $amount, $phoneNumber): VtuDotNGResponse


    /**
     * Purchase Data Bundle
     * @param string $network The network_id is used to make each network unique. They include mtn, glo, airtel and etisalat. Notice that they are all in small letters.
     * @param string $plan The variation ID of the data plan you want to purchase.
     * @param string $phone The phone number that will receive the data
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function purchaseDataBundle(string $network, string $plan, string $phone): VtuDotNGResponse

    /**
     * Verify Customer Smart Card Number/IUC/Decoder Number verification
     * You need to verify your customer unique number before purchasing.
     *
     * @param string $cableTvType The $cableTvType is used to make each cable TV unique. They include dstv, gotv, and startimes. Notice that they are all in small letters.
     * @param string $smartCardNumber The smartcard/IUC number of the decoder that should be subscribed
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function verifyCableSmartCardNumber(string $cableTvType, string $smartCardNumber): VtuDotNGResponse

    /**
     * Purchase DSTV or GoTv Cable Tv Plan
     *
     *
     * @param string $cableTvType The $cableTvType is used to make each cable TV unique. They include dstv, gotv, and startimes. Notice that they are all in small letters.
     * @param string $smartCardNumber The smartcard/IUC number of the decoder that should be subscribed
     * @param string $plan The $plan ID of the cable TV package/bouquet you want to purchase. They are as follows:
     *
     *    dstv-padi = DStv Padi
     *    dstv-yanga = DStv Yanga
     *    dstv-confam = DStv Confam
     *    dstv6 = DStv Asian
     *    dstv79 = DStv Compact
     *    dstv7 = DStv Compact Plus
     *    dstv3 = DStv Premium
     *    dstv10 = DStv Premium Asia
     *    gotv-smallie = GOtv Smallie
     *    gotv-jinja = GOtv Jinja
     *    gotv-jolli = GOtv Jolli
     *    gotv-max = GOtv Max
     *    nova = Startimes Nova
     *    basic = Startimes Basic
     *    smart = Startimes Smart
     *    classic = Startimes Classic
     *    super = Startimes Super
     *
     * @param string $customerPhoneNumber The phone number that will be stored for reference
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function purchaseCableTvPlan(string $cableTvType, string $smartCardNumber, string $plan, string $customerPhoneNumber): VtuDotNGResponse

    /**
     * We advise that you always verify the customer’s details before submitting requests to purchase the service (cable TV or electricity). The VTU.ng customer verification endpoint allows you to get the customer’s full name.
     *
     * @param DiscoEnum $disco The service_id is unique for all cable TV and electricity services.
     * @param string $meterNumber Meter Number to verify
     * @param string $meterType Meter type i.e. <strong>prepaid</strong> or <strong>postpaid</strong>
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function verifyMeterNumber(DiscoEnum $disco, string $meterNumber, string $meterType): VtuDotNGResponse

    /**
     * Purchase Electricity
     * You can purchase electricity through our API and get instant token for prepaid meters.
     *
     * @param DiscoEnum $disco Unique code of the Electricity distribution company the meter number is for
     *
     * @param string $meterNumber The meter number you want to purchase electricity for
     * @param string $meterType The meter type of electricity company you want to purchase. It is either prepaid or postpaid
     * @param int $amount The meter type of electricity company you want to purchase. It is either prepaid or postpaid
     * @param string $customerPhoneNumber The phone number that will be stored for reference
     * @return VtuDotNGResponse
     * @throws VtuDotNGErrorException
     */
    public function purchaseElectricity(DiscoEnum $disco, string $meterNumber, string $meterType, $amount, string $customerPhoneNumber): VtuDotNGResponse

测试

composer test

变更日志

请参阅 变更日志 了解最近更改的更多信息。

贡献

请参阅 贡献指南 了解详细信息。

安全

如果您发现任何安全问题,请通过电子邮件 henry.ejemuta@gmail.com 报告,而不是使用问题跟踪器。

致谢

许可

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

Laravel包模板

此包是使用 Laravel包模板 生成的。