1. HASH
Sipay API Documentation
EN
  • EN
  • TR
  • Overview
    • Getting Started
    • Test Cards
    • IP Restriction
  • Authentication
    • Token Generation
      POST
  • Installments & Commission
    • Installment Details
      POST
    • Commission
      POST
    • Merchant Installments
      POST
  • HASH
    • Hash Creation
    • Hash Validation
  • Non-3DS Payment
    • Non-3DS Payment Flow
    • Non-3DS Card Payment
      POST
    • Non-3DS Recurring Payment
      POST
    • Non-3DS Insurance Payment
      POST
    • Non-3DS Pre-Authorization Payment
      POST
    • Confirm Payment
      POST
  • 3D Secure Payment
    • 3D Secure Payment Flow
    • 3D Secure Card Payment
      POST
    • 3D Secure Recurring Payment
      POST
    • 3D Secure Pre-Authorization Payment
      POST
    • Complete Payment
      POST
    • Confirm Payment
      POST
    • 3D Secure Agriculture Payment
      POST
  • Non-3DS and 3DS Payment with Sipay
    • Purchase Link Example
    • Non-3DS and 3D Secure Payment with Sipay
      POST
  • DPL
    • DPL
    • Status Codes
    • Options for Creating a DPL
    • Create DPL
    • List Payment Links
    • Payment Link Details
    • Update DPL
    • Remove DPL
  • Check Status
    • Check Status
  • Payment with Saved Card
    • Card Registration
    • 3D Secure Pay by Card Token
    • Non-3DS Pay by Card Token
    • Retrieving Saved Card
    • Edit Saved Card
    • Delete Saved Card
  • Recurring
    • Recurring Query Search
    • Recurring Plan Process
    • Recurring Plan Update
  • Refund
    • Refund
  • Cashout
    • Cashout to Bank
  • Webhook
    • Webhook
  • Status Codes
    • Status Codes
  • Plugin
    • Magento v1
    • Magento v2
    • Opencart
    • Presta
    • Woocommerce
    • Shopify
  • Settings
    • DPL Settings
    • Settings Update
  1. HASH

Hash Validation

Hash v2#

Hash v2 uses HMAC-SHA256 with your merchant app_secret as the key. The hash_key is a 64-character hexadecimal signature. The signed fields travel in the request, response, redirect, or webhook payload. Generate and verify signatures on your server, where you store your app_secret.

Generate a request signature#

1.
Look up the signed fields and their order in the endpoint’s hash_key description.
2.
Join their values with | in that order. Keep an empty position for a signed field that the endpoint allows to be empty. Use | only as the separator.
3.
Encode the message as UTF-8, calculate its HMAC-SHA256 using app_secret, and put the hexadecimal result in the request’s hash_key field.
Sign the values in the exact form you send. For example, 100.00 and 100 produce different signatures. Follow the endpoint’s JSON type. If it accepts a string for the amount, a string can preserve trailing zeros. For Cashout to Bank, format the sum of all row amounts with two decimal places and sign the first row’s other values as sent.

Example request for paySmart2D#

The order is total, installments_number, currency_code, merchant_key, invoice_id. With the example secret example_app_secret, the message is 100|1|TRY|merchant_example|20260001. This excerpt shows the signed request fields and hash_key. The JSON sends total, installments_number, and invoice_id as integers. The code examples pass their text representations to the signing function.
[
  {
    "total": 100,
    "installments_number": 1,
    "currency_code": "TRY",
    "merchant_key": "merchant_example",
    "invoice_id": 20260001,
    "hash_key": "2c7f66fa4f0c16a413af7c639af9971c469a7a1f13ee98b8f010e83182cd9f85"
  }
]

Verify a response, redirect, or webhook signature#

1.
For an expected Hash v2 signature, check that hash_key contains exactly 64 hexadecimal characters.
2.
Parse the response, redirect, or webhook. Use its own values and the field order below. For a 3D redirect, read the return or cancel URL’s query values or the submitted form data.
3.
Join the values with | and compute HMAC-SHA256 using your merchant app_secret. Compare the computed and received signatures with a constant-time comparison.
Preserve the signed text exactly as received, including the amount. Use an empty string for a missing or null field and keep its position. Join any embedded | in a signed free-text response field as received. The code examples take string values in the documented order and accept null for an empty verification field.
MessageFormatSigned fields, in order
2D response / 3D redirect2D: JSON; 3D: query string or POST formpayment_status, total, invoice_id, order_id, currency_code
Sale webhookPOST formstatus, total, invoice_id, order_id, currency_code
Refund webhookPOST formstatus, amount, invoice_id, order_id
Manual refund webhookPOST formstatus, refund_amount, invoice_id, empty value (the message ends with a pipe)
Recurring webhookPOST formstatus, product_price, invoice_id, order_id, currency_code
Chargeback webhookPOST JSONprevious_trx_status, current_trx_status, invoice_id, order_id, amount, currency
Reverse webhookPOST JSONEvery field of the payload except hash_key, in payload order (see the field orders in Webhook)
Sub-merchant PF webhookPOST formmerchant_id, pf_id
Status values: sale webhook status is Completed or Failed; recurring webhook status is Completed or Failed; refund webhook status is Completed, or Refund Rejected when the refund is rejected; 2D/3D payment_status is 1 or 0.
Signed Hash v2 payment responses, redirects, and sale webhooks include total and currency_code. The paySmart2D endpoint response examples use example_app_secret. See Webhook for payloads and transaction-specific reverse field orders.

