pashazahari/billplz-bundle

将Billplz集成到您的Symfony应用程序中

安装: 0

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 1

类型:symfony-bundle

0.1 2024-08-15 03:46 UTC

This package is not auto-updated.

Last update: 2024-09-27 02:54:34 UTC


README

这是一个用于Symfony应用程序的billplz支付网关包装器。

安装

composer require pashazahari/billplz-bundle

要求

  • PHP 8.0+
  • Symfony 8.0+

配置

# .env
BILLPLZ_API_KEY=
BILLPLZ_SIGNATURE_KEY=
BILLPLZ_SANDBOX=
BILLPLZ_SANDBOX_API_KEY=
BILLPLZ_SANDBOX_SIGNATURE_KEY=
# /config/packages/fd_billplz.yaml
fd_billplz:
    enable_sandbox: "%env(bool:BILLPLZ_SANDBOX)%" # true or false
    sandbox:
        api_key: "%env(BILLPLZ_SANDBOX_API_KEY)%"
        signature_key: "%env(BILLPLZ_SANDBOX_SIGNATURE_KEY)%"
        collection: # add your bill collection here
            - { name: "", id: ""} # will use when create new bill
    live:
        api_key: "%env(BILLPLZ_API_KEY)%"
        signature_key: "%env(BILLPLZ_SIGNATURE_KEY)%"
        collection:
            - { name: "", id: ""}

用法

/**
 * Note: if you have set 'enable_sandbox' to true, billplz will use 'sandbox' configuration only.
 */
function createPayment(BillplzInterface $billplz)
{
    /**
     * Assume you have set { name: "product", id: "ae12345"} in collection.
     * 
     * It will get the id from the given name, you don't have to do anything. 
     */
    $response = $billplz->createBill("product", "lorem@ipsum.com", null, "Lorem Ipsum", 100, "https://127.0.0.1/payment/success", "A new product", []);

    // your own logic here...
}