SDKs de servidor
PHP
n1co/epay, el API de n1co ePay desde tu servidor PHP.
Corre en tu servidor con PHP 8.2 o superior, ext-curl y ext-json. Usa tu secret_key, que nunca sale de tu servidor.
Instalar
composer require n1co/epay<?php
use N1co\EPay\N1co;
$n1co = new N1co((string) getenv('N1CO_SECRET_KEY'), [
'webhook_secret' => (string) getenv('N1CO_WEBHOOK_SECRET'),
'base_url' => 'https://api-epay-sandbox.n1co.shophttps://api-epay.n1co.com',
]);| Opción | Valores | Por defecto |
|---|---|---|
base_url |
URL del API | https://api-epay.n1co.com |
webhook_secret |
Tu webhook.secret (whsec_…) |
Ninguno |
timeout |
Segundos por intento | 30 |
max_retries |
De 0 a 10, solo en GET | 2 |
Métodos
Cada método acepta un último argumento ['timeout' => segundos].
| Método | Qué hace | Devuelve |
|---|---|---|
paymentIntents->create($params) |
Crea un payment intent; su intent_token va a la página. |
PaymentIntent |
paymentIntents->retrieve($id) |
Lee un intent, con su intent_token. |
PaymentIntent |
paymentIntents->cancel($id) |
Cancela un intent requires_payment_method o requires_action. |
PaymentIntent |
cardSessions->create($params) |
Crea una sesión de tarjeta; su session_token va a la página. Con card, actualiza esa tarjeta. |
CardSessionCreated |
cardSessions->retrieve($id) |
Lee una sesión; completed trae el id de la tarjeta en card. |
CardSession |
refunds->create($params) |
Reembolsa completo un intent succeeded; espera a n1co al menos 90 s. |
Refund |
refunds->retrieve($id) |
Lee un reembolso. | Refund |
webhooks->test() |
Envía un webhook.test a tu webhook_url; hasta 10 por minuto. |
Event |
webhooks->constructEvent($payload, $headers) |
Verifica la firma del cuerpo crudo con tu webhook_secret. |
Event |
webhooks->constructEventFromRequest() |
Igual, leyendo php://input y los encabezados. |
Event |