bornmt/laravel-apcopay 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bornmt/laravel-apcopay

最新稳定版本:2.0.0

Composer 安装命令:

composer require bornmt/laravel-apcopay

包简介

Laravel integration for ApcoPay payment gateway (hosted page and payment status)

README 文档

README

Laravel integration for the ApcoPay payment gateway: hosted payment page and payment status (GetPayment / PreparePayment).

Requirements

  • PHP 8.2+
  • Laravel 10.x, 11.x or 12.x
  • GuzzleHTTP 7.x

Installation

composer require bornmt/laravel-apcopay

Publish the config file (optional; defaults are used from the package):

php artisan vendor:publish --tag=apcopay-config

Configuration

Add to your .env:

APCO_PAY_ENV=local
APCO_PAY_USERNAME=
APCO_PAY_PASSWORD=
APCO_PAY_PID=
APCOPAY_BASE_URL=https://www.apsp.biz/GPG/RESTAPI/api/OnlinePayments
APCOPAY_SANDBOX_BASE_URL=https://www.apsp.biz/GPGTest/RESTAPI/api/OnlinePayments

Set APCO_PAY_ENV=production for live payments.

After publishing the config, you can optionally customize http (e.g. timeout, connect_timeout) for the Guzzle client.

Usage

Inject BornMT\ApcoPay\Contracts\ApcoPayServiceInterface:

use BornMT\ApcoPay\Contracts\ApcoPayServiceInterface;
use BornMT\ApcoPay\Enums\PaymentStateFields;

// Get hosted page URL for redirect
$response = $apcoPay->getHostedPage(
    sessionReference: $sessionReference,
    amount: $amount,
    returnUrl: $returnUrl
);
$paymentUrl = $response['paymentURLField'];

// Get payment status
$payment = $apcoPay->getPayment($sessionReference);

// Get payment with retries (e.g. while processing)
$payment = $apcoPay->getPaymentWithRetry($sessionReference, 3);

// Check state
PaymentStateFields::PENDING->value;   // 1
PaymentStateFields::CANCELLED->value; // 2
PaymentStateFields::SUCCESS->value;   // 3
PaymentStateFields::FAILED->value;    // 4

Exceptions: the service throws BornMT\ApcoPay\Exceptions\ApcoPayException on API or retry failures.

Using the Facade

When the package is installed in a Laravel app, you can use the ApcoPay facade:

use BornMT\ApcoPay\Facades\ApcoPay;

$response = ApcoPay::getHostedPage($sessionReference, $amount, $returnUrl);
$payment = ApcoPay::getPayment($sessionReference);
$payment = ApcoPay::getPaymentWithRetry($sessionReference, 3); // with retries

Testing

composer test

Or with PHPUnit directly:

./vendor/bin/phpunit

License

The MIT License (MIT). Please see the License File for more information.

统计信息

  • 总下载量: 96
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固