Download the PHP package goletter/hyperf-card without Composer

On this page you can find all versions of the php package goletter/hyperf-card. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-card

Goletter Card SDK

多平台卡片 API SDK,支持 Airwallex、Slash、Lampay、Photonpay、Wasabi。

安装

依赖要求

架构说明

本包分两层(请按场景选用):

层级 入口 命名空间 行为
SDK 层 $bundle->card() / api() Platforms\{Vendor}\Api\CardApi 官方路径 + 原始 JSON;失败抛 *ApiException
适配层 $bundle->adapter() Platforms\{Vendor}\Adapter\CardAdapter {code,msg,data} + 字段/状态映射(Lampay 无适配层,adapter() 为 null)

推荐:CardFactory → CardPlatformBundle → 按需 card() 或 adapter()。

工厂模式(推荐,以 Slash 为例)

统一入口是 CardFactory,返回 CardPlatformBundle:

1. 静态创建(任意 PHP 项目)

三种写法等价,任选其一:

2. 通过 Bundle 调用 Slash

适配层(业务统一字段,推荐现有业务继续用)

分页拉取全部卡片:

SDK 层(官方原始响应)

3. Hyperf 中使用(配置 + DI)

发布配置:

编辑 config/autoload/card.php 中的 slash 段(可用环境变量):

注入工厂后,配置文件会自动合并,调用时只需传覆盖项:

未注入时也可手动把配置灌进共享工厂:

4. 其它平台(同一套工厂)

写法 平台
CardFactory::airwallex($config) / make(0, …) Airwallex
CardFactory::slash($config) / make(1, …) Slash
CardFactory::lampay($config) / make(2, …) Lampay
CardFactory::photonpay($config) / make(3, …) Photonpay
CardFactory::wasabi($config) / make(4, …) Wasabi

Airwallex Token 持久化示例:

Airwallex API

配置

配置参数说明

参数 类型 必填 默认值 说明
baseUrl string 否 https://api-demo.airwallex.com API 基础地址
apiKey string 是 - API Key
clientId string 是 - Client ID
timeout int 否 60 请求超时时间(秒)
requestSource int 否 4 请求来源标识

认证 API

登录获取 Token

注意: SDK 会自动管理 token 的获取和刷新,无需手动处理。当 token 过期时,会自动重新获取。

卡片 API

获取卡片列表

获取卡片详情

获取卡片限额

创建卡片

更新卡片

冻结卡片

解冻卡片

取消卡片

手动设置 Token

如果已有有效的 token,可以手动设置,避免重复登录:

异常处理

SDK 提供了两种异常类型:

  1. AirwallexApiException - 通用 API 异常
  2. AirwallexTokenExpiredException - Token 过期异常(继承自 AirwallexApiException)

完整使用示例

Slash API

推荐使用 工厂模式 创建:CardFactory::slash($config)。

配置

配置参数说明

参数 类型 必填 默认值 说明
base_url / baseUrl string 否 https://api.slash.com API 基础地址
api_key / apiKey string 是 - API Key(X-API-Key)
timeout int 否 60 请求超时(秒)
rsa_public_key string 否 - 请求敏感字段时的 RSA 公钥
private_key string 否 - 解密 PAN/CVV 的私钥 PEM
vault_base_url string 否 自动推导 敏感读卡 vault 地址
merchant_allowlist array 否 [] updateCard 商户白名单

卡片 API

以下示例基于工厂适配层:$adapter = CardFactory::slash($config)->adapter();

获取卡片列表

Slash 仅支持 cursor 分页(不支持 limit / offset)。适配层返回 Result 信封:

获取卡片详情

SDK 层(原始 Slash API)

创建虚拟卡片

创建实体卡片

更新卡片

部分更新卡片

冻结卡片

解冻卡片

取消卡片

删除卡片

设置消费限制

获取消费限制

异常处理

SDK 提供了两种异常类型:

  1. SlashApiException - 通用 API 异常
  2. SlashTokenExpiredException - API Key 无效或过期异常(继承自 SlashApiException)

完整使用示例

Lampay API

