idmahbub/ppob

PPOB 多脉冲 API PHP 库。

1.8 2024-02-21 01:45 UTC

This package is auto-updated.

Last update: 2024-09-21 03:14:40 UTC


README

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

目前支持以下提供者

  • MobilePulsa
  • PortalPulsa
  • Tripay
  • IndoH2H
  • DIGIFLAZZ

安装

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

composer require idmahbub/ppob

配置

PPOB 包使用 Laravel 自动发现,因此将自动加载。使用以下命令复制 config 文件:php artisan vendor:publish --provider="Idmahbub\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>

DIGIFLAZZ_USERNAME=
DIGIFLAZZ_DEV_APIKEY=
DIGIFLAZZ_PROD_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 Idmahbub\PPOB\Products\Pulsa;
use Idmahbub\PPOB\Products\TokenPLN;
use Idmahbub\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'
);

//add method Pricelist as pre or pasca
$json += array("df" => PPOB::account('account-jh2h')->pricelist($request->category));

错误 & 改进

请随意报告您发现的任何错误。