# Technical Documentation API

Money Transfer Hub provides possibility to process Person-2-Person and Person-2-Merchant transactions in various forms. Please check details in the below documentation.

<p class="callout info">This documentation contains the methods for **mobile-server** integration. The methods included in the documentation are intended for Customers creating their own mobile SDK.</p>

<p class="callout info">The Customer creating the SDK must also remember about the integration with the <span style="text-decoration: underline;">[MobileDC](https://developer.verestro.com/books/user-lifecycle-card-management-api-sdk)</span> component.</p>

## Receiver types which can be used to set Receiver.Type

Based on ReceiverType user can fill different field in Receiver object in requests.

<table id="bkmrk-receivertype-descrip"><colgroup><col style="width: 50%;"></col><col style="width: 50%;"></col></colgroup><tbody><tr class="odd"><td>**ReceiverType**

</td><td>**Description**

</td></tr><tr class="even"><td>BARE\_CARD\_NUMBER

</td><td>Bare card number in **Receiver.card** field

</td></tr><tr class="odd"><td>FRIEND\_ID

</td><td>Should pass FriendId in **Receiver.Card** field

</td></tr><tr class="even"><td>WALLET\_CARD\_ID

</td><td>Should pass DataCoreCardId to **Receiver.Card** field and UserDataCoreCardId to **Receiver.userId** field

</td></tr><tr class="odd"><td>EMPTY

</td><td>Means that the receiver have the same card data like sender. This type may be useful on [Determine Currency](#determine-currency)

</td></tr></tbody></table>

## JWE

Peer To Peer Transaction Service supports encryption of requests and responses as standard JSON Web Encryption (JWE) per RFC 7516.

Recommended to read the JWE standard: [RFC 7516](https://datatracker.ietf.org/doc/html/rfc7516).

Methods that support request encryption in the JWE standard are tagged in the documentation with the header: *Content-Type:application/x-jwe-encryption-body+json*. If the response is to be encrypted with the JWE standard then the header must be added: *X-Encryption-Public-Key* with the public key.

Processing requests and responses can be divided into 4 options listed below:

1. Base request → Base response - the following headers should be provided to pass this case:
    
    
    - *Content-Type: application/json*
2. Base request → Encrypted response - the following headers should be provided to pass this case:
    
    
    - *Content-Type: application/json*
3. Encrypted request → Base response - the following headers should be provided to pass this case:
    
    
    - *Content-Type: application/x-jwe-encryption-body+json*
4. Encrypted request → Encrypted response - the following headers should be provided to pass this case:
    
    
    - *Content-Type: application/x-jwe-encryption-body+json*

### Overview

JWE represents encrypted content using JSON data structures and Base64 encoding. The representation consists of three parts: a JWE Header, a encrypted payload, and a signature. The three parts are serialized to UTF-8 bytes, then encoded using base64url encoding. The JWE’s header, payload, and signature are concatenated with periods (.).

#### JWE typically takes the following form:

```
{Base64 encoded header}.{Base64 encoded payload}.{Base64 encoded signature}
```

#### JWE header contains:

<table id="bkmrk-type-value-constrain" style="width: 100%;"><colgroup><col style="width: 9.02247%;"></col><col style="width: 15.3258%;"></col><col style="width: 10.1802%;"></col><col style="width: 65.3367%;"></col></colgroup><tbody><tr class="odd"><td>**Type**

</td><td>**Value**

</td><td>**Constraints**

</td><td>**Description**

</td></tr><tr class="even"><td>alg

</td><td>RSA-OAEP-256

</td><td>Required

</td><td>Identifies the cryptographic algorithm used to secure the JWE Encrypted Key. Supported algorithms: **RSA-OAEP-256**, **RSA-OAEP-384**, **RSA-OAEP-512**. Recommend value: **RSA-OAEP-256**.

</td></tr><tr class="odd"><td>enc

</td><td>A256GCM

</td><td>Required

</td><td>Identifies the cryptographic algorithm used to secure the payload. Supported algorithms: **A128GCM**, **A192GCM**, **A256GCM**, **A128CBC-HS256**, **A192CBC-HS384**, **A256CBC-HS512**. Recommend value: **A256GCM**.

</td></tr><tr class="even"><td>typ

</td><td>JOSE

</td><td>Optional

</td><td>Identifies the type of encrypted payload. Recommend value: **JOSE**.

</td></tr><tr class="odd"><td>iat

</td><td>1637929226

</td><td>Optional

</td><td>Identifies the time of generation of the JWT token. Supported date format: unix time in UTC. In the case of *iat* send, the validity of JWE is validated. Recommend send the header due to the increase in the security level.

</td></tr><tr class="even"><td>kid

</td><td>5638742a5094327fcd7a5945d06a45a9d83e9006

</td><td>Optional

</td><td>Identifies the public key of use to encrypt payload. Supported format: SHA-1 value of the public key. In the case of *kid* send, the validity of public key is validated, so we can inform the client that the public key has changed.

</td></tr></tbody></table>

### Payload Encryption

Every encrypted request should include JWE token. The jwe token should be passed in the field: *value*.

In case of problems with the implementation of JWE, please contact the administrator.

To prepare the encrypted payload:

The steps may differ depending on the libraries used.

1. Get the public key using the method: \[???\](#Get publicKey). The public key is encoded with Base64.
2. Decode the public key.
3. Then create a correct object to be encrypted.
4. Encrypt the created object with the public key.
5. Create JWE header compatible with: [JWE Header](#JWE_Header)
6. Make a request on the method that supports JWE. Set the JWE token in the field: *value*. Methods supporting JWE use the following header: *Content-Type:application/x-jwe-encryption-body+json*.

### Payload Decryption

To prepare the decrypted payload:

The steps may differ depending on the libraries used.

The cryptographic algorithm used to secure the payload is: **A256GCM**, while to secure the encrypted JWE key: **RSA-OAEP-256**.

1. For the response to be encrypted you need to send *public key* in the header: *X-Encryption-Public-Key*. The header value must be encoded *Base64*.
2. After receiving the response, you should get the JWE token from the field: *value*.
3. Decrypt the JWE token from the field: *value* with the private key.

**Public key format to be encoded in Base64.**

```
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0IDAQAB...
-----END PUBLIC KEY-----
```

# P2P open API

@swagger="https://p2ptransactions.upaidtest.pl/docs/index.yaml"