Skip to content

IntPay PHP SDK

IntPay 官方 PHP SDK,用于快速接入 IntPay 支付网关。

该 SDK 提供完整的服务端能力,帮助商户安全、高效地完成支付接入。

🚀 功能特性

  • 支持 Iframe 收银台支付
  • 支持服务端直连支付接口
  • 内置签名生成与验签机制
  • 支持支付回调(Webhook)验签
  • 标准化请求与响应处理
  • 生产环境可用的错误处理机制

下载地址

https://developer.links-pay.com/sdk/linkpay-php-sdk.zip

📦 环境要求

  • PHP >= 7.2
  • 已开启 cURL 扩展

📥 安装方式

下载 SDK 后,引入核心文件:

php
require_once 'src/IntPayClient.php';
require_once 'src/SignUtils.php';

⚙️ 初始化配置

php
use IntPay\IntPayClient;

$client = new IntPayClient([
    'base_url' => 'https://api.IntPay.com',
    'app_id'   => 'YOUR_APP_ID',
    'app_key'  => 'YOUR_APP_KEY',
]);

💳 快速开始

1️⃣ 创建 Iframe 支付链接

php
$response = $client->createIframePayment([
    'orderNo'    => 'ORDER_123456',
    'amount'     => '10.00',
    'currency'   => 'USD',
    'notifyUrl'  => 'https://yourdomain.com/notify',
    'returnUrl'  => 'https://yourdomain.com/return',
    'subject'    => 'Test Order',
]);

$iframeUrl = $response['data']['iframeUrl'];

前端嵌入:

html
<iframe src="IFRAME_URL" width="100%" height="600"></iframe>

2️⃣ 服务端直连支付

php
$response = $client->createPayment([
    'orderNo'  => 'ORDER_123456',
    'amount'   => '10.00',
    'currency' => 'USD',
    'token'    => 'CARD_TOKEN',
]);

🔐 签名机制

SDK 已内置签名逻辑,自动完成请求签名,无需额外处理。

🔔 回调通知(Webhook)

php
use IntPay\SignUtils;

$headers = getallheaders();
$body    = file_get_contents('php://input');

$isValid = SignUtils::verify($headers, $body, 'YOUR_APP_KEY');

if (!$isValid) {
    http_response_code(400);
    exit('Invalid signature');
}

$data = json_decode($body, true);

📄 API 方法说明

createIframePayment

创建收银台支付链接。

参数必填说明
orderNo商户订单号
amount金额
currency币种
notifyUrl回调地址
returnUrl跳转地址
subject商品描述

createPayment

创建直连支付。

参数必填说明
orderNo商户订单号
amount金额
currency币种
token支付 Token

⚠️ 错误处理

php
if ($response['code'] !== '0000') {
    throw new Exception($response['message']);
}

🔒 安全建议

  • 必须校验回调签名
  • 不要在前端暴露 app_key
  • 生产环境必须使用 HTTPS
  • 对输入参数进行校验

📜 License

本 SDK 仅用于 IntPay 官方接入使用。