UNPKG

@mollie/api-client

Version:
83 lines (82 loc) 4.49 kB
import type TransformingNetworkClient from '../../communication/TransformingNetworkClient'; import type Page from '../../data/page/Page'; import { type PaymentData } from '../../data/payments/data'; import type Payment from '../../data/payments/Payment'; import type Callback from '../../types/Callback'; import Binder from '../Binder'; import { type CancelParameters, type CreateParameters, type GetParameters, type IterateParameters, type PageParameters, type ReleaseParameters, type UpdateParameters } from './parameters'; export default class PaymentsBinder extends Binder<PaymentData, Payment> { protected readonly networkClient: TransformingNetworkClient; constructor(networkClient: TransformingNetworkClient); /** * Payment creation is elemental to the Mollie API: this is where most payment implementations start off. * * Once you have created a payment, you should redirect your customer to the URL in the `_links.checkout` property from the response. * * To wrap your head around the payment process, an explanation and flow charts can be found in the Accepting payments guide. * * @since 2.0.0 * @see https://docs.mollie.com/reference/v2/payments-api/create-payment */ create(parameters: CreateParameters): Promise<Payment>; create(parameters: CreateParameters, callback: Callback<Payment>): void; /** * Retrieve a single payment object by its payment token. * * @since 2.0.0 * @see https://docs.mollie.com/reference/v2/payments-api/get-payment */ get(id: string, parameters?: GetParameters): Promise<Payment>; get(id: string, parameters: GetParameters, callback: Callback<Payment>): void; /** * Retrieve all payments created with the current website profile, ordered from newest to oldest. * * The results are paginated. See pagination for more information. * * @since 3.0.0 * @see https://docs.mollie.com/reference/v2/payments-api/list-payments */ page(parameters?: PageParameters): Promise<Page<Payment>>; page(parameters: PageParameters, callback: Callback<Page<Payment>>): void; /** * Retrieve all payments created with the current website profile, ordered from newest to oldest. * * The results are paginated. See pagination for more information. * * @since 3.6.0 * @see https://docs.mollie.com/reference/v2/payments-api/list-payments */ iterate(parameters?: IterateParameters): import("../../plumbing/iteration/HelpfulIterator").default<Payment>; /** * This endpoint can be used to update some details of a created payment. * * @since 3.2.0 * @see https://docs.mollie.com/reference/v2/payments-api/update-payment */ update(id: string, parameters: UpdateParameters): Promise<Payment>; update(id: string, parameters: UpdateParameters, callback: Callback<Payment>): void; /** * Some payment methods can be canceled by the merchant for a certain amount of time, usually until the next business day. Or as long as the payment status is `open`. Payments may be canceled * manually from the Mollie Dashboard, or programmatically by using this endpoint. * * The `isCancelable` property on the Payment object will indicate if the payment can be canceled. * * @since 2.0.0 * @see https://docs.mollie.com/reference/v2/payments-api/cancel-payment */ cancel(id: string, parameters?: CancelParameters): Promise<Payment>; cancel(id: string, parameters: CancelParameters, callback: Callback<Page<Payment>>): void; /** * Releases the full remaining authorized amount. Call this endpoint when you will not be making any additional captures. Payment authorizations may also be released manually from the * Mollie Dashboard. * * Mollie will do its best to process release requests, but it is not guaranteed that it will succeed. It is up to the issuing bank if and when the hold will be released. * * If the request does succeed, the payment status will change to `canceled` for payments without captures. If there is a successful capture, the payment will transition to `paid`. * * @since 4.3.0 * @see https://docs.mollie.com/reference/release-authorization */ releaseAuthorization(id: string, parameters?: ReleaseParameters): Promise<true>; releaseAuthorization(id: string, parameters: ReleaseParameters, callback: Callback<Page<true>>): void; }