These docs are for v2.5. Click to read the latest docs for v3.0.

Completing The Payment

Consenting To The Payment

Now you have the authorisation URL sorted. Its time to pass over control to your user.

When given this new URL the user must visit the site and will be taken through a few main steps:

  1. Choosing their bank (if you did not provide a specific bank id in the request)
  2. Consenting to the action being taken - Their bank will inform and request their consent to proceed
  3. Authenticating with their bank - Logging into their bank and providing further access to the requested resources

You can try this yourself, visit the new link you have made and try to connect with our Moneyhub Open Banking Mock.

Exchanging The Code

If all is well, and the user has given consent and successfully authenticated themselves the bank and Moneyhub will redirect back to your given redirect URI. Upon this redirect a code will be given in a query parameter.

Finalising The Payment

To seal the deal with this payment you must now exchange this code for your access and id tokens.

You are now going to make a new request to the identity server (https://identity.moneyhub.co.uk) and
POST /oidc/request

curl --location --request POST 'https://identity.moneyhub.co.uk/oidc/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code={Your code returned from the redirect}' \
--data-urlencode 'redirect_uri={The redirect uri used in the auth url}' \
--data-urlencode 'client_assertion={Your JWT}' \
--data-urlencode 'client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer' \

🚧

New JWTs

Each time you make a new request to the /token endpoint, you will need a fresh JWT with unique jti. You will get errors back if you try to use the same JWT twice.

Once successfully posted, you should receive a token set that looks like this:

{
  access_token: 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlRxVk1laV9XdUtqZW5HWlJUbnJpeUxXRnZuS2tzTjNvLWFuWXBqS0JEbVUifQ.eyJqdGkiOiJLYkFwQVo1UDk5R2RfckdTQXl6bDMiLCJzdWIiOiI2MDUzN2IwNzRjNGI2ZmRmMTIwMjQ2NTgiLCJpc3MiOiJodHRwczovL2lkZW50aXR5Lm1vbmV5aHViLmNvLnVrL29pZGMiLCJpYXQiOjE2MTYwODM3NDMsImV4cCI6MTYxNjA5MDk0Mywic2NvcGUiOiJpZDoxZmZlNzA0ZDM5NjI5YTkyOWM4ZTI5M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xMjMtYWVmZi04YzcwZTczMDJmMzIiLCJhdWQiOiIxZTFiMjU1Ni02ZTI5LTQyNmMtOWE1Mi04Y2Q1YjkwMTljNzIiLCJleHAiOjE2MTYwODczNDYsImlhdCI6MTYxNjA4Mzc0NiwiaXNzIjoiaHR0cHM6Ly9pZGVudGl0eS5tb25leWh1Yi5jby51ay9vaWRjIn0.Upy5ThfFepYYldLL_RVBFMKjBoIWnUfZM6INF2v7572gH3B4fWBuTfQGvWHuf1NJ9szmiNN1_g09b_XI9lSCPzIXnrS-jeEgiMuCbiZISxxbRgS0Swg2XFay2LlgcWTijRBcq2r9o0KpacoXtxU2OSjJY6Q2ahF8H6HRwQHL0-zZAIj_XL8iMvgmXDwIjifSXj9wCxljS1R_3rRr1IYLIxvoSKK9NhJet4PHv-ICbApR5tFjN7ulVjR6V1rEkQDAvj9WmZFL3L2BMKEV9ZvhU773bHATNJ-ehebWr5qXzDxRsGgB4MeWc-Fy0cz4DqiiHwhNTr3sBdD1Pge0gIDv-w',
  scope: 'id:1ffe704d39629a929c8e293880fb449a openid',
  token_type: 'Bearer'
}

You have now successfully made a payment, in order to check that this payment was successful, you will need to query the status.

Verifying Payment Status

To query the status of a payment, you first need the paymentId and you can obtain this from the id_token that was returned to us in the last step. If you decode this token you should see a claim with the key mh:payment. This is the payment id you need to make the next request.

Lets make a request to our identity service at GET /payments/{paymentId} you can use the access_token that you retrieved from the code exchange as our auth bearer token.

curl --location --request GET 'https://identity.moneyhub.co.uk/oidc/payments/{paymentId}' \
--header 'Authorization: Bearer {access_token}'

This should then return to us the payment you have just made along with all the details. You are looking for status

📘

Payment Status

There are lots of status' payments can be in. This endpoint and its documentation can be found here: Payment Status. Depending on how long a payment takes to complete, you may need to poll this data for a resolution.


What’s Next

Thats it! You have made a payment and checked its status. You can go back to the other use cases, or dive into our wider documentation.