# Payments
source: https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/index.md

A payment can be started with the majority of banks in [supported markets](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/production/supported-providers/index.md).

Our payments product enables you or your customers to receive payments from a consumer (for example, accept a payment made directly from a bank account in a webshop). Refer to the [Payments Initiation](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/payment-initiation/index.md) guide for information on how to receive payments.

It is easy to get started making payments with our API. Details on how to make your first payment in four simple steps are shown below.

## Getting started {#getting-started}

A test payment can be set up in one of our test banks. It only requires you to sign up to our Developer Portal and start making http requests.

#### 1. Sign up to our Developer Portal and create an app {#1-sign-up-to-our-developer-portal-and-create-an-app}

Go to [the developer portal](https://devportal.openbanking.mastercard.com) and click on the sign-up tab. Once you are signed up, navigate to the app's page and create an app using your own license.

The client ID and client secret is located on the details page of the app. They are marked in the screenshot below:
![](https://static.developer.mastercard.com/content/open-finance-europe/uploads/client-id-client-secret.png)

#### 2. Request your first payment {#2-request-your-first-payment}

You can begin your first payment when you have your client ID and client secret. There are two ways to create a payment with the Enterprise API: "Create payment" and "Create session payment".

* Create Payment: This method is ideal for one-time payments, such as a checkout scenario, providing a quick and reliable user experience.
* Create Session Payment: This method is suitable when an AIS consent is also present or when there is an ongoing relationship with the payer, such as account top-ups. Use this when you expect to make multiple payments per user or when AIS consent facilitates user onboarding.

To understand all details of creating a payment request refer to the [payment request](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/payments/requesting-payments/index.md) section.

##### Payments {#payments}

The payment you are about to make will guide the Payer through a payment flow, where the bank and account is chosen. Insert your client ID and client secret in the snippet below and copy it into your terminal:

API Reference: `POST /v1/payments/create`

```shell
curl -X POST \
  https://api.nordicapigateway.com/v1/payments/create \
  -H 'Content-Type: application/json' \
  -H 'X-Client-Id: <CLIENT_ID>' \
  -H 'X-Client-Secret: <CLIENT_SECRET>' \
  -d '{
        "redirectUrl": "https://yourredirecturl.com",
        "language": "en",
        "userHash": "test-user-hash",
        "request": {
            "paymentMethod": {
                "type": "Domestic",
            },
            "message": "This is the text that appears to the receiver",
            "transactionText": "This is the text that will appear in the payers own bank",
            "destination": {
                "name": "Payment Receiverson",
                "iban": {
                    "ibanNumber": "FI9520000123456789"
                }
            },
            "amount": {
                "value": 1.00,
                "currency": "EUR"
            },
            "execution": {
                "type": "Instant",
            }
        }
      }'
```

##### Session Payments {#session-payments}

The payment you are about to make will guide the Payer through a session payment flow, where the bank and account to pay from is pre-selected during the Connect login flow. Therefore, in order to use session payments, you will need to have established a session (AIS Consent).

You can visit the [Login flows](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/connect/login-flows/index.md) to learn more about these flows.

Insert your client ID, client secret, access token (from a Login Flow) and a source account Id in the snippet below and copy it into your terminal:

API Reference: `POST /v1/payments/create/session`

```shell
curl -X POST \
  https://api.nordicapigateway.com/v1/payments/create \
  -H 'Content-Type: application/json' \
  -H 'X-Client-Id: <CLIENT_ID>' \
  -H 'X-Client-Secret: <CLIENT_SECRET>' \
  -H 'Authorization: <ACCESS_TOKEN>' \

  -d '{
        "redirectUrl": "https://yourredirecturl.com",
        "language": "en",
        "userHash": "test-user-hash",
        "request": {
            "sourceAccountId": "<ACCOUNT_ID>",
            "paymentMethod": {
                "type": "Domestic",
            },
            "message": "This is the text that appears to the receiver",
            "transactionText": "This is the text that will appear in the payers own bank",
            "destination": {
                "name": "Payment Receiverson",
                "iban": {
                    "ibanNumber": "FI9520000123456789"
                }
            },
            "amount": {
                "value": 1.00,
                "currency": "EUR"
            },
            "execution": {
                "type": "Instant",
            }
        }
      }'
```

#### 3. Authorise the payment {#3-authorise-the-payment}

The payment request that you initiated above returns a response body that contains a redirect URL and a payment ID:

```json
{
   "redirectUrl":
    "https://api.nordicapigateway.com/v1/payments/start?startToken=ugAAAAVDaXBoZXJ0ZXh0AIAAAAAAhDuLI4%2Fm6f8FUGRIpPSMCwP5hB1Aykvr4AKLKjGU03zzdYtdb1%2BFA1muVTMlCKssCfKMFmHsmnaeZ1tQ1Sevc%2Bx31CvyC5ALiltUehdevpc3zlhcIh8DSSzHXbJRP1PTGtbhTzwBu9m7Y2zMUtEaSaZQBpk%2FiGk0AjqwngCohQUFSXYAEAAAAACmRQHuI2P2D8%2Bthiu0dIZkEEtleUlkAAAAAAAA&paymentId=153fb3b0-52ec-4fdc-896e-3e67f21fdfad",
   "paymentId":"153fb3b0-52ec-4fdc-896e-3e67f21fdfad",
   "sessionId": "ugAAAAVDaXBoZXJ0ZXh0AIAAAAAArEP9F"
}
```

Copy and paste the redirect URL into your browser and walk through the payments flow.
Note: Choose the bank "Test bank with data #14 EUR", as this is a EURO account and you chose to make a EUR payment. Type anything in the fields of username and password. Once you reach the screen where you have to confirm payment, type six random characters.

You have now started your very first payment in our test bank.

You can check the status of authentication and obtain an `accessToken` and a `loginToken` to maintain connectivity to that user session by following the steps detailed in [Codes and Tokens](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/api-basics/code-and-tokens/index.md).

#### 4. What is the status of my payment? {#4-what-is-the-status-of-my-payment}

You also received a payment ID in the request body that uniquely identifies the payment you have started. You need this ID when querying the payment status.

API Reference: `POST /v1/payments/{paymentId}/refresh-status`

```shell
  curl -X POST \
  https://api.nordicapigateway.com/v1/payments/{paymentId}/refresh-status \
  -H 'Content-Type: application/json' \
  -H 'X-Client-Id: <CLIENT_ID>' \
  -H 'X-Client-Secret: <CLIENT_SECRET>' \
  -H 'Authorization: <ACCESS_TOKEN>' \

  -d '{}'
```

The response will show you what status your payment is in:

```json
  { 
   "payment":{ 
      "paymentId":"55d68cb8-0bf7-4e12-a78e-70ba1f47a084",
      "userHash":"test-user-hash",
      "providerId":"TestDataBank14",
      "request":{ 
         "sourceAccountId":"81U1EZ8hqrV4nkYI9-VQxSlL_obbdLqxvZgIbw1Ou5A.73213de47f4a",
         "destination":{ 
            "bban":null,
            "iban":{ 
               "ibanNumber":"FI9520000123456789"
            },
            "ownAccount":null,
            "name":"Payment Receiverson"
         },
         "amount":{ 
            "value":1.0,
            "currency":"EUR"
         },
         "execution":{ 
            "type":"Instant",
            "date":null
         },
         "message":"This is the text that appears to the receiver",
         "transactionText":"This is the text that will appear in the payers own bank",
         "endToEndId":null,
         "reference":null,
         "identifiers":null
      },
      "status":{ 
         "terminal":true,
         "code":"Succeeded",
         "lastUpdated":"2019-12-04T14:10:47.4687221+00:00",
         "details":null
      },
      "state":"Succeeded",
      "created":"2019-12-04T14:10:13+00:00",
      "source":{ 
         "bban":{ 
            "bankCode":"0013",
            "accountNumber":"110127523"
         },
         "iban":null,
         "ownAccount":null,
         "name":null
      },
      "execution":{ 
         "type":"Instant",
         "date":null,
         "fee":"Unknown",
         "feeAmount":null
      },
      "message":"This is the text that appears to the receiver",
      "transactionText":"This is the text that will appear in the payers own bank",
      "identifiers":{ 

      }
   }
}
```

The response shows that in this case the payment has been successfully executed by the ASPSP.

You have now created, authorized and checked the status of a payment.

## Further information {#further-information}

Refer to the [Testing](https://developer.mastercard.com/open-finance-europe/documentation/licensed/aiia-enterprise/testing/test-providers/index.md) section for information on how to test payments.
