lzbrest/payment-sdk

There is no license information available for the latest version (0.0.3) of this package.

Maintainers

Package info

github.com/lzfr/payment-sdk

pkg:composer/lzbrest/payment-sdk

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.3 2026-01-27 07:50 UTC

This package is not auto-updated.

Last update: 2026-04-08 11:46:54 UTC


README

安装

composer require lzbrest/payment-sdk

如果包版本还在开发阶段:

composer require lzbrest/payment-sdk:@dev

配置

发布配置文件:

php artisan vendor:publish --provider="Lzbrest\PaymentSdk\PaymentServiceProvider" --tag=config

配置文件路径:config/payment.php

默认支持驱动:

  • alipay
  • wechat
  • stripe
  • paypal

可通过环境变量指定默认驱动与各驱动的接口地址:

PAYMENT_DRIVER=alipay
ALIPAY_ENDPOINT=http://localhost:8080/api/payment
WECHAT_ENDPOINT=http://localhost:8080/api/payment
STRIPE_ENDPOINT=http://localhost:8080/api/payment
PAYPAL_ENDPOINT=http://localhost:8080/api/payment

使用方式

Facade

use Payment;

$result = Payment::pay([
    'order_id' => 1001,
    'amount' => 199,
]);

指定驱动:

$result = Payment::pay([
    'order_id' => 1001,
    'amount' => 199,
], 'stripe');

说明:如果不传 $driver,会使用 PAYMENT_DRIVER 配置的默认驱动;未配置默认驱动会抛出异常。

返回结构

pay() 返回数组:

  • status:HTTP 状态码
  • body:响应原始内容
  • json:解析后的 JSON(若非 JSON 则为 null)

测试

vendor/bin/phpunit