Example 3D return#

The signed message is 1|100.00|INV-DOCS-001|ORD-DOCS-001|TRY. With example_app_secret, the expected hash_key is 2cbe480fb9d6104c3eacf3cc5a479b04f68d3dee5021e9cf45a48018e375b2b4.

Example sale webhook#

In a sale webhook, total is the stored amount without trailing zeros, for example 100 or 150.5.
The signed message is Completed|100|INV-DOCS-001|ORD-DOCS-001|TRY. With example_app_secret, the signature in this payload excerpt verifies successfully.
{
  "status": "Completed",
  "total": "100",
  "invoice_id": "INV-DOCS-001",
  "order_id": "ORD-DOCS-001",
  "currency_code": "TRY",
  "hash_key": "1eaea6c46ead8f3b2384c9df29f7d438327ee2574f8bf82822695b458822720d"
}

Server-side code examples#

JavaScript (Node.js)
Python
PHP

During migration#

How Sipay recognises the version. Sipay looks at the shape of the hash_key you send. Exactly 64 hexadecimal characters (upper or lower case) is Hash v2; anything else is treated as Hash v1. There is no version field, so you can migrate one endpoint at a time.
A Hash v1 value that cannot be decrypted is already refused with the endpoint's "invalid hash key" error. This includes plain field|field|… text.
What Sipay sends you during the migration
MessageBefore the cutoffAfter the cutoff
2D payment response (paySmart2D, Non-3DS pay by card token)Same version as your request's hash_keyv2
3D Secure return / cancel redirectSame version as your request's hash_keyv2
Signed error response or redirect for a rejected requestSame version as your request's hash_keyv2
Sale webhookSame version as the payment request's hash_keyv2
Refund webhook, manual refund webhookv1v2
Recurring webhookv1v2
Chargeback webhookv1v2
Reverse webhookv1v2
Sub-merchant PF webhookv1v2
Purchase Link (hosted payment page): redirect and sale webhookv1v2
DPL (payment link) checkout: redirect and sale webhookv1v2
Wix paymentsv1v2
Sipay will announce the cutoff date in advance. At the cutoff, Sipay stops accepting Hash v1.
Payments (2D and 3D), pay by card token, refund, check status, confirm payment, complete payment, cashout to bank: status_code 68, "Invalid hash key". For 3D Secure this arrives on your cancel URL.
Save, edit and delete card: status_code 90, "Invalid Hash key".
From the cutoff on, every hash_key Sipay sends is Hash v2.
Recommendations
Until the cutoff, accept both versions in your redirect and webhook handlers, and choose the check by shape: 64 hexadecimal characters → verify as v2, otherwise → verify as v1. Webhooks that do not answer a request of yours (refund, recurring, chargeback, reverse, sub-merchant PF) stay v1 until the cutoff even after you move your requests to v2.
After the cutoff, accept only Hash v2.
v2 responses, redirects and sale webhooks carry the signed total and currency_code. Verify with the values in the message exactly as received; do not reformat amounts (800, 800.5 and 800.00 produce different signatures) and do not take total from your own order record.

Hash v1 validation (legacy)#

In all responses related to payment transactions, the user may be redirected to the merchant’s success or cancel URL. Since these URLs may be publicly accessible, they may be triggered by unauthorized individuals.
Therefore, it is recommended to include parameters such as status, invoice_id, order_id, and hash_key in the redirect URL. The merchant must validate the hash_key value to verify the validity and source of the incoming request.
For recurring payments, a POST request is sent to the merchant’s webhook URL for each renewal transaction. Since webhook URLs may also be publicly accessible, the source of incoming requests must be verified using hash_key.
The status values are as follows:
3D Secure payments: The status parameter can have a value of 0 or 1.
Recurring Webhook: The status parameter is Completed or Failed.
Refund Webhook: The status parameter is Completed or Refund Rejected.
Python
Shell
Go
JavaScript
Java
Swift
C
C#
Ruby
Dart
R
Previous
Hash Creation
Next
Non-3DS Payment
Built with