Record a payment against an order, then issue a refund against that payment.
1 workflow2 source APIs1 provider
View SpecView on GitHubCommerceHeadless CommerceAPI-FirstConsumerB2BSubscriptionMarketplaceWholesaleStorefrontCheckoutPaymentsCartOrderCatalogInternationalizationArazzoWorkflows
arazzo: 1.0.1
info:
title: Swell Capture and Refund Payment
summary: Record a payment against an order, then issue a refund against that payment.
description: >-
A back-office money-movement flow. The workflow creates a payment tied to an
order and account with a method and amount, captures the payment id, and then
posts a refund against that payment for a given amount and reason. Each step
spells out its request inline so the flow can be read and executed without
opening the underlying OpenAPI description.
version: 1.0.0
sourceDescriptions:
- name: paymentsApi
url: ../openapi/swell-io-payments-api-openapi.yml
type: openapi
- name: refundsApi
url: ../openapi/swell-io-refunds-api-openapi.yml
type: openapi
workflows:
- workflowId: capture-and-refund-payment
summary: Create a payment, then refund it.
description: >-
Posts a payment against an order and account, then posts a refund against
the returned payment id.
inputs:
type: object
required:
- order_id
- amount
properties:
order_id:
type: string
description: The order the payment settles.
account_id:
type: string
description: The account the payment belongs to.
amount:
type: number
description: Payment amount in store currency.
method:
type: string
description: Payment method (card, account, amazon, paypal, manual).
currency:
type: string
description: ISO 4217 currency code.
refund_amount:
type: number
description: Amount to refund against the payment.
refund_reason:
type: string
description: Reason recorded on the refund.
steps:
- stepId: createPaymentStep
description: Record a payment against the order with the supplied method and amount.
operationId: $sourceDescriptions.paymentsApi.createPayment
requestBody:
contentType: application/json
payload:
order_id: $inputs.order_id
account_id: $inputs.account_id
amount: $inputs.amount
method: $inputs.method
currency: $inputs.currency
successCriteria:
- condition: $statusCode == 201
outputs:
paymentId: $response.body#/id
amountRefundable: $response.body#/amount_refundable
- stepId: refundPaymentStep
description: Issue a refund against the captured payment.
operationId: $sourceDescriptions.refundsApi.refundPayment
parameters:
- name: id
in: path
value: $steps.createPaymentStep.outputs.paymentId
requestBody:
contentType: application/json
payload:
amount: $inputs.refund_amount
reason: $inputs.refund_reason
successCriteria:
- condition: $statusCode == 201
outputs:
refundId: $response.body#/id
refundAmount: $response.body#/amount
outputs:
paymentId: $steps.createPaymentStep.outputs.paymentId
refundId: $steps.refundPaymentStep.outputs.refundId
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.