Connect a Sandbox taxpayer
Use this page to connect a Sandbox taxpayer to your organization. Your app uses the same connection flow as in Live. The difference: you act as the business, and Wafeq e-invoicing ASP simulates its onboarding in EmaraTax.
This page uses these terms:
- Sandbox taxpayer: a taxpayer that Wafeq e-invoicing ASP makes in Sandbox. No real business is behind it.
- Grant: the permission that a business gives to your organization. A grant lets your app submit e-invoices in which that business is the seller.
- EmaraTax: the online portal of the FTA. In Live, a business appoints Wafeq e-invoicing ASP in EmaraTax.
- TIN: the 10-digit number that the FTA gives a business.
- VAT TRN: the VAT registration number of a business: 15 digits, ending in
03.
Before you start
Do the setup of your organization in Sandbox: a Sandbox API key, the Sandbox OAuth client with your callback URLs, and a webhook endpoint. Refer to Sandbox.
The four steps
| Step | Who | Action |
|---|---|---|
| 1 | Your app | Redirects you to the Sandbox authorization page. |
| 2 | You, as the business | Simulate the onboarding. |
| 3 | You, as the business | Approve your app. |
| 4 | Your app | Exchanges the code for the Taxpayer ID and the grant ID. |
For the same flow in Live, refer to Connect a taxpayer (stage 2).
Step 1: Redirect to the Sandbox authorization page
Start the connection flow of your app with your Sandbox OAuth client. Use the Sandbox authorization page:
https://einvoicing.wafeq.com/sandbox/oauth/authorizeThe parameters are the same as in Live. Sandbox accepts two more:
tin_hint: the TIN of the Sandbox taxpayer. It has 10 digits and starts with1. Without it, Wafeq e-invoicing ASP selects a random TIN that is not in use, from the TINs that start with1998. If no TIN in that range is free, Wafeq e-invoicing ASP selects a random TIN outside it.vat_registered=false: the business is not registered for VAT. The Sandbox taxpayer then has no VAT TRN, as the FTA verification gives for such a business in Live. Live ignores this parameter.
Step 2: Simulate the onboarding
On the page of Wafeq e-invoicing ASP, select Simulate EmaraTax onboarding. Wafeq e-invoicing ASP makes a Sandbox taxpayer with these details:
- TIN: your
tin_hint, or a random TIN, as in step 1. - VAT TRN: the TIN, followed by
00003. If you sentvat_registered=false, the Sandbox taxpayer has no VAT TRN. - Sign-in email: your email address. The Sandbox taxpayer signs in to its workspace with this address.
Follow the pages of the simulation. They ask for the address of the Sandbox taxpayer, with the emirate.
Wafeq e-invoicing ASP refuses a tin_hint in these cases:
- The TIN is already in use in Sandbox. If you onboarded a Sandbox taxpayer with this TIN, sign in as that taxpayer instead.
- Wafeq e-invoicing ASP reserves the TIN for tests. This includes each TIN that starts with
19992or19993. These TINs are the test buyers.
Step 3: Approve your app
Wafeq e-invoicing ASP shows the approval page, as in Live. Approve your app. Wafeq e-invoicing ASP creates the grant and redirects to your callback URL with the code.
Step 4: Exchange the code
Exchange the code at the Sandbox token endpoint:
https://einvoicing.wafeq.com/sandbox/oauth/tokenThe response gives the Taxpayer ID and the grant ID of the Sandbox taxpayer. Store them. You can also get them later with GET /grants and your Sandbox API key.
Other OAuth calls in Sandbox
These calls use the Wafeq e-invoicing ASP portal, not the API address. They use form-encoded bodies and your Sandbox OAuth client:
| Call | Address |
|---|---|
| Refresh a token, or get a client-credentials token | https://einvoicing.wafeq.com/sandbox/oauth/token |
| Revoke a token | https://einvoicing.wafeq.com/sandbox/oauth/revoke |
To check whether a business is onboarded, send JSON to https://einvoicing.wafeq.com/sandbox/oauth/taxpayer-registration, with HTTP Basic authentication.
Next
Send a document in the Sandbox from the Sandbox taxpayer.
Updated 4 days ago