> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://amer.developers.trustly.com/llms.txt.
> For full documentation content, see https://amer.developers.trustly.com/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://amer.developers.trustly.com/_mcp/server.

# Refund Transaction

POST https://sandbox.trustly.one/api/v1/transactions/{transactionId}/refund
Content-Type: application/x-www-form-urlencoded

Refunds a previously completed Capture or Instant transaction (minimum of 0.99). You can optionally refund partially. You can do so as many times as you wish until the entire collected amount has been refunded.

A *Capture* or *Pay* transaction can only be refunded after the bank money collection has been processed and completed.

Ensure you also implement an Event Notification Handler to get transaction status updates.

Reference: https://amer.developers.trustly.com/api-reference/api/transactions/post-transactions-refund

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Trustly API
  version: 1.0.0
paths:
  /transactions/{transactionId}/refund:
    post:
      operationId: post-transactions-refund
      summary: Refund Transaction
      description: >-
        Refunds a previously completed Capture or Instant transaction (minimum
        of 0.99). You can optionally refund partially. You can do so as many
        times as you wish until the entire collected amount has been refunded.


        A *Capture* or *Pay* transaction can only be refunded after the bank
        money collection has been processed and completed.


        Ensure you also implement an Event Notification Handler to get
        transaction status updates.
      tags:
        - subpackage_transactions
      parameters:
        - name: transactionId
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: ''
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Transaction'
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              type: object
              properties:
                merchantReference:
                  type: string
                  description: >-
                    A specific merchant reference for this refund. For example,
                    this could be a merchant order number or the same merchant
                    reference value used in the original establish call.
                amount:
                  type: string
                  description: >-
                    The amount to be refunded which can be less or equal than
                    the current balance of the transaction being refunded. If
                    the value is omitted the remaining balance is refunded.
                    (maximum of 10 characters with support for 2 decimal places)
servers:
  - url: https://sandbox.trustly.one/api/v1
