devlover/ppob

PPOB 多脉冲 API PHP 库。

0.2.1 2020-03-16 10:48 UTC

This package is auto-updated.

Last update: 2024-09-16 20:46:56 UTC


README

该包的目的是允许您的网站在印度尼西亚购买多种预付费数字产品,如 Token PLN、Pulsa、数据包等。

目前支持以下提供商

信用

感谢 https://github.com/rick20/ppob 分享此代码

安装

要开始使用 PPOB,运行此命令或将包添加到您的 composer.json

composer require devlover/ppob

配置

PPOB 包使用 Laravel 自动发现,因此它将自动加载。使用以下命令复制 config 文件:php artisan vendor:publish --provider="Devlover\PPOB\PPOBServiceProvider"

最后,在 .env 文件中添加您的提供商账户

MOBILEPULSA_USERNAME=<your-phone>
MOBILEPULSA_APIKEY=<your-api-key>

PORTALPULSA_USERNAME=<your-username>
PORTALPULSA_APIKEY=<your-apikey>
PORTALPULSA_SECRET=<your-secret>

TRIPAY_APIKEY=<your-apikey>
TRIPAY_PIN=<your-pin>

INDOH2H_USERNAME=<your-username>
INDOH2H_APIKEY=<your-apikey>

要在单个提供商中添加更多账户,请将这些账户添加到 config/ppob.php

...
'accounts' => [
    'account-A' => [
        'provider' => 'mobile-pulsa',
        'username' => 'usernameA',
        'apikey' => 'apikeyA'
    ],
    'account-B' => [
        'provider' => 'mobile-pulsa',
        'username' => 'usernameB',
        'apikey' => 'apikeyB'
    ],
]
...

如何使用

设置完成后,可以使用 PPOB 如下

use Devlover\PPOB\Products\Pulsa;
use Devlover\PPOB\Products\TokenPLN;
use Devlover\PPOB\Products\GenericProduct;

// Topup Pulsa
$status = PPOB::topup(new Pulsa('082112345678', 50000), 'ref123');

// Check your deposit balance 
$balance = PPOB::balance();

// Check status of a transaction
$status = PPOB::status('ref123');

// Use another account
$status = PPOB::account('account-portalpulsa')->topup(
  new TokenPLN('no-meter', 'no-hp', 100000), 'ref456'
);

// Purchase other products
$status = PPOB::account('account-tripay')->topup(
  new GenericProduct('subscriber-id', 'no-hp', 'product-code'), 'ref789'
);

错误 & 改进

请随意向我报告您发现的任何错误。我也非常乐意接收改进和添加其他 PPOB 提供商的拉取请求。如果您觉得这个包很有用,捐赠将会很棒! =)