PSLWallet API v1
Entegre peman USD nan platfòm ou. Senp, sekirize, rapid.
Vèsyon 1.0
Monè : USD
REST / JSON
OTP Email
URL debaz
https://pslwallet.com/pslwallet/api/v1
Otantifikasyon
Tout demann (sof /health) bezwen kle API ou nan header HTTP :
HTTP HeaderX-API-Key: votre_api_key_ici
Oswa via Bearer token :
HTTP HeaderAuthorization: Bearer votre_api_key_ici
⚠️ Pa janm ekspoze kle API ou nan kòd JavaScript frontend côté kliyan. Toujou fè apèl yo depi sèvè backend ou.
Mòd TEST / LIVE
De mòd disponib pou devlope ak teste san risk.
| Mòd | Kijan aktive | Konpòtman |
|---|---|---|
| LIVE | 5364b6aaec51f74c... | Vre debi USD sou balans kliyan an |
| TEST | test_5364b6aaec51f74c... | Similasyon — pa gen vrè debi |
💡 Nan mòd TEST, referans yo kòmanse ak PSL-TEST- epi tranzaksyon yo anrejistre ak
Ajoute prefiks
mode=test.Ajoute prefiks
test_ devan kle API ou pou aktive mòd TEST.Fliks Peman
① Sit ou
→
POST /initiate
→
② order_id + payment_url
→
③ Redirijman
→
④ Kliyan peye
→
⑤ Webhook
① Sit ou rele
② Sit ou sove order_id + reference nan baz done, epi redirijye kliyan an
③ Kliyan an konekte nan PSLWallet, resevwa yon OTP pa imèl epi konfime peman an
④ PSLWallet voye webhook nan webhook_url ou ak order_id + tx_id
⑤ Sit ou resevwa webhook → idantifye kòmand pa order_id → debloke aksè
/payment/initiate → resevwa order_id + payment_url② Sit ou sove order_id + reference nan baz done, epi redirijye kliyan an
③ Kliyan an konekte nan PSLWallet, resevwa yon OTP pa imèl epi konfime peman an
④ PSLWallet voye webhook nan webhook_url ou ak order_id + tx_id
⑤ Sit ou resevwa webhook → idantifye kòmand pa order_id → debloke aksè
Endpoints
GET
/health
Tcheke eta API a — san otantifikasyon
curlcurl https://pslwallet.com/pslwallet/api/v1/health
Repons 200{ "success": true, "status": "ok", "api": "PSLWallet v1", "mode": "live", "db": "connected" }
POST
/payment/initiate
Kreye yon demann peman
Paramèt Body JSON
| Chan | Tip | Estati | Deskripsyon |
|---|---|---|---|
| amount | float | obligatwa | Montan an USD — egz : 25.00 |
| description | string | obligatwa | Deskripsyon peman an |
| customer_email | string | obligatwa | Imèl kliyan PSLWallet |
| order_id | string | opsyonèl | Referans kòmand ou — retounen nan webhook. Si absab, PSLWallet jenere otomatikman. |
| redirect_url | string | opsyonèl | URL retou apre peman |
| webhook_url | string | opsyonèl | Remplace webhook kont patnè ou |
| metadata | object | opsyonèl | Done lib retounen nan webhook — product_id, user_id, elatrye. |
| expires_in | int | opsyonèl | Ekspirasyon an minit — default : 30 |
curlcurl -X POST https://pslwallet.com/pslwallet/api/v1/payment/initiate \ -H "X-API-Key: votre_api_key" \ -H "Content-Type: application/json" \ -d '{ "amount": 25.00, "description": "Commande #1042", "customer_email": "client@email.com", "order_id": "CMD-1042", "redirect_url": "https://monsite.com/confirm", "metadata": { "product_id": "42", "user_id": "789" } }'
Repons 201{ "success": true, "order_id": "CMD-1042", "reference": "PSL-71F9B1C08DA0EA84", "payment_url": "https://pslwallet.com/pslwallet/pay/PSL-71F9B1C08DA0EA84", "amount": 25.00, "currency": "USD", "status": "pending", "mode": "live", "expires_at": "2026-03-16T21:30:00+00:00", "customer": { "name": "Jean Dupont", "can_pay": true, "balance": 100.00 } }
⚠️ Enpòtan : Sove order_id ak reference nan baz done imedyatman apre resevwa repons lan, anvan redirijye kliyan an.
GET
/payment/status
Tcheke estati — pa order_id oswa reference
De fason pou mande — pa order_id (referans ou) oswa pa reference PSLWallet :
Pa order_id — rekòmandecurl "https://pslwallet.com/pslwallet/api/v1/payment/status?order_id=CMD-1042" \ -H "X-API-Key: votre_api_key"
Pa reference PSLWalletcurl "https://pslwallet.com/pslwallet/api/v1/payment/status?ref=PSL-71F9B1C08DA0EA84" \ -H "X-API-Key: votre_api_key"
Estati posib yo
pending
completed
failed
expired
refunded
GET
/payment/verify/{ref}
Verifye pa referans nan URL
curlcurl https://pslwallet.com/pslwallet/api/v1/payment/verify/PSL-71F9B1C08DA0EA84 \ -H "X-API-Key: votre_api_key"
POST
/payment/refund
Ranbouse yon peman completed
| Chan | Tip | Estati | Deskripsyon |
|---|---|---|---|
| order_id | string | oswa reference | order_id ou pase pandan /initiate |
| reference | string | oswa order_id | Referans PSLWallet — PSL-... |
| reason | string | opsyonèl | Rezon ranbousman an |
curlcurl -X POST https://pslwallet.com/pslwallet/api/v1/payment/refund \ -H "X-API-Key: votre_api_key" \ -H "Content-Type: application/json" \ -d '{ "order_id": "CMD-1042", "reason": "Client annulé" }'
GET
/balance?email=...
Tcheke balans USD pa ou
⚠️ Aksè Restrenn : Ou ka wè sèlman balans kont ki asosye ak kle API ou. Nenpòt tantativ tcheke yon lòt imèl retounen
403 FORBIDDEN.curlcurl "https://pslwallet.com/pslwallet/api/v1/balance?email=votre@email.com" \ -H "X-API-Key: votre_api_key"
Repons 200{ "success": true, "has_account": true, "customer_name": "Jean Dupont", "balance": 100.00, "pending_holds": 0.00, "available": 100.00, "currency": "USD", "can_pay": true }
Repons 403{ "success": false, "error": { "code": "FORBIDDEN", "message": "Vous ne pouvez consulter que le solde de votre propre compte." } }
Kòd Erè
Tout erè retounen fòma JSON sa a ak kòd HTTP apwopriye a.
| HTTP | Kòd | Koz ak solisyon |
|---|---|---|
| 401 | UNAUTHORIZED | Header X-API-Key mank oswa kle pa valid |
| 403 | FORBIDDEN | Imèl mande diferan de kont ki lye ak kle API ou — /balance sèlman |
| 404 | NOT_FOUND | order_id oswa reference pa jwenn pou kont patnè sa a |
| 409 | CANNOT_REFUND | Estati pa konpatib — sèlman peman completed ka ranbouse |
| 409 | DUPLICATE_ORDER_ID | order_id sa a deja itilize — itilize yon ID inik pa peman |
| 422 | MISSING_FIELDS | Chan JSON obligatwa mank — verifye amount, description, customer_email |
| 422 | INVALID_AMOUNT | Montan ≤ 0 oswa siperyè a 100 000 USD |
| 422 | INVALID_EMAIL | Fòma imèl pa valid |
| 500 | DB_ERROR | Erè sèvè PSLWallet — eseye ankò apre 30 segonn |
Fòma erè JSON{ "success": false, "error": { "code": "INVALID_AMOUNT", "message": "Montant doit être > 0" } }
Webhook
PSLWallet voye yon POST JSON nan webhook_url ou (konfigire nan kont patnè ou) apre chak evènman peman. Endpoint ou dwe reponn HTTP 200.
Payload — payment.completed
JSON resevwa sou sèvè ou{ "event": "payment.completed", "order_id": "CMD-1042", "reference": "PSL-71F9B1C08DA0EA84", "amount": 25.00, "currency": "USD", "customer": "client@email.com", "customer_name": "Jean Dupont", "description": "Commande #1042", "partner": "Solisyon", "tx_id": 471, "metadata": { "product_id": "42", "user_id": "789" }, "mode": "live", "paid_at": "2026-03-16T21:00:00+00:00" }
⚠️ Toujou verifye ke
mode === "live" anvan valide yon kòmand. Nan mòd tès, logate evènman an san modifye baz done ou.Resevwa webhook — PHP
PHP — webhook/pslwallet.php$payload = json_decode(file_get_contents('php://input'), true); if (!$payload) { http_response_code(400); exit; } if ($payload['event'] === 'payment.completed' && $payload['mode'] === 'live') { $orderId = $payload['order_id']; $txId = $payload['tx_id']; $order = get_order($orderId); if ($order && $order['status'] === 'pending') { mark_order_paid($orderId, $txId); send_confirmation_email($payload['customer'], $orderId); unlock_product_access($orderId); } } http_response_code(200); echo 'OK';
Entegrasyon PHP Konplè
Fichye helper pslgateway.php
PHP — pslgateway.phpdefine('PSL_KEY', getenv('PSL_API_KEY')); define('PSL_URL', 'https://pslwallet.com/pslwallet/api/v1'); function psl($method, $path, $body = []) { $ch = curl_init(PSL_URL . $path); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => $method, CURLOPT_HTTPHEADER => ['X-API-Key: '.PSL_KEY, 'Content-Type: application/json'], CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, ...($body ? [CURLOPT_POSTFIELDS => json_encode($body)] : []), ]); $r = json_decode(curl_exec($ch), true); curl_close($ch); return $r; }
Paj checkout — inisye peman
PHP — checkout.phprequire_once 'pslgateway.php'; $r = psl('POST', '/payment/initiate', [ 'amount' => 25.00, 'description' => 'Commande #1042', 'customer_email' => 'client@email.com', 'order_id' => 'CMD-1042', 'redirect_url' => 'https://monsite.com/confirm', 'metadata' => ['product_id' => '42'], ]); if ($r['success']) { db_query("UPDATE orders SET psl_order_id=?, psl_ref=? WHERE id=?", [$r['order_id'], $r['reference'], '1042']); header('Location: ' . $r['payment_url']); exit; } else { $error = $r['error']['message']; }
Entegrasyon Node.js
JavaScript — pslgateway.js + Expressconst PSL = { key: process.env.PSL_API_KEY, url: 'https://pslwallet.com/pslwallet/api/v1', async req(method, path, body) { const r = await fetch(this.url + path, { method, headers: { 'X-API-Key': this.key, 'Content-Type': 'application/json' }, ...(body ? { body: JSON.stringify(body) } : {}), }); const data = await r.json(); if (!data.success) throw new Error(data.error?.message); return data; }, initiate(amount, desc, email, orderId, meta = {}) { return this.req('POST', '/payment/initiate', { amount, description: desc, customer_email: email, order_id: orderId, redirect_url: `${process.env.APP_URL}/confirm`, metadata: meta, }); }, status(orderId) { return this.req('GET', `/payment/status?order_id=${orderId}`); }, refund(orderId, reason) { return this.req('POST', '/payment/refund', { order_id: orderId, reason }); }, }; // Checkout app.post('/checkout/pslwallet', async (req, res) => { const { orderId, amount, email } = req.body; const payment = await PSL.initiate(amount, `Commande #${orderId}`, email, `CMD-${orderId}`); await Order.update(orderId, { pslOrderId: payment.order_id, pslRef: payment.reference }); res.json({ payment_url: payment.payment_url }); }); // Webhook app.post('/webhook/pslwallet', (req, res) => { const { event, order_id, tx_id, mode } = req.body; if (event === 'payment.completed' && mode === 'live') Order.markPaid(order_id, tx_id); res.json({ ok: true }); });
WooCommerce
📁 📁 Kreye dosye wp-content/plugins/psl-gateway/ epi mete fichye sa ladan. Aktive apre nan Extensions → Méthodes de paiement.
PHP — psl-gateway.php/* * Plugin Name: PSL Gateway * Description: Paiements USD via PSL Wallet * Version: 1.0 */ add_filter('woocommerce_payment_gateways', fn($g) => [...$g, 'WC_PSL_Gateway']); add_action('plugins_loaded', function() { class WC_PSL_Gateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'psl_gateway'; $this->method_title = 'PSL Wallet'; $this->method_description = 'Paiement USD sécurisé via PSL Wallet'; $this->has_fields = false; $this->init_form_fields(); $this->init_settings(); $this->title = $this->get_option('title'); $this->api_key = $this->get_option('api_key'); add_action('woocommerce_update_options_payment_gateways_psl_gateway', [$this, 'process_admin_options']); } public function init_form_fields() { $this->form_fields = [ 'title' => ['title'=>'Titre affiché', 'type'=>'text', 'default'=>'PSL Wallet (USD)'], 'api_key' => ['title'=>'Clé API PSLWallet', 'type'=>'password'], ]; } public function process_payment($wc_order_id) { $order = wc_get_order($wc_order_id); $order_id = 'WC-' . $wc_order_id; $ch = curl_init('https://pslwallet.com/pslwallet/api/v1/payment/initiate'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ['X-API-Key: '.$this->api_key, 'Content-Type: application/json'], CURLOPT_POSTFIELDS => json_encode([ 'amount' => (float)$order->get_total(), 'description' => 'Commande #'.$wc_order_id.' — '.get_bloginfo('name'), 'customer_email' => $order->get_billing_email(), 'order_id' => $order_id, 'redirect_url' => $this->get_return_url($order), 'webhook_url' => home_url('/wp-json/psl/webhook'), 'metadata' => ['wc_order_id' => $wc_order_id], ]), ]); $r = json_decode(curl_exec($ch), true); curl_close($ch); if ($r['success']) { $order->update_meta_data('_psl_order_id', $r['order_id']); $order->update_meta_data('_psl_reference', $r['reference']); $order->save(); return ['result'=>'success', 'redirect'=>$r['payment_url']]; } wc_add_notice($r['error']['message'] ?? 'Erreur PSL Wallet', 'error'); return ['result'=>'failure']; } } }); // Webhook REST WooCommerce add_action('rest_api_init', function() { register_rest_route('psl', '/webhook', [ 'methods' => 'POST', 'permission_callback' => '__return_true', 'callback' => function($req) { $p = $req->get_json_params(); if (($p['mode'] ?? '') !== 'live') return new WP_REST_Response(['ok'=>true]); if ($p['event'] === 'payment.completed') { $wc_id = $p['metadata']['wc_order_id']; $order = wc_get_order($wc_id); if ($order && $order->get_status() === 'pending') { $order->payment_complete($p['tx_id']); $order->add_order_note('Payé via PSL Wallet · order: '.$p['order_id']); } } return new WP_REST_Response(['ok'=>true], 200); }, ]); });