import type { Square } from "square" import { defineSquareOperation } from "../lib" /** Cancels (voids) a payment. */ export const cancelSquarePayment = defineSquareOperation< Square.CancelPaymentsRequest, Square.CancelPaymentResponse >({ allowedKeys: ["paymentId"], description: "Cancels (voids) a payment.", execute: (api, input) => api.payments.cancel(input), name: "Cancel Square Payment", replaySafety: "unsafe", requiredKeys: ["paymentId"], scopes: ["PAYMENTS_WRITE"], }) /** * Cancels (voids) a payment identified by the idempotency key that is specified * in the request. */ export const cancelSquarePaymentByIdempotencyKey = defineSquareOperation< Square.CancelPaymentByIdempotencyKeyRequest, Square.CancelPaymentByIdempotencyKeyResponse >({ allowedKeys: ["idempotencyKey"], description: "Cancels (voids) a payment identified by the idempotency key that is specified in the request.", execute: (api, input) => api.payments.cancelByIdempotencyKey(input), name: "Cancel Square Payment By Idempotency Key", replaySafety: "safe", requiredKeys: ["idempotencyKey"], scopes: ["PAYMENTS_WRITE"], }) /** Completes (captures) a payment. */ export const completeSquarePayment = defineSquareOperation< Square.CompletePaymentRequest, Square.CompletePaymentResponse >({ allowedKeys: ["paymentId", "versionToken"], description: "Completes (captures) a payment.", execute: (api, input) => api.payments.complete(input), name: "Complete Square Payment", replaySafety: "unsafe", requiredKeys: ["paymentId"], scopes: ["PAYMENTS_WRITE"], }) /** Creates a payment using the provided source. */ export const createSquarePayment = defineSquareOperation< Square.CreatePaymentRequest, Square.CreatePaymentResponse >({ allowedKeys: [ "sourceId", "idempotencyKey", "amountMoney", "tipMoney", "appFeeMoney", "appFeeAllocations", "delayDuration", "delayAction", "autocomplete", "orderId", "customerId", "locationId", "teamMemberId", "referenceId", "verificationToken", "acceptPartialAuthorization", "buyerEmailAddress", "buyerPhoneNumber", "billingAddress", "shippingAddress", "note", "statementDescriptionIdentifier", "cashDetails", "externalDetails", "customerDetails", "offlinePaymentDetails", ], description: "Creates a payment using the provided source.", execute: (api, input) => api.payments.create(input), name: "Create Square Payment", replaySafety: "safe", requiredKeys: ["sourceId", "idempotencyKey"], scopes: ["PAYMENTS_WRITE"], }) /** Retrieves details for a specific payment. */ export const getSquarePayment = defineSquareOperation< Square.GetPaymentsRequest, Square.GetPaymentResponse >({ allowedKeys: ["paymentId"], description: "Retrieves details for a specific payment.", execute: (api, input) => api.payments.get(input), name: "Get Square Payment", replaySafety: "safe", requiredKeys: ["paymentId"], scopes: ["PAYMENTS_READ"], }) /** Retrieves a list of payments taken by the account making the request. */ export const listSquarePayments = defineSquareOperation< Square.ListPaymentsRequest, Square.ListPaymentsResponse >({ allowedKeys: [ "beginTime", "endTime", "sortOrder", "cursor", "locationId", "total", "last4", "cardBrand", "limit", "isOfflinePayment", "offlineBeginTime", "offlineEndTime", "updatedAtBeginTime", "updatedAtEndTime", "sortField", ], description: "Retrieves a list of payments taken by the account making the request.", execute: (api, input) => api.payments.list(input), name: "List Square Payments", replaySafety: "safe", requiredKeys: [], scopes: ["PAYMENTS_READ"], }) /** Updates a payment with the APPROVED status. */ export const updateSquarePayment = defineSquareOperation< Square.UpdatePaymentRequest, Square.UpdatePaymentResponse >({ allowedKeys: ["paymentId", "payment", "idempotencyKey"], description: "Updates a payment with the APPROVED status.", execute: (api, input) => api.payments.update(input), name: "Update Square Payment", replaySafety: "safe", requiredKeys: ["paymentId", "idempotencyKey"], scopes: ["PAYMENTS_WRITE"], })