inpayuz/inpay-php 问题修复 & 功能扩展

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

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

inpayuz/inpay-php

Composer 安装命令:

composer require inpayuz/inpay-php

包简介

Official inPAY PHP SDK — create invoices, check status, and verify webhooks for the inPAY payment platform (Uzbekistan).

README 文档

README

Official PHP SDK for the inPAY payment platform (Uzbekistan). One inPAY contract → accept Click, Payme, UzCard/HUMO with a few lines of code.

Bitta inPAY shartnomasi bilan barcha to'lov usullarini qabul qiling — har bir PSP bilan alohida integratsiya qilish shart emas.

O'rnatish / Installation

composer require inpayuz/inpay-php

Talab: PHP ≥ 7.4, ext-curl, ext-json.

Tez boshlash / Quick start

use InPay\InPay;

$inpay = new InPay([
    'merchant_id'    => 12345,          // kassa merchant_id
    'bearer_token'   => 'xxxxxxxx',     // kassa bearer token
    'webhook_secret' => 'yyyyyyyy',     // webhook imzosi uchun
]);

// 1) To'lov yaratish
$invoice = $inpay->create([
    'amount'       => 50000,            // so'm (min 1000)
    'callback_url' => 'https://shop.uz/inpay/webhook.php',
    'order_id'     => 'A-123',          // sizning ichki reference
]);

header('Location: ' . $invoice->payUrl);   // foydalanuvchini yo'naltiring

$invoice:

Xususiyat Izoh
$invoice->orderId inPAY buyurtma ID (16 hex)
$invoice->payUrl Universal checkout sahifasi
$invoice->payUrlLink So'ralgan usulga mos to'g'ridan havola
$invoice->payLinks ['click'=>..., 'payme'=>...] to'g'ridan havolalar

To'g'ridan-to'g'ri bitta usul

$invoice = $inpay->create([
    'amount'         => 50000,
    'payment_method' => 'click',   // 'click' | 'payme' | 'myuzcard'
]);
header('Location: ' . $invoice->payUrlLink);

2) Holatni tekshirish / Status

$tx = $inpay->status('a1b2c3d4e5f6a7b8');
if ($tx->isPaid()) {
    // ...
}
// $tx->status: 'pending' | 'success' | 'failed'

3) Webhook (payment.success)

inPAY to'lov muvaffaqiyatli bo'lganda callback_url'ingizga POST yuboradi va uni X-InPAY-Signature (HMAC-SHA256) bilan imzolaydi. SDK imzoni constant-time tekshiradi.

use InPay\InPay;
use InPay\Transaction;

$inpay = new InPay([
    'merchant_id'    => 12345,
    'bearer_token'   => 'xxxxxxxx',
    'webhook_secret' => 'yyyyyyyy',
]);

$inpay->webhook()->onSuccess(function (Transaction $tx) {
    // ⚠️ IDEMPOTENT bo'ling — takror kelishi mumkin
    // if (already_paid($tx->orderId)) return;
    // mark_paid($tx->orderId, $tx->amount);
});

Qo'lda tekshirish (framework ichida):

$wh   = $inpay->webhook();
$body = file_get_contents('php://input');
$sig  = $_SERVER['HTTP_X_INPAY_SIGNATURE'] ?? '';

if ($wh->isValid($body, $sig)) {
    $tx = $wh->verify($body, $sig);   // Transaction
}

Xavfsizlik: imzo tekshiruvidan o'tmagan webhook'ni HECH QACHON to'lov deb qabul qilmang. Tekshiruvsiz har kim soxta success yuborishi mumkin.

Xatolar / Errors

use InPay\Exception\ApiException;      // inPAY biznes-xatosi (error_code bilan)
use InPay\Exception\SignatureException;// webhook imzosi mos emas
use InPay\Exception\InPayException;    // bazaviy tur (hammasini ushlaydi)

try {
    $inpay->create([...]);
} catch (ApiException $e) {
    echo $e->getErrorCode();   // masalan "MERCHANT_INACTIVE", "AMOUNT_TOO_LOW"
}

Litsenziya

MIT © inPAY

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固