Signatures
The pawaPay API is secured by the API token as explained in Authentication. To add a second layer of security, you can optionally sign your financial requests to us - deposit, payout and refund requests. In this case, pawaPay will only accept financial requests that have been signed by you. To utilize this additional capability, you should provide your public key in the pawaPay Dashboard and enable this feature. Read how to do that from the pawaPay Dashboard Docs. This ensures that even if your API token leaks, only you can initiate financial requests with pawaPay. If configured, pawaPay will also send callbacks to your callback URLs with the final status of your payment. Your network team can whitelist the pawaPay platform IP addresses for these callback URLs. Additionally, you can also enable pawaPay to sign those callbacks. You can then validate the signature that is included in the header of the callback to ensure that callbacks are in fact coming from pawaPay and have not been tampered with.Signatures in financial requests
Financial requests are requests sent to the pawaPay Merchant API to move funds. These include deposits, payouts, bulk payouts and refunds. The implementation of signatures in pawaPay is based on the standard described in RFC-9421. When creating the financial request to send to the pawaPay Merchant API, you should create a Content-Digest, sign the request and add Signature and Signature-Input headers. You can find sample node code for signing your requests from Github.Hash the request body
For generating theContent-Digest
you can use either SHA-256 or SHA-512 algorithm.
The Content-Digest
should be created from the request body.
Having the request body hashed and available as a header allows verification that the content of the request has not been tampered with.
Create the signature base
For creating the content that will be signed, you need to create a signature base. This should include all details of the request that should be verifiable. We recommend including at least the following Derived Components.- @method
- @authority
- @path
- Signature-Date
- Content-Digest
- Content-Type
Create the signature
You can use your private key now to sign the signature base. You can use one of the following algorithms:- RSASSA-PSS Using SHA-512
- RSASSA-PKCS1-v1_5 Using SHA-256
- ECDSA Using Curve P-256 DSS and SHA-256
- ECDSA Using Curve P-384 DSS and SHA-384
Include Signature and Signature-Input headers
Having generated the signature, you should include it into theSignature
header of the request.
You also need to create the Signature-Input
header which outlines the parameters and their order that were used to generate the Signature
as well as metadata about the signature.
The metadata should include:
- The used algorithm (
alg
) - The date the signature was created (
created
) - The expiration date of the keypair (
expires
) - The id of the key (
keyid
)
Do not forget to enable signed financial calls and upload your public key in the pawaPay Dashboard. Learn how to do that from the pawaPay Dashboard Docs.
Make the request
You can now send this request to pawaPay Merchant API to initiate a deposit, payout, bulk payout and refund.Signatures in callbacks
When receiving callbacks from pawaPay they will include the following headers.- Signature
- Signature-Input
- Signature-Date
- Content-Type
- Content-Digest
Validate content integrity
Create a hash of the request body using the algorithm specified in theContent-Digest
header.
Comparing the generated value to the value in Content-Digest
ensures the body of the request has not been tampered with.
Validate the signature
Based on the parameters inSignature-Input
, generate the signature base for the request. You can read more about it here.
Based on the previous example, the signature base would be the following.
Signature-Input
) was in fact signed by pawaPay and therefore originates from pawaPay.
Do not forget to enable signed callbacks in the pawaPay Dashboard. Learn how to do that from the pawaPay Dashboard Docs.