Tagih.id

Send Multiple Invoice

Send Multiple Invoice is a service from Tagih.id designed to simplify sending multiple invoices efficiently and centrally. Tagih.id provides the Send Multiple Invoice service to help you send up to 500 invoices in a single request.
Before Integration
Make sure you have received the credentials from the Espay team.
Integration Steps
You can use the following steps to integrate with Tagih.id – Send Multiple Invoice:
1. Generate Signature
Every request you send will be validated by Tagih.id using your generated signature parameter. Learn how to make a Tagih.id | Hash-Based Signature.
2. Data Encryption

Data encryption is converting information into an unreadable format to enhance data security. For every transaction, you must encrypt the parameter values you send, except for rq_uuid, rq_datetime, and sender_id (refer to the request example section).

Below are the encryption requirements used:
openssl_encrypt($plainString, ‘AES-256-CBC’, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
Name Description
Encryption
AES 256
Mode
CBC
Key
32 bytes.

Provided by the Espay team.
IV
16 bytes.

Provided by the Espay team.
Output
Base64

Steps for Data Encryption:

$_key = ’45bfba7eb46a6007d49ca55a3738aae0′;
$_iv = ‘acc6d0f5aa29120a’;
$plainString = “SGWYESSISHOP”;

1. Add padding

In the AES 256 CBC algorithm, data must have a length that is a multiple of 16 bytes.

before padding:

string(12) “SGWYESSISHOP”

after padding:

The string becomes 16 bytes: “SGWYESSISHOP” + 4 null bytes (\0).
The string looks the same visually, but its length changes to 16 bytes due to the addition of 4 null characters (\0).
⚠️ This padding is applied automatically in the code using a padding function.

2. Data encryption

Encrypt the data using the following encryption format:
openssl_encrypt($plainString, ‘AES-256-CBC’, $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);

3. Encode the Encrypted Result Using Base64

The encrypted plain string is then encoded using Base64.
7ehJDLKEnDvhoTaI0Ao3Fg==
3. Payment Notification

You are required to provide a callback so that Espay can access it. Learn more about Tagih.id | Payment Notification.

4. Create Multiple Invoice

Flow

You send the required parameters to make a request, and Tagih.id will respond in JSON format.

API URL

Environment URL
Sandbox
Port of HTTPS (443)
https://sandbox-api.espay.id/rest/lesscash/sendinvoicemulti
Production
Port of HTTPS (443)
https://api.espay.id/rest/lesscash/sendinvoicemulti

HTTP Headers

Key Value
Method
POST
HTTP Version
HTTP/1.1
Accept
*/*
Content-Type
application/x-www-form-urlencoded
Content-Length
<dynamic>

Request Parameter

Parameter Type Mandatory Description
rq_uuid
String (64)
Y
Request identifier. A unique ID used to identify messages

Format:
UUID V.4 Recommendation
rq_datetime
String
Y
Date and time of the transaction request.

Format:
Y-m-d H:i:s

Example:
2024-03-14 07:49:28
signature
String
Y
Code used to validate transactions. Learn how to make a Tagih.id | Hash-Based Signature.
sender_id
String (32)
Y
Merchant ID provided by the Espay team.
comm_code
String (32)
Y
Merchant region code.

Example:
INDOREGION1
ccy
String (3)
Y
Transaction currency code.

Format:
  • Rupiah: IDR
invoices
JSON
Y
Invoice details.
   doc_no
String (32)
Y
Invoice number.

Format:
site code_shift number_fuel/non fuel

Example:
1221-31013.SH_2107_00099.N
  member_code
String (32)
Y
Member code.
  member_name
String (100)
Y
Member name.
  member_email
String (100)
Y
Member email.
  comm_code
String (32)
Y
Member region code.
   amount
String (13)
Y
Total invoice amount.

Example:
200000
  due_date
Datetime
Y
Due date of payment.

Format:
YYYY-MM-DD

Example:
2024-12-16
  issue_date
Datetime
Y
Invoice issue date.

Format:
YYYY-MM-DD

Example:
2024-12-16
total_invoices
String (3)
Y
Total invoices sent. The maximum submission is 500 invoices in JSON format.

Example:
500
Y: Yes, O: Optional, C: Conditional

Response Parameter

Parameter Type Mandatory Description
rq_uuid
String (64)
Y
Request identifier. A unique ID used to identify messages

Format:
UUID V.4 Recommendation
rs_datetime
String
Y
Date and time of the transaction response.

Format:
yyyy-MM-dd hh:mi:ss

Format:
2024-03-14 07:49:28
error_code
String (4)
Y
Response code.

Format:
  • Success: 0000
  • Failure: XXXX
error_message
String
Y
Response description.
invoices
JSON
Y
invoices_success
JSON
Y
Invoice success.
invoices_failed
JSON
Y
Invoice failed.
total_success
String
Y
Total successful invoices.

Example:
15
total_failed
String
Y
Total failed invoices.

Example:
20
total_row_execute
String
Y
Total processed invoices.

Example:
35
Y: Yes, O: Optional, C: Conditional




















Encryption - PHP

// Encryption function
function encryptData($data, $key, $iv) {
    $paddedData = padZero($data); // Pastikan data dipadding
    return openssl_encrypt($paddedData, 'AES-256-CBC', $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv);
}

// Decryption function
function decryptData($encryptedData, $key, $iv) {
    $decodedData = base64_decode($encryptedData);
    return rtrim(openssl_decrypt($decodedData, 'AES-256-CBC', $key, OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING, $iv), "\0");
}

// Utility for padding
function padZero($data) {
    $len = 16;
    $padLength = $len - (strlen($data) % $len);
    return $data . str_repeat("\0", $padLength);
}
             

















































































Sample Request - Before Encryption

POST /rest/lesscash/sendinvoicemulti HTTP/1.1
Host: sandbox-api.espay.id
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Accept: */*


rq_uuid=80784df2-accb-46fc-92f4-8d3103b38408&
rq_datetime=2025-01-21 11:30:08&
signature=f3ceda666e03630789f1bb3fd2db7a6e9910ea998ae8f2c24e71a74d9f28fdd2&
sender_id=SGWYESSISHOP&
comm_code=SGWYESSISHOP&
ccy=IDR&
invoices={
    "1221-31013.SH_2107_00099.F": {
        "member_code": "1221-31013",
        "member_name": "Tambiluk Serang",
        "member_email": "[email protected]",
        "comm_code": "INDOREGION1",
        "reference_number": "F",
        "amount": 20000,
        "due_date": "2018-03-22",
        "issue_date": "2018-03-22"
    },
    "1221-31013.SH_2107_00099.N": {
        "member_code": "1221-31013",
        "member_name": "Tambiluk Serang",
        "member_email": "[email protected]",
        "comm_code": "INDOREGION1",
        "reference_number": "N",
        "amount": 150000,
        "due_date": "2018-03-22",
        "issue_date": "2018-03-22"
    }
}&
total_invoices=2

             


Sample Request - After Encryption

POST /rest/lesscash/sendinvoicemulti HTTP/1.1
Host: sandbox-api.espay.id
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Accept: */*


rq_uuid=80784df2-accb-46fc-92f4-8d3103b38408&
rq_datetime=2025-01-21 11:30:08&
signature=8729c1f717a84acb2cba8cef24e1d2c87af203e168b0d2febf0eab810396e322&
sender_id=SGWYESSISHOP&
comm_code=7ehJDLKEnDvhoTaI0Ao3Fg==&
ccy=XAgDOyFSyCxclKSInvWVcw==&
invoices=vRE8jWjMGB1SE0Etm/w6LtLesQ4lVJb4aMne8rpos/4GSxdx2sSVEeRny/JmrEzbWLSwZZD6EMn0GtSzvNhWvDjLhMzxaQRvhKpWLF1SdZwLJWycLPYwlXyZkh6mLRWP68VsYZRWFeh6lrvHvFlDHttI47hvEaW1QEAjr1CrWJ+3fMEx3czgSbqEtdJ30qDvhX6h5LmRaDFQhwGH9fcsbmcRqZfJMOOGvvDFRpf6B9yW2yANVDtnIBHRu70iOkGKjXSOFRtdrkhU0xQC20Pv51N8lOIZ14qtxARHHbdlLCOmwCVeIXk1r/JDOw/ltXMvpuJqPiHdeQijDqqn2we3EeDIEpo1EKB+fePxTFQSlg0K4yXlW6rfWW0a+1ZsWchJn4INVi5OFLUS0ijFmNHWae0JjVT1u8MJXCzQZcoN+RZY3kE70j9MyZMx5wqYswikoj+ZzM2yE3TZ3P7IDLClOwqRQn3GsM1rgzqs41uaoeGrwNyshyR8tVZRjM7Rc59xyDmW03GYy0kGaiX9dOQXIHod2mcfJdcFJDhK7MX25nJMprvyt3PG5Z8PdTFObOJvMKAKHPMl1I+cJ5yKXbaht5rtBBmqcokGRtkbUYUDQPc=&
total_invoices=I3QGPJlhxrj9P2wjsQw/Bw==
             
































Sample Respons

{
    "rq_uuid": "ebf8e9df-639e-424f-8148-94d2741edd03",
    "rs_datetime": "2020-10-01T22:55:14+07:00",
    "error_code": "0000",
    "error_message": "Success",
    "invoices": "",
    "invoices_success": "{
        "1221-31013.SH_2107_00099.N": {
            "error_code": "0000",
            "error_msg": "success",
            "doc_ref_no": "DDOC16282856452UMEM"
        },
        "1221-31013.SH_2107_00099.F": {
            "error_code": "0000",
            "error_msg": "success",
            "doc_ref_no": "DDOC1628285646EMB0M"
        }
    }
    ",
    "invoices_failed": "{
        "20210004048524": {
            "error_code": "0014",
            "error_msg": "invalid issue date",
        },
        "20210004048525": {
            "error_code": "0030",
            "error_msg": "invalid amount",
        }
    }",
    "total_success": "10",
    "total_failed": "4",
    "total_row_execute": "50"
}
              




CURL

....

           





Scroll to Top