Quickstart
On this page
Take one test payment from start to finish: create it, send the customer through 3D Secure, get the result by webhook and refund it.
You need:
- a sandbox secret key (
sk_sandbox_…) curl- Node.js 18 or later, for the webhook handler in step 3
- a browser, for the 3D Secure page in step 5
- a public HTTPS address for webhooks. On your own machine, use a tunnel that forwards a public address to a local port.
The samples use the address of this site. If this is not your sandbox, use your sandbox address followed by /v1 instead. Sandbox payments move no money.
1. Get a sandbox key
In the merchant panel of your sandbox, open the API keys page in the Developers menu and create a secret key. It is shown once. Keep it on your server, never in a browser or an app.
Check that the key works:
curl https://api.pf.organizer.tr/v1/balance \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY"
A 200 with your balance means the key works. A 401 means it does not. error.code says why: api_key_missing, api_key_invalid, api_key_revoked, or api_key_mode_mismatch (a live key on the sandbox, or the reverse). See errors.
2. Register your website
After 3D Secure the customer comes back to your website, and webhooks are posted to your server. On live, both addresses must be on a website you registered. Add yours on the Websites & callbacks tab of Business details.
In the sandbox an unregistered address still works. The request gets a warning on the Logs page in the Developers menu, so you can go on while your registration waits for approval.
3. Create a webhook endpoint
Create the endpoint before the payment, so that you receive the payment's events. The url in this sample is a placeholder. Use the address of your tunnel followed by /webhooks/odeme. The handler below listens on port 3000 at that path, so forward the tunnel to port 3000.
curl -X POST https://api.pf.organizer.tr/v1/webhook_endpoints \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
-H "Idempotency-Key: webhook-endpoint-orders" \
-H "Content-Type: application/json" \
-d '{"url": "https://modakitabevi.com.tr/webhooks/odeme", "enabled_events": ["payment_intent.succeeded", "payment_intent.payment_failed", "refund.succeeded", "refund.failed"]}'
{
"id": "we_01J9ZQC8D0F2H4K6M8P1R3T5V7",
"object": "webhook_endpoint",
"url": "https://modakitabevi.com.tr/webhooks/odeme",
"enabled_events": ["payment_intent.succeeded", "payment_intent.payment_failed", "refund.succeeded", "refund.failed"],
"status": "enabled",
"description": null,
"secret": "REPLACE_WITH_THE_SECRET_FROM_THE_RESPONSE",
"created": 1790000000,
"metadata": {}
}
Store secret on your server. It is shown only in this response. If you run the call again with another url, change the Idempotency-Key too. A repeat of the same request returns the endpoint without its secret.
Every delivery carries a signature in the Argus-Signature header. Check it before you trust the event. This Node.js handler does that. The webhooks guide has the same check in PHP, C#, Go and Python.
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
function verify(rawBody, header, secret) {
const parts = String(header ?? '').split(',').map((p) => p.trim().split('='));
const t = parts.find(([k]) => k === 't')?.[1];
if (!t || Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest();
return parts
.filter(([k]) => k === 'v1')
.some(([, v]) => {
const given = Buffer.from(v ?? '', 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
});
}
const app = express();
app.post('/webhooks/odeme', express.raw({ type: 'application/json' }), (req, res) => {
const raw = req.body.toString('utf8');
if (!verify(raw, req.get('Argus-Signature'), process.env.ARGUS_WEBHOOK_SECRET)) return res.sendStatus(400);
const event = JSON.parse(raw);
console.log(event.type, event.data.object.id);
res.sendStatus(200);
});
app.listen(3000);
Save it as webhook.mjs. The .mjs ending lets Node read import. In the same folder, install its one package with npm install express. Then start it with the secret from the response above:
ARGUS_WEBHOOK_SECRET=whsec_YOUR_SECRET node webhook.mjs
Send a test event to check your handler. Within a few seconds it logs a line that starts with webhook_endpoint.test:
curl -X POST https://api.pf.organizer.tr/v1/webhook_endpoints/we_01J9ZQC8D0F2H4K6M8P1R3T5V7/test_event \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
-H "Idempotency-Key: webhook-test-1"
4. Create and confirm the payment
Save the request as payment.json. Your server sends the card with the secret key. confirm: true creates and charges the payment in one call, and three_d_secure: required sends this test through 3D Secure.
{
"amount": 12500,
"currency": "try",
"confirm": true,
"payment_method_data": {
"type": "card",
"card": {
"number": "4109090000000011",
"exp_month": 12,
"exp_year": 2030,
"cvc": "123",
"holder_name": "AYSE YILMAZ"
},
"billing_details": {
"name": "Ayşe Yılmaz",
"email": "ayse.yilmaz@example.com",
"address": {"line1": "Caferağa Mah. Moda Cad. No:12", "city": "Kadıköy", "country": "TR"}
}
},
"payment_method_options": {"card": {"three_d_secure": "required"}},
"return_url": "https://modakitabevi.com.tr/odeme/sonuc",
"description": "Sipariş SIP-2026-10419",
"metadata": {"order_id": "SIP-2026-10419"}
}
curl -X POST https://api.pf.organizer.tr/v1/payment_intents \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
-H "Idempotency-Key: order-SIP-2026-10419" \
-H "Content-Type: application/json" \
-d @payment.json
amount is in kuruş, so 12500 is ₺125.00. If the connection drops, send the same request with the same Idempotency-Key. The card is charged at most once. The repeat returns the first response, so its status is the one from then. Read the payment to see where it is now. The same key with a different request returns 409 idempotency_conflict.
If your account accepts cards only from the browser, this call returns 403 card_data_not_allowed. Collect the card in the browser and send payment_method instead of payment_method_data.
If it returns 403 merchant_setup_incomplete, your payment institution has not finished setting up your account. Nothing was charged. Contact them; retrying does not help.
5. Send the customer to 3D Secure
The response has status: requires_action:
{
"id": "pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M",
"object": "payment_intent",
"amount": 12500,
"amount_charged": 12500,
"surcharge": 0,
"amount_capturable": 0,
"amount_received": 0,
"captured_minor": 0,
"refunded_minor": 0,
"amount_refundable": 0,
"currency": "try",
"status": "requires_action",
"capture_method": "automatic",
"installments": 1,
"three_d_secure": {"requested": "required", "effective": "required"},
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": {
"url": "https://pay.example.com/3ds/pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M",
"return_url": "https://modakitabevi.com.tr/odeme/sonuc"
}
},
"metadata": {"order_id": "SIP-2026-10419"},
"latest_attempt": "att_01J9ZQ3T7V9X1Z3B5D7F9H2K4N",
"created": 1795163400,
"livemode": false
}
Store the id with your order. Then send the customer's browser to next_action.redirect_to_url.url. For this test, open that address in your own browser.
The sandbox shows a simulated bank page that asks for a code. Enter 00000 to approve. Other codes make the check fail; see Testing.
The browser then goes to your return_url. If that page does not exist yet, the browser shows an error. The address bar still holds payment_intent and argus_signature, which is enough for this test.
6. Read the result
The customer comes back to your return_url with payment_intent and argus_signature in the query string. The signature proves that the redirect came from us. To check it, you need a return signing secret. Verify the redirect shows how to create one and run the check. You can skip it for this test.
The redirect only brings the customer back. To get the result, read the payment from your server:
curl https://api.pf.organizer.tr/v1/payment_intents/pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY"
{
"id": "pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M",
"object": "payment_intent",
"amount": 12500,
"amount_charged": 12500,
"surcharge": 0,
"amount_capturable": 0,
"amount_received": 12500,
"captured_minor": 12500,
"refunded_minor": 0,
"amount_refundable": 12500,
"currency": "try",
"status": "succeeded",
"capture_method": "automatic",
"installments": 1,
"three_d_secure": {"requested": "required", "effective": "required"},
"card": {"brand": "visa", "last4": "0011", "masked": "410909******0011", "card_type": "credit", "domestic": true},
"next_action": null,
"fees": {
"object": "payment_fees",
"status": "booked",
"currency": "try",
"amount": 12500,
"rate_ppm": 27900,
"fixed": 0,
"pf_fee": 349,
"fee_tax": 70,
"total": 419,
"installment_surcharge": 0,
"net_to_merchant": 12081,
"refunded": {"amount": 0, "pf_fee_refunded": 0, "fee_tax_refunded": 0, "installment_surcharge_refunded": 0, "merchant_debit": 0},
"net_after_refunds": 12081
},
"settlement": [
{"id": "sti_01J9ZQ3V8X0Z2B4D6F8H1K3M5P", "object": "payment_settlement", "type": "capture", "status": "pending", "currency": "try", "net": 12081, "reserve": 0, "available_on": "2026-11-23", "released_at": null, "reserve_release_on": null, "reserve_released_at": null, "payout": null}
],
"metadata": {"order_id": "SIP-2026-10419"},
"latest_attempt": "att_01J9ZQ3T7V9X1Z3B5D7F9H2K4N",
"created": 1795163400,
"livemode": false
}
status |
What to show |
|---|---|
succeeded |
The order is paid. |
requires_payment_method |
The card was declined or 3D Secure failed. Ask for another card. |
processing |
The bank has not answered yet. Wait for the webhook. |
Card payments covers every status.
7. Get the webhook
Your endpoint also receives payment_intent.succeeded. It arrives even if the customer closes the tab before coming back, so use it to mark the order paid. The handler from step 3 logs:
payment_intent.succeeded pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M
An event can arrive more than once. Store event.id and skip events you have already handled. Answer with a 2xx within 10 seconds and do slow work afterwards. A failed delivery is retried for about four days.
8. Refund the payment
Refund the whole payment with its id:
curl -X POST https://api.pf.organizer.tr/v1/refunds \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
-H "Idempotency-Key: refund-order-SIP-2026-10419" \
-H "Content-Type: application/json" \
-d '{"payment_intent": "pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M"}'
{
"id": "re_01J9ZQ3W8Y0A2C4E6G8J1L3N5Q",
"object": "refund",
"amount": 12500,
"amount_returned_to_card": 12500,
"fees": {"currency": "try", "pf_fee_refunded": 349, "fee_tax_refunded": 70, "fee_refunded": 419, "installment_surcharge_refunded": 0, "fee_retained_on_void": 0, "merchant_debit": 12081},
"currency": "try",
"payment_intent": "pi_01J9ZQ3T7V9X1Z3B5D7F9H2K4M",
"status": "succeeded",
"method": "void",
"scheduled_for": null,
"settlement_netting": null,
"reason": null,
"failure_reason": null,
"metadata": {},
"created": 1795164000
}
To refund part of a payment, send amount in kuruş. This refund covered the whole payment, so nothing is left to refund. On the day of the sale the bank usually cancels the charge (method: void) and the customer sees nothing on the statement. fees shows the commission given back (all of it, for a void). settlement_netting is null because nothing was taken from your settlement. Your endpoint receives refund.succeeded. A refund can also be processing or pending_approval. Refunds explains both.
If something goes wrong
| What you see | Cause | What to do |
|---|---|---|
401 on any call |
The key is wrong, revoked or for the other mode. | Copy the key again from the API keys page. Use a sk_sandbox_… key on the sandbox. |
409 idempotency_conflict |
You reused an Idempotency-Key with a different request. |
Use a new key for each new request. Reuse a key only to repeat the same request. |
The payment stays requires_action |
The customer has not finished 3D Secure. | Open next_action.redirect_to_url.url and enter 00000. |
| No webhook arrives | The tunnel does not reach port 3000, or your handler answered with something other than 2xx. |
Open the Webhooks page in the Developers menu and read the attempts. Your handler answers 400 when the signature check fails, so check that ARGUS_WEBHOOK_SECRET is the full secret from step 3. |
Errors and retries covers every error.
When you get paid
The payment's settlement array shows it: available_on is the date the net amount (12081, the sale less the commission) reaches your available balance, and a payout then sends it to your bank account. Balance and payouts explains both.
Before you go live
Sandbox and live are separate: keys, webhook endpoints and registrations are made again on live. Going live is the checklist to work through first.
In the API reference
- Create a webhook endpoint
- Send a test event
- Create a payment intent
- Retrieve a payment intent
- Create a refund
Next: Choose how your customers enter cards in Card payments and 3D Secure, then try the failure cases with Test cards and sandbox.