# 1 - Créer le lien de paiement

### **Étape 1 : Créer un lien de paiement**

Une URL unique qui redirige vos clients vers une page de paiement sécurisée.

Le lien de paiement est une URL qui affiche la page de paiement en ligne. L’URL de base à invoquer pour initier le paiement dépend de l’environnement utilisé.\
Voici un exemple de structure d’URL permettant à votre client de démarrer un paiement :

### **Structure de l’URL :**

```
https://pay.centralbill.app/?applicationId=<applicationId>&invoice[id]=1&invoice[customerId]=<customerId>&invoice[totalAmount][amount]=100&invoice[totalAmount][currency]=XOF&invoice[issuedAt]=<issuedAt>&invoice[dueDate]=<dueDate>&invoice[expiresAt]=<expiresAt>&description=<description>&signature=<signature>&callbackUrl=<callbackUrl>&redirectUrl=<redirectUrl>
```

### **Required Fields**:

<table data-header-hidden data-full-width="false"><thead><tr><th width="196.20001220703125"></th><th width="88.2000732421875"></th><th></th></tr></thead><tbody><tr><td>Field Name</td><td>Type</td><td>Description</td></tr><tr><td><code>applicationId</code></td><td>String</td><td>The merchant application identifier.</td></tr><tr><td><code>invoice[id]</code></td><td>String</td><td>The unique identifier for the invoice.</td></tr><tr><td><code>invoice[customerId]</code></td><td>String</td><td>The customer identifier (email recommended).</td></tr><tr><td><code>invoice[totalAmount]</code></td><td>Float</td><td>Total amount for the invoice.</td></tr><tr><td><code>invoice[totalAmount]</code></td><td>String</td><td>Currency (ISO 4217 format, e.g., XOF).</td></tr><tr><td><code>invoice[issuedAt]</code></td><td>String</td><td>Invoice issue date (ISO 8601 format).</td></tr><tr><td><code>invoice[dueDate]</code></td><td>String</td><td>Invoice due date (ISO 8601 format).</td></tr><tr><td><code>invoice[expiresAt]</code>] (Optional)</td><td>String</td><td>The date when the invoice will expire (ISO 8601 format)</td></tr><tr><td><code>description</code></td><td>String</td><td>A description for the payment.</td></tr><tr><td><code>signature</code></td><td>String</td><td>Signature generated from the data.</td></tr><tr><td><code>callbackUrl</code> (optional)</td><td>String</td><td>URL for receiving IPN notifications.</td></tr><tr><td><code>redirectUrl</code> (optional)</td><td>String</td><td>URL for customer redirection after payment.</td></tr></tbody></table>

### **Example Payment Link**:

```
https://pay.centralbill.app/?applicationId=fbab3ccc-719e-11ed-93ad-02420a0003c1&invoice%5Bid%5D=1&invoice%5BcustomerId%5D=johndoe%40example.com&invoice%5BtotalAmount%5D%5Bamount%5D=100&invoice%5BtotalAmount%5D%5Bcurrency%5D=XOF&invoice%5BissuedAt%5D=2022-12-12T00%3A00%3A00%2B00%3A00&invoice%5BdueDate%5D=1970-01-01T00%3A00%3A00%2B00%3A00&invoice%5BexpiresAt%5D=2023-12-12T00%3A00%3A00%2B00%3A00&description=ACME+-+Facture+%23107285&signature=9407f193b8a53f68e6184ef28cffc7a7524cff81d6e6dd76a4c624b990a3e1cf&callbackUrl=https%3A%2F%2Facme.net%2Fmodules%2Fgateways%2Fcallback%2Fcentralbill.php&redirectUrl=https%3A%2F%2Facme.net%2Fviewinvoice.php%3Fid%3D1
```

### **Generate a Signature (PHP):**

To generate a payment signature you must combine the following payment informations : `application.id`,`invoice.id` , `invoice.customerid`, `invoice.totalAmount.amount`, `invoice.totalAmount.currency`and`application.secret`.\
The identifier and secret of the application can be retrieved from your administration console.

```json
$applicationId = 'fbab3ccc-719e-11ed-93ad-02420a0003c1';
$applicationSecret = app!secret';
$invoiceId = '1';
$invoiceCustomerId = 'johndoe@example.com';
$invoiceTotalAmountAmount = 1000;
$invoiceTotalAmountCurrency = 'XOF';

$signature = hash('sha256', sprintf('%s,%s,%s,%s,%s,%s',
    $applicationId,  
    $invoiceId,  
    $invoiceCustomerId,  
    $invoiceTotalAmountAmount,  
    $invoiceTotalAmountCurrency,  
    $applicationSecret
));

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.centralbill.app/centralbill-payment-api/1-creer-le-lien-de-paiement.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
