jpay-api/php-sdk 问题修复 & 功能扩展

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

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

jpay-api/php-sdk

Composer 安装命令:

composer require jpay-api/php-sdk

包简介

Php API SDK for J-Pay payment gateway

README 文档

README

Introduction

Php API SDK for J-Pay payment gateway

Installation

With Composer

$ composer require jpay-api/php-sdk
{
  "require": {
    "jpay-api/php-sdk": "~1.0"
  }
}

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
apiKey string Merchant API key for automatic MD5 request signing on Payments API calls.
environment Environment The API environment.
Default: Environment.PRODUCTION
timeout int Timeout for API calls in seconds.
Default: 30
enableRetries bool Whether to enable retries and backoff feature.
Default: false
numberOfRetries int The number of retries to make.
Default: 0
retryInterval float The retry time interval between the endpoint calls.
Default: 1
backOffFactor float Exponential backoff factor to increase interval between retries.
Default: 2
maximumRetryWaitTime int The maximum wait time in seconds for overall retrying requests.
Default: 0
retryOnTimeout bool Whether to retry on request timeout.
Default: true
httpStatusCodesToRetry array Http status codes to retry against.
Default: 408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524
httpMethodsToRetry array Http methods to retry against.
Default: 'GET', 'PUT', 'GET', 'PUT'
loggingConfiguration LoggingConfigurationBuilder Represents the logging configurations for API calls
proxyConfiguration ProxyConfigurationBuilder Represents the proxy configurations for API calls
verifyPeer bool Whether to verify SSL certificates.
Default: true
verifyHost bool Whether to verify SSL host names.
Default: true

The API client can be initialized as follows:

use JPayApiLib\Logging\LoggingConfigurationBuilder;
use JPayApiLib\Logging\RequestLoggingConfigurationBuilder;
use JPayApiLib\Logging\ResponseLoggingConfigurationBuilder;
use Psr\Log\LogLevel;
use JPayApiLib\Environment;
use JPayApiLib\JPayApiClientBuilder;

$client = JPayApiClientBuilder::init()
    ->apiKey('your-merchant-api-key')
    ->environment(Environment::PRODUCTION)
    ->loggingConfiguration(
        LoggingConfigurationBuilder::init()
            ->level(LogLevel::INFO)
            ->requestConfiguration(RequestLoggingConfigurationBuilder::init()->body(true))
            ->responseConfiguration(ResponseLoggingConfigurationBuilder::init()->headers(true))
    )
    ->build();

Environments

The SDK can be configured to use a different environment for making API calls. Available environments are:

Fields

Name Description
PRODUCTION Sandbox (Default)
ENVIRONMENT2 Production

Request Models & Builders

Each API endpoint supports typed request models with fluent builders aligned to the OpenAPI spec. All parameters use string types as defined in the API.

use JPayApiLib\Models\Requests\Builders\CreatePayoutRequestBuilder;

$request = CreatePayoutRequestBuilder::init()
    ->orderType('1')
    ->memberid('10010')
    ->outTradeNo('PO20260101001')
    ->amount('100.00')
    ->currency('USD')
    ->notifyurl('https://example.com/payout/notify')
    ->remark('Salary payout')
    ->sign($md5Sign)
    ->firstname('John')
    ->payeeCountry('US')
    ->payeeaccount('1234567890')
    ->bankcode('001')
    ->bankname('Test Bank')
    ->build();

$response = $client->getPayoutsApi()->createFromRequest($request);
/** @var \JPayApiLib\Models\ApiV1PaymentCreateOrderResponse $result */
$result = $response->getResult();

Response models are automatically deserialized (e.g. PayTradeQueryResponse, PaymentResponse).

Automatic Request Signing

When apiKey is configured, PaymentsApi automatically generates the MD5 signature (pay_md5sign) before sending outbound requests. You do not need to set payMd5Sign manually unless you want to override the computed value.

Signing follows the J-Pay signature algorithm: non-empty sign fields are sorted by name, joined as key=value&..., appended with &key={apiKey}, then MD5-hashed in uppercase.

For card payment creation (POST /pay_index), the signed fields are: pay_memberid, pay_orderid, pay_applydate, pay_bankcode, pay_notifyurl, pay_callbackurl, pay_amount.

List of APIs

SDK Infrastructure

Configuration

HTTP

Utilities

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-26