Անցնել բովանդակությանը
OneGate փաստաթղթեր
Կառավարման վահանակ
Ուղեցույցներ

Այս էջը հասանելի է միայն անգլերենով։ Կոդը, API դաշտերը և նույնացուցիչները չեն թարգմանվում։

SDKs & Postman

Official helpers for TypeScript/Node and PHP.

TypeScript / Node

bash
npm install @onegate/node
ts
import { OneGate, verifyWebhook } from "@onegate/node";

const onegate = new OneGate(process.env.ONEGATE_SECRET_KEY!); // sk_test_... or sk_live_...
const payment = await onegate.payments.create(
  { amount: 12500, currency: "AMD", order_id: "ORD-1001", return_url: "https://shop.am/done" },
  { idempotencyKey: "ORD-1001" },
);
redirect(payment.checkout_url);

// Refunds require an idempotency key; derive it from your own refund record.
await onegate.refunds.create(payment.id, { amount: 2500 }, { idempotencyKey: "refund-4711" });

The client retries network errors, 5xx, 429 (honouring Retry-After) and 409 idempotency_request_in_progress up to 2 times, always with the same Idempotency-Key, so a retry can never repeat a payment or refund. Every POST gets a generated key if you pass none; pass your own to stay safe across process restarts.

PHP

bash
composer require onegate/onegate-php
php
$onegate = new \OneGate\Client(getenv('ONEGATE_SECRET_KEY'));
$payment = $onegate->payments()->create([
    'amount' => 12500, 'currency' => 'AMD', 'order_id' => 'ORD-1001',
    'return_url' => 'https://shop.am/done',
], idempotencyKey: 'ORD-1001');
header('Location: ' . $payment['checkout_url']);

$refund = $onegate->refund($payment['id'], ['amount' => 2500], idempotencyKey: 'refund-4711');

$event = \OneGate\Webhook::verify($rawBody, $_SERVER['HTTP_ONEGATE_SIGNATURE'],
    $_SERVER['HTTP_ONEGATE_TIMESTAMP'], getenv('ONEGATE_WEBHOOK_SECRET'));

The PHP client does not retry automatically; if you retry, reuse the same idempotencyKey.

Postman

Download the OneGate Postman collection, then set the secret_key variable to a Test key. It uses https://api.onegate.am and generates an idempotency key for each POST.

Packages are published from the OneGate repository; until they appear on npm and Packagist, install them from the release archive supplied by OneGate.