基于 Lampay Consumer API(Base URL: https://api.lampay.app)。 认证使用 API Key + RSA-SHA256 请求签名 / 响应验签,发卡等敏感接口使用 RSA-OAEP-AES-256-GCM 加密信封。

配置

配置参数说明

参数 类型 必填 默认值 说明
base_url / baseUrl string 否 https://api.lampay.app API 基础地址
api_key / apiKey string 是 - API Key 调用凭证
private_key / merchantAuthPrivateKeyPem string 是 - 客户端鉴权私钥 PEM
public_key / platformAuthPublicKeyPem string 是 - 平台鉴权公钥 PEM(响应/Webhook 验签)
merchant_enc_private_key string 否 - 客户端加密私钥(解密敏感响应/Webhook)
platform_enc_public_key string 否 - 平台加密公钥(加密发卡请求)
webhook_receiver_key_id string 否 - Webhook 接收方 API Key 业务 ID
provider_type string 否 10010105 部分卡片路径中的提供商类型
api_version string 否 1 X-API-VERSION
timeout int 否 60 请求超时(秒)

卡片 API

Webhook

异常处理

Photonpay API

配置

配置参数说明

参数 类型 必填 默认值 说明
base_url / baseUrl string 否 https://x-api.photonpay.com API 基础地址
api_key / apiKey string 是 - API Key
api_secret / apiSecret string 是* - API Secret(无 token 时用于登录)
private_key string 否 - RSA 私钥(X-PD-SIGN)
token string 否 - 已有 access token
verify_ssl bool 否 true TLS 证书校验
timeout int 否 60 请求超时时间(秒)

认证 API

未传入 token 或临近过期时,SDK 会自动调用 /api/v1/auth/token 刷新。

卡片 API

异常处理

Wasabi API

注意事项

Airwallex

  1. Token 管理:SDK 会自动管理 token 的获取和刷新。Token 会在过期前 60 秒自动刷新。

  2. 环境配置:

    • 测试环境:https://api-demo.airwallex.com
    • 生产环境:https://api.airwallex.com
  3. 请求来源:requestSource 参数默认为 4,如有特殊要求请根据实际情况调整。

Slash

  1. API Key 认证:Slash 使用 API Key 进行认证,通过 X-API-Key header 传递。

  2. 环境配置:

    • 生产环境:https://api.slash.com
    • 请根据实际情况配置正确的 API 地址
  3. 消费限制:Slash 支持设置消费限制规则,可以基于商户类别、交易金额等进行控制。

Lampay

  1. 认证方式:X-Api-Key + RSA-SHA256 请求签名(X-Signature),响应使用平台鉴权公钥验签。

  2. 加密:发卡请求使用 RSA-OAEP-AES-256-GCM 信封;敏感信息与 Webhook 需客户端加密私钥解密。

  3. 环境配置:

  4. 卡片管理:列表/详情、加密发卡、消费规则、冻结/解冻/注销、交易查询与 Webhook。

Photonpay

  1. Token 管理:未传入 token 或临近过期时,会调用 /api/v1/auth/token(可用 token_url 覆盖)。请配置 api_key + api_secret。

  2. 环境配置:

    • 默认:https://x-api.photonpay.com
    • TLS 校验默认开启,可通过 verify_ssl => false 关闭(仅建议本地调试)
  3. 卡片功能:当前适配 /vcc/openApi/v4/* 与账户查询接口(cardList / cardInfo / 冻结解冻 / 交易等)。

Wasabi

  1. 认证:X-WSB-API-KEY + RSA 请求签名;响应用平台公钥验签,敏感数据用商户私钥解密。

  2. 环境配置:沙箱默认 https://sandbox-api-merchant.wasabicard.com,生产请换成正式域名。

通用

  1. 请求超时:默认超时时间为 60 秒,可根据实际情况调整。

  2. 错误处理:建议在生产环境中对异常进行适当的处理和日志记录。

  3. API 文档:具体 API 字段和参数请参考各平台的官方 API 文档。

许可证

MIT


All versions of hyperf-card with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
ext-openssl Version *
guzzlehttp/guzzle Version ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package goletter/hyperf-card contains the following files

Loading the files please wait ...