An invoice is a document you send to your client after purchasing goods or services from you, recording the sale, and requesting payment from them. You can catch everything you need about PayTabs invoices in our what PayTabs Invoices is? solutions article.
In this article, we will walk you through the ways to send PayTabs invoices to your customers via SMS. You should know that PayTabs provides two ways of sending invoices via SMS, the first way is through the SMS endpoint and the second way is thorough the invoice object itself. Find below a details clarification for both.
Through out the article we will use the configuration options clarified in the previous step "Transaction API Main Configurations" and the invoice payment workflow clarified in the first step.
In this article, you will be going to know about:
While Creating The Invoice
The second way that PayTabs offers you to send your customers is within the invoice's initial request. Here you will be using the "notification" object clarified in our Request Parameters | invoice (invoice) solution article to provide the customers' phone numbers whom you want to send this invoice once it is created.
The Minimum Required Parameters
Here, you will be using the normal invoice request as clarified in our initiating/Creating the Invoice Payment Request solution article and along with it you will be adding the "notification" object and providing the phone numbers to the customers that you want the invoice to be sent to them once it is created.
To initiate a payment request using this integration type, there are minimum required parameters that need to be passed with valid information. The specification of these required parameters is clarified below:
Sample Request Payload
The below sample request payload will show you how you can pass the above-mentioned parameters, which are needed to be passed with valid values to perform a request.
{ "profile_id": {{profile_id}}, "tran_type": "sale", "tran_class": "ecom", "tokenise": 2, "cart_currency": {{Cart_currency}}, "cart_amount": "9.5", "cart_id": "cart_12345_2", "cart_description": "Test Description", "hide_shipping": true, "customer_ref":"CUST0101", "invoice": { "shipping_charges": 0, "extra_charges": 0, "extra_discount": 0, "total": 0, "expiry_date": "2023-10-27T13:33:00+04:00", "due_date": "2023-10-26T12:36:00+04:00", "notifications":{ "phone_numbers":["+201111111211"] }, "line_items": [ { "sku": "sku", "description": "desc", "url": "https://www.costacoffee.ae/whats-new/flat-white", "unit_cost": 9.5, "quantity": 1, "net_total": 9.5, "discount_rate": 0, "discount_amount": 0, "tax_rate": 0, "tax_total": 0, "total": 9.5 } ] }
Sample Response Payload
{ "bulk_sms": [ { "numberRequested": "+201111111211", "sentTo": "+20 111 111 1211" } ], "invoice_id": 2775467, "invoice_link": "https://secure-egypt.paytabs.com/payment/request/invoice/2775467/2AA5542E8E7041E7A5FA40D941FF24F5" }
Via The SMS Endpoint
PayTabs offers you an API endpoint that you can use to send your previously created invoices via SMS messages to your customers. Here, you will be using the invoice ID along with your profile id and the customer phone number in the request in order to send the created invoice to this customer as clarified below.
The Endpoint and Related Postman Collection
In this tutorial, we will rely on the PayTabs invoices API Endpoint, mentioned on the PayTabs API endpoints postman collection, which you can access from here. The endpoint will need to be accessed with a POST request on the below-mentioned URL
Post | {{domain}}/payment/payment/invoice/{{invoice_id}}/sms |
Please note that not using the proper endpoint URI {{domain}} will lead to authentication issues within your responses. To find the your proper domain you can read our What Is My (Region)/(endpoint URL)? solution article.
The Minimum Required Parameters
Here you will find the API request that you can use to send your invoices via SMS messages to your customers. From the postman collection, and after applying the endpoint in your code, add the invoice_id that you want to send inside your endpoint URL params, as shown in the below sample:
curl --location -g --request POST 'https://secure-egypt.paytabs.com/payment/invoice/{{invoice_id}}/sms' \ --header 'authorization: SBJNZBM2GJ-J26LHBRWLH-6TMNHNL9WM' \ --header 'Content-Type: application/json' \
To initiate a payment request using this integration type, there are minimum required parameters that need to be passed with valid information. The specification of these required parameters is clarified below:
Parameter | Data Type | Min | Max | Required | Purpose |
INT | Accept only valid profile number | ✔ | The merchant Profile ID you can get from your PayTavs dashboard. For more information please check our How to get your account information from PT2 Dashboard? solution article. To know more about this parameter please click here. | ||
STRING | Valid phone number | ✔ | Indicates the customer's valid phone number To know more about this parameter please click here. |
Sample Request Payload
The below sample request payload will show you how you can pass the above-mentioned parameters, which are needed to be passed with valid values to perform a request.
{ "profile_id":{{profile_id}}, "customer_details" : { "phone":"01550091596" } }
Sample Response Payload
{ "message": "Invoice No. 2080263 sent to phone: +20 15 50091596" }
⌂ To get familiar with the whole process and the other steps, kindly navigate to our "The PT2 API Endpoints Integration Manual" solution article.
⇦ And to get familiar with the rest of the steps regarding the previous step "Step 2 - Configure the integration method" kindly click here.
⇦ And to get familiar with the rest of the steps regarding the current step "Step 3 - Initiating the payment" click here.
⇨ And to navigate to the next step in the integration process "Step 4 - Accepting the payment" kindly click here.