Signing Payout Instructions

Signature and Expires-at headers

Sign payout requests using the Signature and Expires-at headers.

HeaderDescription
Expires-atInteger UNIX timestamp for signature expiry time in seconds
SignatureBase 64 encoded signature
Key-idOptional identifier for the key, see Key Rotation

You will need a private RSA key as discussed in Payouts RSA Key Registration, and Yaspa will use the public key to verify the signature. The signature is valid until the expiry time set by the merchant in the Expires-at header; this can be no more than 10 minutes from the time the request is sent.

Step 1: Construct the Concatenated String

First, generate a plain-text, pipe-delimited ('|' character) concatenated string from the expiryTime, httpMethod, url, and requestBody as specified below. If the request does not contain a body, omit it from the concatenation while keeping the | at the end as shown in the illustration below.

expiryTime | httpMethod | url | requestBody
expiryTime | httpMethod | url |
ComponentDescription
expiryTimeInteger UNIX timestamp for signature expiry time in seconds, matching the Expires-at header
httpMethodString HTTP method (GET, POST etc) in upper case
urlString URL of the endpoint
requestBodyString representation of the JSON request body if present

An example of the concatenated string is as follows:

1613639354|POST|https://testapi.yaspa.com/v2/corporate-account/admin-counter-party|{"customerIdentifier":"1846593725421829","bankCountry":"GB","accountGiro":"FPS","accountCurrency":"GBP","accountName":"Internal Account","accountNumber":"12345678","bankCode":"010203","counterPartyBank":"OPENPAYD","customerType":"CORPORATE"}

Step 2: Generate the Signature and Expires-at Headers

Use your private key to sign the concatenated string using SHA256withRSA and Base64 encode. The Java example below signs the concatenated string and generates both the Signature and Expires-at headers.

private HttpHeaders generateHeadersForSignedRequest (
     HttpMethod httpMethod, String url, String requestBody, PrivateKey privateKey)
     throws JsonProcessingException, SignatureException {

     String requestExpiryTime = String.valueOf(Instant.now().getEpochSecond() + 300);

     String textToSign = requestExpiryTime + "|" + httpMethod.name().toUpperCase() + "|" + url + "|";

     if (requestBody != null) {
         textToSign += requestBody;
     }

     String signature = generateSignature(textToSign, privateKey);

     HttpHeaders httpHeaders = new HttpHeaders();
     httpHeaders.set("Signature", signature);
     httpHeaders.set("Expires-at", requestExpiryTime);

     return httpHeaders;
}

private String generateSignature(String plainText, PrivateKey privateKey)
    throws SignatureException {

    try {
        Signature signature = Signature.getInstance("SHA256withRSA");
        signature.initSign(privateKey);
        signature.update(plainText.getBytes("UTF8"));
        byte[] valueSigned = signature.sign();

        return Base64.getEncoder().encodeToString(valueSigned);
    } catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) {
        throw new SignatureException(e);
    }
}

Step 3: Add Headers to Request

Add the headers to the request. For the avoidance of doubt, all other required headers including AuthorizationCitizen must also be included.


Did this page help you?