Quickstart
Take a test payment with the hosted payment page (checkout), the integration that needs the least code.
-
Get your test key
In the dashboard, copy your
sk_test_…key. Keep it on your server, never in a mobile app or in JavaScript that runs in the browser. -
Initialize a checkout
Fenêtre de terminal curl https://api.senfenico.com/v1/payment/checkouts/initialize/ \-H "X-API-KEY: sk_test_..." \-H "Content-Type: application/json" \-d '{"amount": 1000, "success_url": "https://example.com/success", "cancel_url": "https://example.com/cancel"}'$ch = curl_init('https://api.senfenico.com/v1/payment/checkouts/initialize/');curl_setopt_array($ch, [CURLOPT_POST => true,CURLOPT_RETURNTRANSFER => true,CURLOPT_TIMEOUT => 30,CURLOPT_HTTPHEADER => ['X-API-KEY: ' . getenv('SENFENICO_KEY'),'Content-Type: application/json',],CURLOPT_POSTFIELDS => json_encode(['amount' => 1000,'success_url' => 'https://example.com/success','cancel_url' => 'https://example.com/cancel',]),]);$res = json_decode(curl_exec($ch), true);$url = $res['data']['authorization_url'];import osimport requestsres = requests.post("https://api.senfenico.com/v1/payment/checkouts/initialize/",headers={"X-API-KEY": os.environ["SENFENICO_KEY"]},json={"amount": 1000,"success_url": "https://example.com/success","cancel_url": "https://example.com/cancel",},timeout=30,)url = res.json()["data"]["authorization_url"]const res = await fetch('https://api.senfenico.com/v1/payment/checkouts/initialize/', {method: 'POST',headers: { 'X-API-KEY': process.env.SENFENICO_KEY, 'Content-Type': 'application/json' },body: JSON.stringify({ amount: 1000, success_url: 'https://example.com/success', cancel_url: 'https://example.com/cancel' }),});const { data } = await res.json(); -
Redirect the customer to
authorization_url{"status": true,"message": "Checkout initialized","data": {"reference": "CHK261126-101502--1ba1b4d126","authorization_url": "https://api.senfenico.com/v1/checkout_payment/payment_page/CHK261126-101502--1ba1b4d126/","live_mode": false}}On the page, pay with a test number, for example the Orange number
76000000with amount1000and OTP123456. -
Confirm the payment server-side
Senfenico sends the customer back to
success_url?reference=CHK…. Anyone can open that URL, so it proves nothing. Fetch the checkout from your server and check its status and amount:Fenêtre de terminal curl https://api.senfenico.com/v1/payment/checkouts/CHK261126-101502--1ba1b4d126/ \-H "X-API-KEY: sk_test_..."{"status": true,"message": "Checkout details retrieved","data": {"reference": "CHK261126-101502--1ba1b4d126","amount": 1000,"status": "success","live_mode": false}}The order is paid only if
data.statusissuccessanddata.amountmatches your order. In production, also subscribe to thecharge.successwebhook, the only one that arrives if the customer closes the page before the end. See Confirm the payment server-side.