emmadedayo/laravel-vtpass

1.0.1 2022-03-13 22:42 UTC

This package is not auto-updated.

Last update: 2024-09-23 10:30:07 UTC


README

这里应该是你的描述。查看contributing.md以获取待办事项列表。

## 安装

通过 Composer

$ composer require emmadedayo/laravel-vtpass

设置

该包将自动注册服务提供者。

你需要发布配置文件

php artisan vendor:publish --provider="Emmadedayo\VtPass\VTPassServiceProvider"

这是配置文件 vtpass.php 的默认内容

<?php

return [
  "username"          => env("VTPASS_USERNAME"),
  "password"          => env("VTPASS_PASSWORD"),
  // specify to use sandbox mode or live mode
   "mode"              => env("VTPASS_MODE", "sandbox"), // app mode sandbox ?? live
];

更新项目的 .env 配置文件

VTPASS_USERNAME=xxx@xxxx.com
VTPASS_PASSWORD=xxxxxx
VTPASS_MODE=sandbox //leave at sandbox for testing purpose

可用的 Api 模型

Emmadedayo\VtPass\Model\VTClassicPurchase;
Emmadedayo\VtPass\Model\VTModernPurchase;

显式使用

获取服务和变体代码(现代模型和经典方式)

use Emmadedayo\VtPass\Model\MobileAirtime;

public function loadData(){
 
  VTModernPurchase::getServiceID([
      'identifier'=>'tv-subscription'
  ]); 
  
  VTModernPurchase::variations([
      'serviceID'=>'gotv'
  ]); 
  
  VTModernPurchase::category();
  
  VTModernPurchase::getProductOptions([
        'serviceID'=>'aero',
        'name'=>'passenger_type'
  ]);  
  
}

(现代模型方式)购买话费

use Emmadedayo\VtPass\Model\MobileAirtime;

public function buyAirtime(){ 
  $serviceID = 'mtn';
  $phone = '08011111111'; //demo phone number
  $amount = 100;
  $requestID = rand(1000,9000); //save your request id for re-query and verification purpose(optional)

  $result =  VTModernPurchase::purchase([
    'serviceID'   => $serviceID,
    'phone'       => $phone,
    'amount'      => $amount,
  ]);
  
  return Response::json($result);
  
}

响应

{
    "code": "000",
    "content": {
        "transactions": {
            "status": "delivered",
            "product_name": "MTN Airtime VTU",
            "unique_element": "08011111111",
            "unit_price": 100,
            "quantity": 1,
            "service_verification": null,
            "channel": "api",
            "commission": 4,
            "total_amount": 96.5,
            "discount": null,
            "type": "Airtime Recharge",
            "email": "emmanzley@yahoo.com",
            "phone": "08103141424",
            "name": null,
            "convinience_fee": 0,
            "amount": 100,
            "platform": "api",
            "method": "api",
            "transactionId": "16397074258999566580332982"
        }
    },
    "response_description": "TRANSACTION SUCCESSFUL",
    "requestId": "123255",
    "amount": "100.00",
    "transaction_date": {
        "date": "2021-12-17 03:17:05.000000",
        "timezone_type": 3,
        "timezone": "Africa/Lagos"
    },
    "purchased_code": ""
}

状态

VTModernPurchase::status([
  'request_id' => '24545544'
]);

响应

{
    "code": "000",
    "content": {
        "transactions": {
            "status": "delivered",
            "product_name": "MTN Airtime VTU",
            "unique_element": "08011111111",
            "unit_price": 100,
            "quantity": 1,
            "service_verification": null,
            "channel": "api",
            "commission": 4,
            "total_amount": 96.5,
            "discount": null,
            "type": "Airtime Recharge",
            "email": "emmanzley@yahoo.com",
            "phone": "08103141424",
            "name": null,
            "convinience_fee": 0,
            "amount": 100,
            "platform": "api",
            "method": "api",
            "transactionId": "16397074258999566580332982"
        }
    },
    "response_description": "TRANSACTION SUCCESSFUL",
    "requestId": "123255",
    "amount": "100.00",
    "transaction_date": {
        "date": "2021-12-17 03:17:05.000000",
        "timezone_type": 3,
        "timezone": "Africa/Lagos"
    },
    "purchased_code": ""
}

(经典模型方式)购买数据

use Emmadedayo\VtPass\Model\MobileData;

public function buyData(){ 

    $requestID = rand(1000,9000); //save your request id for re-query and verification purpose(optional)
    $serviceID = 'mtn-data';
    $billersCode = '08011111111';
    $variationCode = "mtn-10mb-100";
    $phone = '08011111111';
    $amount = 100;
    
     $result =  VTClassicPurchase::purchaseData($requestID,$serviceID,$billersCode,$variationCode,$amount,$phone);
     return Response::json($result);
      
}

响应

{
    "code": "000",
    "content": {
        "transactions": {
            "status": "delivered",
            "product_name": "MTN Data",
            "unique_element": "08011111111",
            "unit_price": 100,
            "quantity": 1,
            "service_verification": null,
            "channel": "api",
            "commission": 4,
            "total_amount": 96,
            "discount": null,
            "type": "Data Services",
            "email": "emmanzley@yahoo.com",
            "phone": "08103141424",
            "name": null,
            "convinience_fee": 0,
            "amount": 100,
            "platform": "api",
            "method": "api",
            "transactionId": "16397076684791728393807589"
        }
    },
    "response_description": "TRANSACTION SUCCESSFUL",
    "requestId": "09092109",
    "amount": "100.00",
    "transaction_date": {
        "date": "2021-12-17 03:21:08.000000",
        "timezone_type": 3,
        "timezone": "Africa/Lagos"
    },
    "purchased_code": ""
}

状态

MobileData::status([
  'request_id' => '24545544'
]);

响应

{
    "code": "000",
    "content": {
        "transactions": {
            "status": "delivered",
            "product_name": "MTN Data",
            "unique_element": "08011111111",
            "unit_price": 100,
            "quantity": 1,
            "service_verification": null,
            "channel": "api",
            "commission": 4,
            "total_amount": 96,
            "discount": null,
            "type": "Data Services",
            "email": "emmanzley@yahoo.com",
            "phone": "08103141424",
            "name": null,
            "convinience_fee": 0,
            "amount": 100,
            "platform": "api",
            "method": "api",
            "transactionId": "16397076684791728393807589"
        }
    },
    "response_description": "TRANSACTION SUCCESSFUL",
    "requestId": "09092109",
    "amount": "100.00",
    "transaction_date": {
        "date": "2021-12-17 03:21:08.000000",
        "timezone_type": 3,
        "timezone": "Africa/Lagos"
    },
    "purchased_code": ""
}

变更日志

有关最近更改的更多信息,请参阅changelog

测试

$ composer test

贡献

请参阅contributing.md以获取详细信息以及待办事项列表。

安全

如果您发现任何与安全相关的问题,请通过电子邮件联系作者而不是使用问题跟踪器。

致谢

许可协议

许可协议。有关更多信息,请参阅许可文件