AdminPaymentsResource
This class is used to send requests to Admin Payment API Routes. All its method
are available in the JS Client under the medusa.admin.payments property.
All methods in this class require user authentication.
A payment can be related to an order, swap, return, or more. It can be captured or refunded.
Methods
capturePayment
Capture a payment.
Example
Parameters
idstringRequiredThe payment's ID.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
Resolves to the payment's details.
refundPayment
Refund a payment. The payment must be captured first.
Example
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.admin.payments
.refundPayment(paymentId, {
amount: 1000,
reason: "return",
note: "Do not like it",
})
.then(({ payment }) => {
console.log(payment.id)
})
Parameters
idstringRequiredThe payment's ID.
The refund to be created.
customHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
Resolves to the refund's details.
retrieve
Retrieve a payment's details.
Example
Parameters
idstringRequiredThe payment's ID.
queryGetPaymentsParamsConfigurations to apply on the retrieved payment.
queryGetPaymentsParamscustomHeadersRecord<string, any>RequiredCustom headers to attach to the request.
Default: {}
Returns
Resolves to the payment's details.
Was this section helpful?