Skip to content
Last updated

Creating The First Payment

Creating your first payment, below is a very basic example which will help you get going.

Note that even though payment.items is marked as optional in the documentation, most PSPs will require them to be set correctly and this to match the payment.totalGrossAmount and payment.totalNetAmount fields.

Add as much information in the API call as possible

Although the example below will work, we recommend to go through all the possible fields in the API Reference and make sure to add all the data you have available. This will enable future proofing for different features and integrations we have available.

Having as much information as possible added will also enable flexibility in terms of which reference number to be used with PSPs, which can be set up in the platform to be almost anything.

An example is the BMW App, where we require a VIN number of a vehicle in order to send a payment directly to a customer's app.

Example

curl -i -X POST \
  https://api.spense.no/api/payments \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'X-Organization-Id: string' \
  -d '{
    "customer": {
      "email": "some-person@some-domain.no",
      "firstName": "First name",
      "lastName": "Last name",
      "billingAddress": {
        "careOf": "",
        "street": "Dronning Eufemias gate 22",
        "secondary": "",
        "postalCode": "0191",
        "city": "OSLO",
        "country": "NO"
      },
      "phone": {
        "number": "40000000",
        "countryCode": "+47"
      },
      "type": "person",
      "sendSms": true
    },
    "order": {
      "orderNumber": "10076401"
    },
    "payment": {
      "currency": "NOK",
      "totalGrossAmount": 422,
      "totalNetAmount": 337.5,
      "items": [
        {
          "description": "DEKKSKIFTE KAMPANJE",
          "grossUnitPrice": 312.5,
          "netUnitPrice": 250,
          "vatAmount": 62.5,
          "quantity": 1,
          "taxRate": 25
        },
        {
          "description": "Vare alltid med",
          "grossUnitPrice": 100,
          "netUnitPrice": 80,
          "vatAmount": 20,
          "quantity": 1,
          "taxRate": 25
        },
        {
          "description": "MILJØAVGIFT",
          "grossUnitPrice": 9.38,
          "netUnitPrice": 7.5,
          "vatAmount": 1.88,
          "quantity": 1,
          "taxRate": 25
        },
        {
          "description": "Avrunding",
          "grossUnitPrice": 0.12,
          "netUnitPrice": 0,
          "vatAmount": 0.12,
          "quantity": 1,
          "taxRate": 0
        }
      ],
      "dueDate": "2024-02-19",
      "paymentRef": "10076401",
      "internalRef": "",
      "externalRef": ""
    },
    "callback": {
      "url": "https://your-own-domain.com/spense/payment-status-updated"
    },
    "supportFunctions": [
      {
        "sharebox": {
          "useSharebox": false,
          "plateNumber": null
        }
      }
    ]
  }'