# Migrate refunds from the Payments API to One API

> Everything needed to move an existing refunds integration onto One API, with the legacy guide and its One API counterpart side by side.

Both sides are implemented against: the legacy refunds endpoints and their One
API counterparts. Read Step 6 of the migration guide, which maps them, then the
two refund guides beside each other.

Authentication and the notification change with the rest of the integration, so
read the payin package first if you have not moved that yet: a refund on One
API needs a bearer token and a verified Svix signature, and the endpoints
changed shape at the same time.

Refunds are funded from your float balance on both APIs. A refund above that
balance fails rather than queueing.

Refund statuses reuse names that also appear on payins and mean something
different there. Handle every refund status the statuses page lists.

Test and live are separated by environment, not by a flag on the request.

## What this was built from

- Ozow Hub, commit `e0b2a572`
- `one-api` version 1.0, OpenAPI document: https://hub.ozow.com/api-reference/specs/one-api.yaml
- `payments-api` version 1.0, OpenAPI document: https://hub.ozow.com/api-reference/specs/payments-api.yaml
- Build against `https://one.ozow.com/v1` for `one-api`
- Build against `https://api.ozow.com` for `payments-api`
- 7 pages, 20 operations
- Everything below inlined in one document: https://hub.ozow.com/bundles/migrate-refunds-to-one-api-full.md

## Implement against these

Every field name, order and format on these pages is exact.

- [Migrating to One API](https://hub.ozow.com/integration-methods/apis/deprecated-integrations/migrating-to-one-api.md): Map a redirect payin and refunds integration from the Payments API to One API: what changes, what does not, and the order to make the changes in.
- [Refund a payment](https://hub.ozow.com/integration-methods/apis/deprecated-integrations/refund-a-payment.md): Issue a refund on the Payments API, the legacy path. Refunds are merchant-initiated backend operations, funded from your float balance.
- [Refund a payment](https://hub.ozow.com/integration-methods/apis/refunds/refund-a-payment.md): Issue a refund with One API. Refunds are merchant-initiated backend operations with no customer-facing step, so the whole flow is in your backend.
- [Verify a webhook signature](https://hub.ozow.com/integration-methods/apis/payin/verify-a-webhook.md): The signature on a One API webhook, the five steps that check it, and a working implementation in four languages.

## Background

Context for the above. Nothing here is implemented against.

- [Prerequisites and onboarding](https://hub.ozow.com/getting-started/prerequisites-and-onboarding.md): What to have in place before you write any code: a merchant account, Dashboard access, your credentials, and payout eligibility if you need it.
- [Float top-up guide](https://hub.ozow.com/payment-products/settlements-and-float/float-top-up.md): Payouts and refunds are funded from your float balance. Set up your static top-up reference once, then load funds whenever your float runs low.
- [Transaction and settlement statuses](https://hub.ozow.com/integration-methods/statuses.md): Every payin, payout, refund and settlement status, which are final, and what to do about each.

## The contract

Fetch the OpenAPI document named above to generate a client, or to check a field name or an enum against the schema.

- [one-api#get-/refunds](https://hub.ozow.com/api-reference/one-api/get-refunds.md)
- [one-api#get-/refunds/{id}](https://hub.ozow.com/api-reference/one-api/get-refunds-id.md)
- [one-api#get-/transactions/{id}/refunds](https://hub.ozow.com/api-reference/one-api/get-transactions-id-refunds.md)
- [one-api#get-/webhooks/{id}/secret](https://hub.ozow.com/api-reference/one-api/get-webhooks-id-secret.md)
- [one-api#post-/payments](https://hub.ozow.com/api-reference/one-api/post-payments.md)
- [one-api#post-/refunds](https://hub.ozow.com/api-reference/one-api/post-refunds.md)
- [one-api#post-/refunds/{id}/cancel](https://hub.ozow.com/api-reference/one-api/post-refunds-id-cancel.md)
- [one-api#post-/token](https://hub.ozow.com/api-reference/one-api/post-token.md)
- [one-api#post-/transactions/{id}/refunds](https://hub.ozow.com/api-reference/one-api/post-transactions-id-refunds.md)
- [one-api#schema/WebhookEnvelope](https://hub.ozow.com/api-reference/one-api/schemas/webhook-envelope.md)
- [one-api#tag/webhooks](https://hub.ozow.com/api-reference/one-api/tags/webhooks.md)
- [one-api#webhook/refund.complete](https://hub.ozow.com/api-reference/one-api/webhooks/refund-complete.md)
- [one-api#webhook/transaction.complete](https://hub.ozow.com/api-reference/one-api/webhooks/transaction-complete.md)
- [payments-api#get-/secure/refunds/getrefund](https://hub.ozow.com/api-reference/payments-api/get-secure-refunds-getrefund.md)
- [payments-api#get-/secure/refunds/getrefunds](https://hub.ozow.com/api-reference/payments-api/get-secure-refunds-getrefunds.md)
- [payments-api#get-/secure/refunds/getrefundsbytransactionid](https://hub.ozow.com/api-reference/payments-api/get-secure-refunds-getrefundsbytransactionid.md)
- [payments-api#post-/postpaymentrequest](https://hub.ozow.com/api-reference/payments-api/post-post-payment-request.md)
- [payments-api#post-/secure/refunds/submit](https://hub.ozow.com/api-reference/payments-api/post-secure-refunds-submit.md)
- [payments-api#post-/token](https://hub.ozow.com/api-reference/payments-api/post-token.md)
- [payments-api#webhook/refundNotification](https://hub.ozow.com/api-reference/payments-api/webhooks/refund-notification.md)
