Cancel
The cancellations resource lists the cancellation transactions on a
specific payment.
Create Cancel Transaction
To cancel a previously created payment, you must perform the
create-paymentorder-cancel operation against the accompanying href returned
in the operations list. You can only cancel a payment - or part of a payment -
which has not been captured yet. If you cancel before any capture has been done,
no captures can be performed later.
Cancel Request
Request
1
2
3
4
POST /psp/paymentorders/09ccd29a-7c4f-4752-9396-12100cbfecce/cancellations HTTP/1.1
Host: api.externalintegration.payex.com
Authorization: Bearer <AccessToken>
Content-Type: application/json;version=3.0/2.0      // Version optional
 
1
2
3
4
5
6
{
    "transaction": {
        "description": "Test Cancellation",
        "payeeReference": "ABC123"
    }
}
 
      transaction
      object
      check
    
    
          description
          string
          check
        
        
          payeeReference
          string(30)
          check
        
        A unique reference from the merchant system. Set per operation to     ensure an exactly-once delivery of a transactional operation. Length and     content validation depends on whether the transaction.number or the     payeeReference is sent to the acquirer. If Swedbank Pay handles the     settlement, the transaction.number is sent to the acquirer and the     payeeReference must be in the format of A-Za-z0-9 and     string(30). If you handle the settlement,     Swedbank Pay will send the payeeReference and it will be limited to the     format of string(12). All characters must be digits.
Cancel Response
If the cancel request succeeds, the response should be similar to the example below:
Response
1
2
3
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8; version=3.0/2.0
api-supported-versions: 3.0/2.0
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
    "payment": "/psp/creditcard/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1",
    "cancellation": {
        "id": "/psp/creditcard/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1/cancellations/ec2a9b09-601a-42ae-8e33-a5737e1cf177",
        "transaction": {
            "id": "/psp/creditcard/payments/7e6cdfc3-1276-44e9-9992-7cf4419750e1/transactions/ec2a9b09-601a-42ae-8e33-a5737e1cf177",
            "created": "2022-01-31T09:49:13.7567756Z",
            "updated": "2022-01-31T09:49:14.7374165Z",
            "type": "Cancellation",
            "state": "Completed",
            "number": 71100732065,
            "amount": 1500,
            "vatAmount": 375,
            "description": "Test Cancellation",
            "payeeReference": "AB123"
        }
    }
}
 
      payment
      string
    
    
      cancellation
      object
    
    
          id
          string
        
        
          transaction
          object
        
        The object representation of the generic transaction resource, containing information about the current transaction.
              id
              string
            
            transaction resource.
              created
              string
            
            
              updated
              string
            
            
              type
              string
            
            
              state
              string
            
            Initialized, Completed or Failed. Indicates the state of the transaction.
              number
              integer
            
            The transaction number, useful when there’s need to reference the transaction in human communication. Not usable for programmatic identification of the transaction, where id should be used instead.
              amount
              integer
            
            The transaction amount (including VAT, if any) entered in the lowest monetary unit of the selected currency. E.g.: 10000 = 100.00 SEK, 5000 = 50.00 SEK.
              vatAmount
              integer
            
            The payment’s VAT (Value Added Tax) amount, entered in the lowest monetary unit of the selected currency. E.g.: 10000 = 100.00 SEK, 5000 = 50.00 SEK.  The vatAmount entered will not affect the amount shown on the payment page, which only shows the total amount. This field is used to specify how much of the total amount the VAT will be. Set to 0 (zero) if there is no VAT amount charged.
              description
              string
            
            
              payeeReference
              string(30)
            
            A unique reference from the merchant system. Set per operation to     ensure an exactly-once delivery of a transactional operation. Length and     content validation depends on whether the transaction.number or the     payeeReference is sent to the acquirer. If Swedbank Pay handles the     settlement, the transaction.number is sent to the acquirer and the     payeeReference must be in the format of A-Za-z0-9 and     string(30). If you handle the settlement,     Swedbank Pay will send the payeeReference and it will be limited to the     format of string(12). All characters must be digits.               In Invoice Payments payeeReference is used as an invoice/receipt         number, if the receiptReference is not defined.
Cancel Sequence Diagram
Cancel can only be done on an authorized transaction. As a cancellation does not have an amount associated with it, it will release the entire reserved amount. If your intention is to make detailed handling, such as only capturing a partial amount of the transaction, you must start with the capture of the desired amount before performing a cancel for the remaining reserved funds.
sequenceDiagram
    participant SwedbankPay as Swedbank Pay
    Merchant->>SwedbankPay: POST <  cancellation>
    activate Merchant
    activate SwedbankPay
    SwedbankPay-->>Merchant: transaction resource
    deactivate SwedbankPay
    deactivate Merchant