Invoices

Creating an invoice on amwal.exchange:

To create an invoice, you need to perform a PUT HTTPS request against your project's unique URL with the following JSON format:


Required properties

{ amount: 5, header: 'Invoice header to display on the payment page', } 

Optional props:

{ description: 'Short description', successUrl: 'https://your-website.com/payment-accepted.html', cancelUrl: 'https://your-website.com/payment-canceled.html', } 


To perform the call, you will need 2 variables from us, and API key and a project URL, you can get these from your project settings page.


TS code example:

const getAmwalExchangePaymentPage = (amount: number) => { try { const paymentSesson = await axios.put< IResponse<IAmwalExchangePaymentSession> >( YOUR_PROJECT_ENDPOINT_URL, { amount: 5, header: 'Invoice header to display on the payment page', description: 'Short description', successUrl: 'https://your-website.com/payment-accepted.html', cancelUrl: 'https://your-website.com/payment-canceled.html', }, { headers: { Authorization: `Bearer ${ACCESS_TOKEN}`, }, }, ); return paymentSesson.data.data; } catch (e) { console.error('payment sesion on awmwal.exchange not created', e); } } 


The above PUT request will return the following JSON on success: IResponse<IAmwalExchangePaymentSession>

export interface IAmwalExchangePaymentSession { invoiceId: string; url: string; QR: string; status: number; secret: string; } export interface IResponse<T> { data: T; err: number; } 


Response Example:

{     "data": {         "invoiceId": "65448ddef4924a5dd1b241a9",         "url": "https://amwal.exchange/en/invoice/65448ddef4924a5dd1b241a9",         "QR": "data:image/png;base64,iVBORw0K...MlP8BHih8KXNTDJgAAAAASUVORK5CYII=",         "secret": "0927f7cc-98a7-4b67-a8b5-254fe46227dd",         "status": 1     },     "err": 0 } 


Save the secret:

Make sure you capture the value of the secret and save it. If applicable (in your project's settings) whenever the invoice is fulfilled on amwal.exchange, we will perform a callback against your project's callback endpoint. The payload will contain this secret value which allows you to distinguish between your user baskets and mark them as paid AND start the delivery process. More details about callbacks is provided here.


Redirect the user to the payment page:

Starting from this point, your customer is expected to open the above payment URL (data.url) and make the payment on amwal.exchange's invoice page.


More working examples can be found in your project->docs section.