n1coePayDocs

Server SDKs

PHP

n1co/epay, the n1co ePay API from your PHP server.

Server · PHP 8.2+

Runs on your server with PHP 8.2 or later, ext-curl and ext-json. It uses your secret_key, which never leaves your server.

Install

Terminal
composer require n1co/epay
n1co.php
<?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',
]);
Option Values Default
base_url API URL https://api-epay.n1co.com
webhook_secret Your webhook.secret (whsec_…) None
timeout Seconds per attempt 30
max_retries 0 to 10, GET only 2

Methods

Every method takes a last ['timeout' => seconds] argument.

Method What it does Returns
paymentIntents->create($params) Creates a payment intent; its intent_token goes to the page. PaymentIntent
paymentIntents->retrieve($id) Reads an intent, with its intent_token. PaymentIntent
paymentIntents->cancel($id) Cancels a requires_payment_method or requires_action intent. PaymentIntent
cardSessions->create($params) Creates a card session; its session_token goes to the page. With card, it updates that card. CardSessionCreated
cardSessions->retrieve($id) Reads a session; once completed, card is the card's id. CardSession
refunds->create($params) Refunds a succeeded intent in full; waits for n1co at least 90 s. Refund
refunds->retrieve($id) Reads a refund. Refund
webhooks->test() Sends a webhook.test to your webhook_url; up to 10 per minute. Event
webhooks->constructEvent($payload, $headers) Verifies the raw body's signature with your webhook_secret. Event
webhooks->constructEventFromRequest() The same, reading php://input and the headers. Event

Type to search the documentation.