components:
  schemas:
    TransactionTransactionType:
      type: string
      enum:
        - '0'
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
        - '7'
        - '8'
        - '10'
      description: >-
        Type of transaction record. Definitions and descriptions can be found in
        [this
        table](https://amer.developers.trustly.com/payments/docs/type-definitions#transaction-types)
      title: TransactionTransactionType
    PaymentPaymentType:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
      description: "Financial Institution Account Type:\n * `1`: Instant -\tInstant payment. The debit instruction is automatically initiated with that day's batch after consumer authorization.\n * `2`: Deferred - Deferred payment. Payment is authorized but the capture operation must be called to initiate the debit. You can start to initiate multiple captures that are less than or equal to the original transaction authorization amount.\n * `3`: Recurring - Recurring payment. Same as deferred but associated to a payment agreement between consumer and merchant that defines how much and when the capture can be started.\n * `4`: Disbursement - Disbursement payment. This payment type can only be used for disbursements.\n * `5`: Verification - This payment type is used to verify the customer financial institution account as the payments will be done outside of the Trustly system.\n * `6`: Retrieval\tData retrieval. This payment type is used to retrieve account and user information from Trustly without an associated payment request. This payment type is not enabled by default. Contact Trustly if you need this feature."
      title: PaymentPaymentType
    PaymentMerchant:
      type: object
      properties:
        merchantId:
          type: string
          description: Unique Trustly Merchant ID.
        name:
          type: string
          description: Merchants name.
      title: PaymentMerchant
    VerificationStatus:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
      description: "Verification Status:\n  * `1`: Automatic - Payment verification followed Trustly internal rules.\n  * `2`: ToVerify\t- Payment transaction is held (status = OnHold) for further investigation and approval by the merchant.\n  * `3`: Verified - Payment was verified and approved by the merchant or Trustly (see Verification Mode).\n  * `4`: Refused - Payment was denied by the merchant or Trustly after verification.\n"
      title: VerificationStatus
    VerificationMode:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
      description: |
        Verification Mode:
          * `1`: VerifiedByMerchant
          * `2`: ApprovedByMerchant
          * `3`: VerifiedByTrustly
          * `4`: AmountAuthorizedByMerchant
      title: VerificationMode
    Verification:
      type: object
      properties:
        status:
          $ref: '#/components/schemas/VerificationStatus'
          description: "Verification Status:\n  * `1`: Automatic - Payment verification followed Trustly internal rules.\n  * `2`: ToVerify\t- Payment transaction is held (status = OnHold) for further investigation and approval by the merchant.\n  * `3`: Verified - Payment was verified and approved by the merchant or Trustly (see Verification Mode).\n  * `4`: Refused - Payment was denied by the merchant or Trustly after verification.\n"
        mode:
          $ref: '#/components/schemas/VerificationMode'
          description: |
            Verification Mode:
              * `1`: VerifiedByMerchant
              * `2`: ApprovedByMerchant
              * `3`: VerifiedByTrustly
              * `4`: AmountAuthorizedByMerchant
        verifyCustomer:
          type: boolean
          description: >-
            If true, the Customer information (name and zip code) was verified
            against information provided by the User's bank.
      title: Verification
    PaymentProviderSubType:
      type: string
      enum:
        - '1000'
        - '2000'
        - '2001'
      description: |
        Financial Institution Account Type:
         * `1000`: Online Banking
         * `2000`: Manual Entry
         * `2001`: Manual Entry with Challenge Deposit
      title: PaymentProviderSubType
    Address:
      type: object
      properties:
        address1:
          type: string
          description: Address line 1 (e.g., street or PO Box)
        address2:
          type: string
          description: Address line 2 (e.g., apartment, suite or unit number)
        city:
          type: string
          description: City, district, town or village
        state:
          type: string
          description: State, province or region code
        zip:
          type: string
          description: ZIP or Postal Code
        country:
          type: string
          description: >-
            2 character [ISO Country
            code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
      required:
        - country
      description: Valid mailing or billing address associated with the customer
      title: Address
    PaymentProviderCountry:
      type: string
      enum:
        - US
        - CA
        - UK
        - DE
        - AU
      description: 2-letter ISO country code of the financial institution
      title: PaymentProviderCountry
    PaymentProvider:
      type: object
      properties:
        paymentProviderId:
          type: string
          description: A unique identifier for the Payment Provider.
        type:
          type: number
          format: double
        name:
          type: string
          description: Name of the payment provider
        instantPayoutAvailable:
          type: boolean
          description: Whether payment provider supports instant payout.
        subType:
          $ref: '#/components/schemas/PaymentProviderSubType'
          description: |
            Financial Institution Account Type:
             * `1000`: Online Banking
             * `2000`: Manual Entry
             * `2001`: Manual Entry with Challenge Deposit
        swift:
          type: string
        address:
          $ref: '#/components/schemas/Address'
        country:
          $ref: '#/components/schemas/PaymentProviderCountry'
          description: 2-letter ISO country code of the financial institution
        instantPayment:
          type: boolean
      required:
        - name
      description: Details of the Financial institution
      title: PaymentProvider
    AccountCountry:
      type: string
      enum:
        - US
        - CA
        - UK
        - DE
        - AU
      description: >-
        2-character ISO code of the country for the bank account that was
        selected. Currently only the US, CA, UK, DE, and AU are supported.
      title: AccountCountry
    FinancialInstitutionAccountVerificationType:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
      description: "Verification Type:\n * `1`: Manual - The account was verified with manual account verification. For example, Manual Electronic Check and Micro Challenge Deposit.\n * `2`: Online Banking verification\t- The Account was verified using the Trustly Online Banking application.\n * `3`: Database verification\t- The Account was verified using the Trustly database or a Third-Party Service.  \n"
      title: FinancialInstitutionAccountVerificationType
    FinancialInstitutionAccountVerificationScore:
      type: string
      enum:
        - '0'
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
        - '7'
        - '8'
        - '9'
        - '10'
      description: |
        Verification Score:
         * `0`: Invalid input. The account or routing number are invalid. (Verified Mapping = false)
         * `1`: There is a strong indication that the account is invalid. (Verified Mapping = false)
         * `2`: There are active non-bankable returns on this account that are less than 3 years old. (Verified Mapping = false)
         * `3`: There are administrative returns on this account. (Verified Mapping = false)
         * `4`: The format appears to be suspicious. (Verified Mapping = false)
         * `5`: There is no data on this account or format. (Verified Mapping = false)
         * `6`: We have not seen this account, but the format appears to be valid. (Verified Mapping = true)
         * `7`: We have seen this account but have not received a final disposition on the transaction. (Verified Mapping = true)
         * `8`: We have seen this account, but not in the last 6 months, and have seen no returns associated with the account. (Verified Mapping = true)
         * `9`: We have seen this account in the last 6 months and have seen no returns associated with the account. (Verified Mapping = true)
         * `10`: This account has been directly validated with/by the financial institution or 3rd party. We have the highest confidence that this account is valid. (Verified Mapping = true)
      title: FinancialInstitutionAccountVerificationScore
    FinancialInstitutionAccountVerificationThirdPartyScore:
      type: string
      enum:
        - '0'
        - '100'
        - '200'
        - '300'
        - '400'
        - '500'
        - '600'
        - '700'
        - '800'
        - '900'
        - '999'
      description: |
        Verification Third-Party Score:
         * `0`: Failed RT validation. (Verified Mapping = 0)
         * `100`: The supplier has a strong indication that this account is invalid. (Verified Mapping = 1)
         * `200`: The supplier has active non-bankable debt(s) on this account that are less than 3 years old. (Verified Mapping = 2)
         * `300`: The supplier has administrative returns on this account. (Verified Mapping = 3)
         * `400`: The supplier does not have Neg data on this account, but the format appears to be suspicious. (Verified Mapping = 4)
         * `500`: The supplier does not have data on this account or format. (Verified Mapping = 5)
         * `600`: The supplier has not seen this account, but the format appears valid. (Verified Mapping = 6)
         * `700`: The supplier has seen this account, but did not receive a final disposition on the transaction. (Verified Mapping = 7)
         * `800`: The supplier has seen this account, but not in the last 6 months. (Verified Mapping = 8)
         * `900`: The supplier has seen this account in the last 6 months. (Verified Mapping = 9)
         * `999`: The supplier has the highest confidence that this account is valid. (Verified Mapping = 10)
      title: FinancialInstitutionAccountVerificationThirdPartyScore
    FinancialInstitutionAccountVerification:
      type: object
      properties:
        verified:
          type: boolean
          description: true if the account is verified; false otherwise.
        type:
          $ref: '#/components/schemas/FinancialInstitutionAccountVerificationType'
          description: "Verification Type:\n * `1`: Manual - The account was verified with manual account verification. For example, Manual Electronic Check and Micro Challenge Deposit.\n * `2`: Online Banking verification\t- The Account was verified using the Trustly Online Banking application.\n * `3`: Database verification\t- The Account was verified using the Trustly database or a Third-Party Service.  \n"
        hasEnoughFunds:
          type: boolean
          description: If true, there is enough balance in account.
        verificationDate:
          type: integer
          description: |-
            The date and time the verification was completed 
             as a UNIX timestamp.
        score:
          $ref: '#/components/schemas/FinancialInstitutionAccountVerificationScore'
          description: |
            Verification Score:
             * `0`: Invalid input. The account or routing number are invalid. (Verified Mapping = false)
             * `1`: There is a strong indication that the account is invalid. (Verified Mapping = false)
             * `2`: There are active non-bankable returns on this account that are less than 3 years old. (Verified Mapping = false)
             * `3`: There are administrative returns on this account. (Verified Mapping = false)
             * `4`: The format appears to be suspicious. (Verified Mapping = false)
             * `5`: There is no data on this account or format. (Verified Mapping = false)
             * `6`: We have not seen this account, but the format appears to be valid. (Verified Mapping = true)
             * `7`: We have seen this account but have not received a final disposition on the transaction. (Verified Mapping = true)
             * `8`: We have seen this account, but not in the last 6 months, and have seen no returns associated with the account. (Verified Mapping = true)
             * `9`: We have seen this account in the last 6 months and have seen no returns associated with the account. (Verified Mapping = true)
             * `10`: This account has been directly validated with/by the financial institution or 3rd party. We have the highest confidence that this account is valid. (Verified Mapping = true)
        thirdPartyScore:
          $ref: >-
            #/components/schemas/FinancialInstitutionAccountVerificationThirdPartyScore
          description: |
            Verification Third-Party Score:
             * `0`: Failed RT validation. (Verified Mapping = 0)
             * `100`: The supplier has a strong indication that this account is invalid. (Verified Mapping = 1)
             * `200`: The supplier has active non-bankable debt(s) on this account that are less than 3 years old. (Verified Mapping = 2)
             * `300`: The supplier has administrative returns on this account. (Verified Mapping = 3)
             * `400`: The supplier does not have Neg data on this account, but the format appears to be suspicious. (Verified Mapping = 4)
             * `500`: The supplier does not have data on this account or format. (Verified Mapping = 5)
             * `600`: The supplier has not seen this account, but the format appears valid. (Verified Mapping = 6)
             * `700`: The supplier has seen this account, but did not receive a final disposition on the transaction. (Verified Mapping = 7)
             * `800`: The supplier has seen this account, but not in the last 6 months. (Verified Mapping = 8)
             * `900`: The supplier has seen this account in the last 6 months. (Verified Mapping = 9)
             * `999`: The supplier has the highest confidence that this account is valid. (Verified Mapping = 10)
        numberOfTries:
          type: number
          format: double
          description: Number of tries allowed.
        numberOfAttemptsLeft:
          type: number
          format: double
          description: Number of remaining attempts.
      required:
        - verified
        - type
        - hasEnoughFunds
        - verificationDate
      title: FinancialInstitutionAccountVerification
    Account:
      type: object
      properties:
        providerId:
          type: string
          description: Payment provider ID.
        paymentProvider:
          $ref: '#/components/schemas/PaymentProvider'
        country:
          $ref: '#/components/schemas/AccountCountry'
          description: >-
            2-character ISO code of the country for the bank account that was
            selected. Currently only the US, CA, UK, DE, and AU are supported.
        name:
          type: string
          description: >-
            A description to identify a specific account (e.g. Test checking
            account)
        type:
          type: number
          format: double
          description: See Financial Institution Account Type Values.
        profile:
          type: number
          format: double
          description: See Financial Institution Account Profile Values
        accountNumber:
          type: string
          description: >-
            Bank Account Number or VAN if `virtualAccountRoutingPair` is equal
            to `true`.
        iban:
          type: string
          description: >-
            IBAN (International Bank Account Number) is an internationally
            agreed system of identifying bank accounts across national borders
        verified:
          type: boolean
          description: Indicates if the account is verified or not.
        verification:
          $ref: '#/components/schemas/FinancialInstitutionAccountVerification'
        source:
          type: number
          format: double
        routingNumber:
          type: string
          description: Bank Routing Number
        token:
          type: string
          description: The Account Token
        accountNumberLastFour:
          type: string
          description: The last 4 digits of the real account number.
        virtualAccountRoutingPair:
          type: boolean
          description: >-
            Indicates if account is using virtual/tokenized account and routing
            numbers (VANs/TANs) or not.
      title: Account
    PaymentCurrency:
      type: string
      enum:
        - USD
      description: 3-letter ISO Currency Code. Currently only USD is supported.
      title: PaymentCurrency
    PaymentAuth:
      type: object
      properties:
        token:
          type: string
          description: Authorization token.
        status:
          type: integer
          description: See Authorization Status Values.
        message:
          type: string
          description: Authorization message.
      title: PaymentAuth
    CustomerCustomData:
      type: object
      properties: {}
      description: Object for sending merchant-specific custom data.
      title: CustomerCustomData
    DriverLicense:
      type: object
      properties:
        number:
          type: string
          description: Driver License number.
        state:
          type: string
          description: 2 character ISO State code.
      required:
        - number
        - state
      title: DriverLicense
    Customer:
      type: object
      properties:
        name:
          type: string
          description: Full name of the Customer
        taxId:
          type: string
          description: >-
            Customer tax ID (e.g. SSN [US], SIN [CA]). *May be required
            depending on industry and location.*
        address:
          $ref: '#/components/schemas/Address'
        phone:
          type: string
          description: Customer phone number.
        email:
          type: string
          description: Customer email address.
        dateOfBirth:
          type: string
          description: Customer date of birth.
        createdAt:
          type: integer
          description: The record created date and time as a UNIX timestamp.
        updatedAt:
          type: integer
          description: The record created date and time as a UNIX timestamp.
        customerId:
          type: string
          description: A unique Trustly customer identifier.
        externalId:
          type: string
          description: A unique merchant customer identifier.
        merchantId:
          type: string
          description: A unique Trustly merchant identifier.
        enrollDate:
          type: integer
          description: >-
            Date of the user's first transaction in your system, regardless of
            payment method used as a UNIX timestamp.
        vip:
          type: string
          description: >-
            Range that determines how low-risk the customer represents to the
            merchant
        currency:
          type: string
          description: Customer currency.
        balance:
          type: string
          description: >-
            Customer account balance (not associated with a financial
            institution account).
        organizationNumber:
          type: string
          description: Organization number for business accounts
        externalTier:
          type: string
          description: >-
            It should describe the customer''s rank to the merchant (e.g. Gold,
            Diamond, 4 stars, etc.)
        personId:
          type: string
          description: Unique customer identity throughout different banks.
        customData:
          $ref: '#/components/schemas/CustomerCustomData'
          description: Object for sending merchant-specific custom data.
        driverLicense:
          $ref: '#/components/schemas/DriverLicense'
        nationalId:
          type: string
          description: Customer National ID
      required:
        - name
        - address
        - phone
        - email
      description: >-
        The Trustly customer object, containing identification details and
        contact information.
      title: Customer
    RecurrenceFrequencyUnitType:
      type: string
      enum:
        - Day
        - Week
        - Month
        - Year
      description: Frequency Unit Type
      title: RecurrenceFrequencyUnitType
    Recurrence:
      type: object
      properties:
        startDate:
          type: string
          format: date-time
          description: Recurring payment start date as a UNIX timestamp.
        endDate:
          type: string
          format: date-time
          description: Recurring payment end date as a UNIX timestamp.
        nextOccurrence:
          type: string
          format: date-time
          description: >-
            When the next capture will be issued if using automatic captures as
            a UNIX timestamp.
        recurringAmount:
          type: string
          description: >-
            Recurring payment amount. (maximum of 10 characters with support for
            2 decimal places)
        debtSettlement:
          type: string
          description: >-
            Any debt amount settlement done outside of the Trustly like
            discounts or when consumers pays one recurring debt using another
            payment method like traditional checks or credit cards. (maximum of
            10 characters with support for 2 decimal places)
        frequency:
          type: integer
          default: 1
          description: >-
            How many payments per frequencyUnit. Defaults to 1. Example: To
            define 2 recurring payments every 3 months set: frequency=2,
            frequencyUnit=3 and frequencyUnitType=3.
        frequencyUnit:
          type: number
          format: double
          description: >-
            Defines with frequencyUnitType the interval of the frequency of
            payments.
        frequencyUnitType:
          $ref: '#/components/schemas/RecurrenceFrequencyUnitType'
          description: Frequency Unit Type
        automaticCapture:
          type: boolean
          description: If true, payment captures are issued automatically.
        recurrenceId:
          type: string
      description: Recurring payment options
      title: Recurrence
    PaymentSystem:
      type: string
      enum:
        - '-1'
        - '1'
        - '2'
      description: |-
        Financial Institution Account Type:
          * `-1`: None
          * `1`: PayWithMyBank
          * `2`: TrustlyAB
      title: PaymentSystem
    PaymentCountry:
      type: string
      enum:
        - US
        - CA
        - UK
        - DE
        - AU
      description: >-
        2-character ISO code of the country for the bank account that was
        selected. Currently only the US, CA, UK, DE, and AU are supported.
      title: PaymentCountry
    PaymentProviderSubtype:
      type: string
      enum:
        - '1000'
        - '2000'
        - '2001'
      description: |-
        Payment Provider Subtype:
          * `1000`: EasyOnline
          * `2000`: MEC
          * `2001`: MCD
      title: PaymentProviderSubtype
    Payment:
      type: object
      properties:
        required:
          description: Any type
        paymentId:
          type: string
          description: A unique payment identifier generated by Trustly (15 character max).
        paymentType:
          $ref: '#/components/schemas/PaymentPaymentType'
          description: "Financial Institution Account Type:\n * `1`: Instant -\tInstant payment. The debit instruction is automatically initiated with that day's batch after consumer authorization.\n * `2`: Deferred - Deferred payment. Payment is authorized but the capture operation must be called to initiate the debit. You can start to initiate multiple captures that are less than or equal to the original transaction authorization amount.\n * `3`: Recurring - Recurring payment. Same as deferred but associated to a payment agreement between consumer and merchant that defines how much and when the capture can be started.\n * `4`: Disbursement - Disbursement payment. This payment type can only be used for disbursements.\n * `5`: Verification - This payment type is used to verify the customer financial institution account as the payments will be done outside of the Trustly system.\n * `6`: Retrieval\tData retrieval. This payment type is used to retrieve account and user information from Trustly without an associated payment request. This payment type is not enabled by default. Contact Trustly if you need this feature."
        merchant:
          $ref: '#/components/schemas/PaymentMerchant'
        merchantReference:
          type: string
          description: >-
            An external reference from the merchant. Ex: Order identifier from
            merchant e-commerce application.
        merchantId:
          type: string
          description: Your Trustly Merchant Id. It will be provided to you.
        fingerprint:
          type: string
          description: Internal use only
        verification:
          $ref: '#/components/schemas/Verification'
        account:
          $ref: '#/components/schemas/Account'
        description:
          type: string
          description: A summary description of the order.
        returnUrl:
          type: string
          description: Return URL provided with the bank authorization.
        cancelUrl:
          type: string
          description: Cancel URL provided with the bank authorization.
        currency:
          $ref: '#/components/schemas/PaymentCurrency'
          description: 3-letter ISO Currency Code. Currently only USD is supported.
        amount:
          type: string
          description: "\tThe total amount of the order, including tax and shipping. If transactionType is Recurring, this is the Setup Fee Amount."
        paymentProvider:
          $ref: '#/components/schemas/PaymentProvider'
        allowedPaymentProviderType:
          type: array
          items:
            type: integer
        auth:
          $ref: '#/components/schemas/PaymentAuth'
        authorization:
          type: string
          description: Authorization token.
        authorizationStatus:
          type: number
          format: double
          description: >-
            Status of the related bank authorization. See Transaction Status
            Values.
        authorizationStatusMessage:
          type: string
          description: Status message of the related bank authorization.
        pending:
          type: string
          description: >-
            The total amount that is still pending completion. (10 characters
            with support for 2 decimal places)
        paid:
          type: string
          description: >-
            The total amount that was already paid. (10 characters with support
            for 2 decimal places)
        refunded:
          type: string
          description: >-
            The total amount that was refunded. (10 characters with support for
            2 decimal places)
        reversed:
          type: string
          description: >-
            The total amount that was reversed. (10 characters with support for
            2 decimal places)
        balance:
          type: string
          description: >-
            The balance of the amount paid, minus the amount reversed and/or
            refunded. (10 characters with support for 2 decimal places)
        createdAt:
          type: integer
          description: The date and time the transaction was created as a UNIX timestamp.
        updatedAt:
          type: integer
          description: >-
            The date and time the transaction was last updated as a UNIX
            timestamp.
        recordVersion:
          type: number
          format: double
          description: The current record version.
        paymentFlow:
          type: number
          format: double
          description: internal use only
        customer:
          $ref: '#/components/schemas/Customer'
        address:
          $ref: '#/components/schemas/Address'
        recurrence:
          $ref: '#/components/schemas/Recurrence'
        system:
          $ref: '#/components/schemas/PaymentSystem'
          description: |-
            Financial Institution Account Type:
              * `-1`: None
              * `1`: PayWithMyBank
              * `2`: TrustlyAB
        country:
          $ref: '#/components/schemas/PaymentCountry'
          description: >-
            2-character ISO code of the country for the bank account that was
            selected. Currently only the US, CA, UK, DE, and AU are supported.
        paymentProviderSubtype:
          $ref: '#/components/schemas/PaymentProviderSubtype'
      description: A Trustly Payment
      title: Payment
    TransactionCurrency:
      type: string
      enum:
        - USD
      description: 3-letter ISO Currency Code. Currently only USD is supported.
      title: TransactionCurrency
    PaymentProviderTransactionPaymentProcessor:
      type: object
      properties:
        paymentProcessorId:
          type: string
        type:
          type: integer
        name:
          type: string
        shortName:
          type: string
        url:
          type: string
        active:
          type: string
      title: PaymentProviderTransactionPaymentProcessor
    PaymentProviderTransaction:
      type: object
      properties:
        paymentProviderTransactionId:
          type: string
          description: Unique payment provider transaction identifier.
        status:
          type: string
          description: See Payment Provider Transaction Status Codes.
        statusMessage:
          type: string
          description: Payment provider transaction status message.
        signature:
          type: string
        statusDescription:
          type: string
        paymentProcessor:
          $ref: '#/components/schemas/PaymentProviderTransactionPaymentProcessor'
        thirdPartyDeclineCode:
          type: string
        clearingHouse:
          type: string
        instantSettle:
          type: boolean
          description: Whether instant settlement was used for transaction.
      description: Payment Provider Transaction
      title: PaymentProviderTransaction
    TransactionStatus:
      type: string
      enum:
        - '0'
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
        - '6'
        - '7'
        - '8'
        - '10'
        - '11'
        - '12'
        - '13'
        - '14'
      description: >-
        Status code of the Payment Provider Transaction record. Definitions and
        descriptions can be found in [this
        table](https://amer.developers.trustly.com/payments/docs/type-definitions#transaction-status-values)
      title: TransactionStatus
    Transaction:
      type: object
      properties:
        required:
          description: Any type
        transactionId:
          type: string
          description: >-
            A unique transaction identifier generated by Trustly (15 character
            max).
        transactionType:
          $ref: '#/components/schemas/TransactionTransactionType'
          description: >-
            Type of transaction record. Definitions and descriptions can be
            found in [this
            table](https://amer.developers.trustly.com/payments/docs/type-definitions#transaction-types)
        payment:
          $ref: '#/components/schemas/Payment'
        currency:
          $ref: '#/components/schemas/TransactionCurrency'
          description: 3-letter ISO Currency Code. Currently only USD is supported.
        amount:
          type: string
          description: >-
            The amount of the transaction. (10 characters with support for 2
            decimal places)
        pending:
          type: string
          description: >-
            The total amount that is still pending completion. (10 characters
            with support for 2 decimal places)
        paid:
          type: string
          description: >-
            The total amount that was already paid. (10 characters with support
            for 2 decimal places)
        refunded:
          type: string
          description: >-
            The total amount that was refunded. (10 characters with support for
            2 decimal places)
        reversed:
          type: string
          description: >-
            The total amount that was reversed. (10 characters with support for
            2 decimal places)
        balance:
          type: string
          description: >-
            The balance of the amount paid, minus the amount reversed and/or
            refunded. (10 characters with support for 2 decimal places)
        paymentProviderTransaction:
          $ref: '#/components/schemas/PaymentProviderTransaction'
        status:
          $ref: '#/components/schemas/TransactionStatus'
          description: >-
            Status code of the Payment Provider Transaction record. Definitions
            and descriptions can be found in [this
            table](https://amer.developers.trustly.com/payments/docs/type-definitions#transaction-status-values)
        statusMessage:
          type: string
          description: A descriptive status message. (120 characters)
        ip:
          type: string
          description: The client IP address in IPv4 or IPv6 format.
        createdAt:
          type: integer
          description: The date and time the transaction was created as a UNIX timestamp.
        processedAt:
          type: integer
          description: The date and time the transaction was processed as a UNIX timestamp.
        completedAt:
          type: integer
          description: The date and time the transaction was completed as a UNIX timestamp.
        updatedAt:
          type: integer
          description: >-
            The date and time the transaction was last updated as a UNIX
            timestamp.
        ppTrxId:
          type: string
          description: internal use only
        merchantReference:
          type: string
          description: Merchants internal reference id for the transaction.
        expiredAt:
          type: integer
          description: >-
            The date and time the preauthorization will expire as a UNIX
            timestamp.
        recordVersion:
          type: number
          format: double
          description: The current record version.
        originalTransactionId:
          type: string
        fee:
          type: string
        timeZone:
          type: string
        representmentScheduledAt:
          type: number
          format: double
        paymentProcessorType:
          type: string
        statusCode:
          type: string
        preAuthorized:
          type: boolean
      description: A Trustly transaction object
      title: Transaction
  securitySchemes:
    HTTPBasic:
      type: http
      scheme: basic
      description: ''

```

## SDK Code Examples

```python Example
import requests

url = "https://sandbox.trustly.one/api/v1/transactions/transactionId/refund"

payload = ""
headers = {
    "Content-Type": "application/x-www-form-urlencoded"
}

response = requests.post(url, data=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript Example
const url = 'https://sandbox.trustly.one/api/v1/transactions/transactionId/refund';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: new URLSearchParams('')
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://sandbox.trustly.one/api/v1/transactions/transactionId/refund"

	req, _ := http.NewRequest("POST", url, nil)

	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Example
require 'uri'
require 'net/http'

url = URI("https://sandbox.trustly.one/api/v1/transactions/transactionId/refund")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/x-www-form-urlencoded'

response = http.request(request)
puts response.read_body
```

```java Example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://sandbox.trustly.one/api/v1/transactions/transactionId/refund")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```php Example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://sandbox.trustly.one/api/v1/transactions/transactionId/refund', [
  'form_params' => null,
  'headers' => [
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp Example
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://sandbox.trustly.one/api/v1/transactions/transactionId/refund");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/x-www-form-urlencoded"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://sandbox.trustly.one/api/v1/transactions/transactionId/refund")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```