Create a Wallet: Flow Example

An example of a Wallet creation flow is described in this section.

General Flow

The described flow is an example on the APIs that should be used to create a digital wallet for a customer.

  1. Get a token that have the privileges to create entities, wallet and payment methods.
  2. Create the entity with the customer information. In this step you can also create the users if you are going to authenticate the customer with Inswitch's identity manager.
  3. Create an alias for the entity, this step it is optional. You can use it to get information about the customer without need of using the entityReference. Sometimes the document number, document type and issuer country can be used as alias.
  4. Create the Wallet for the created entity.
  5. Create the payment method, in this case the class will be emoney.

API Flow

Auth-Service API

curl --location --request POST 'https://{{baseUrl}}/auth-service/1.0/protocol/openid-connect/token' \
--header 'apikey: {{apikey}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=password' \
--data-urlencode 'username={{username}}' \
--data-urlencode 'password={{password}}'
{
    "access_token": "{{access_token}}",
    "expires_in": 300,
    "refresh_expires_in": 1800,
    "refresh_token": "{{refresh_token}}",
    "token_type": "Bearer",
    "not-before-policy": 0,
    "session_state": "{{session_state}}",
    "scope": "profile email"
}

Entity API

curl --location 'https://{{baseUrl}}/entities/1.2/entities' \
--header 'X-User-Bearer: Bearer {{acces_token}}'\
--header 'apikey: {{apices}}' \
--data-raw '{
  "name": {
    "firstName": "John",
    "lastName": "Doe",
    "fullName": "John Doe"
  },
  "contact": {
    "phoneNumber": "+59811111111",
    "email": "[email protected]",
    "postalAddress": {
      "addressLine1": "Jose Ellauri",
      "addressLine2": "Esq. 21 de Setiembre",
      "city": "Montevideo",
      "stateProvince": "Montevideo",
      "postalCode": "11300",
      "country": "UY"
    }
  } ,
  "idDocuments": [
    {
      "idType": "nationalId",
      "idNumber": "11111111",
      "issueDate": "2023-04-18",
      "expiryDate": "2033-04-18",
      "issuerCountry": "UY"
    }
  ],
  "dateOfBirth": "1980-02-22",
  "birthCountry": "UY",
  "nationality": "UY",
  "residenceCountry": "AD",
  "gender": "m",
  "entityType": "naturalPerson"
}'
{
    "entityId": "2210",
    "creationDate": "2023-04-18T19:06:55.267Z",
    "lastLoginDate": null,
    "users": [],
    "name": {
        "title": null,
        "firstName": "John",
        "middleName": null,
        "lastName": "Doe",
        "secondlastName": null,
        "fullName": "John Doe",
        "nativeName": null
    },
    "contact": {
        "phoneNumber": "+59811111111",
        "email": "[email protected]",
        "firstName": null,
        "lastName": null,
        "postalAddress": {
            "addressLine1": "Jose Ellauri",
            "addressLine2": "Esq. 21 de Setiembre",
            "addressLine3": null,
            "city": "Montevideo",
            "stateProvince": "Montevideo",
            "postalCode": "11300",
            "country": "UY",
            "canton": null
        }
    },
    "beneficiaries": [],
    "idDocuments": [
        {
            "idType": "nationalId",
            "idNumber": "11111111",
            "issueDate": "2023-04-18",
            "expiryDate": "2033-04-18",
            "issuer": null,
            "issuerPlace": null,
            "issuerCountry": "UY",
            "otherDescription": null
        }
    ],
    "dateOfBirth": "1980-02-22",
    "birthCountry": "UY",
    "nationality": "UY",
    "residenceCountry": "AD",
    "occupation": null,
    "gender": "m",
    "entityProfileData": [],
    "metadata": [],
    "entityType": "naturalPerson",
    "r_version": 1,
    "parentId": null,
    "entityStatus": "active",
    "entitySubStatus": "CREATED",
    "entitySubStatusDescription": "Entity was just created",
    "lockReason": null,
    "channel": null
}

Take into account that not all the information is required, see the api definition for more information about which fields are mandatory.

Entity Alias API

curl --location --request PUT 'https://{{baseUrl}}/entities/1.2/entities/2210/alias' \
--header 'X-User-Bearer: Bearer {{access_token}}' \
--header 'apikey: {{api_key}}' \
--data-raw '{
  "keys": [
    "documentType@nationalId$documentNumber@11111111$issuerCountry@UY"
  ]
}'

Wallet API

curl --location --request POST 'https://{{baseUrl}}/wallets/1.0/wallets' \
--header 'X-User-Bearer: Bearer {{access_token}}' \
--header 'apikey: {{api_key}}' \
--data-raw '{
  "entityId": "2210",
  "walletStatus": "active" 
}'
{
    "entityId": "2210",
    "isBatch": false,
    "lockReason": "",
    "metadata": [],
    "walletId": "1128",
    "walletStatus": "active"
}

Wallet Payment Methods API

curl --location --request PUT 'https://{{baseUrl}}//wallets/1.0/wallets/1128/paymentmethods' \
--header 'X-User-Bearer: Bearer {{access_token}}' \
--header 'apikey: {{api_key}}' \
--data-raw '{
  {
    "paymentMethodAlias": "USD",
    "paymentMethodType": "emoney-usd"
}'
{
    "inactiveReason": "",
    "paymentMethodAlias": "USD",
    "paymentMethodData": {
        "ACCOUNT_ID": "1000854"
    },
    "paymentMethodId": "3635383934372D313132382D33303831",
    "paymentMethodLinkData": [],
    "paymentMethodMetadata": [],
    "paymentMethodStatus": "active",
    "paymentMethodType": "emoney-usd",
    "paymentMethodTypeClass": "emoney",
    "paymentMethodTypeCountry": null,
    "paymentMethodTypeCurrency": "USD",
    "paymentMethodTypeDesc": "eMoney USD",
    "paymentMethodTypeDirection": null,
    "paymentMethodTypeImageUrl": null,
    "paymentMethodTypeStatus": "available",
    "paymentMethodTypeUsage": null,
    "walletId": "1128"
}