import type { Square } from "square" import { defineSquareOperation } from "../lib" /** Creates a Square-hosted checkout page. */ export const createSquarePaymentLink = defineSquareOperation< Square.checkout.CreatePaymentLinkRequest, Square.CreatePaymentLinkResponse >({ allowedKeys: [ "idempotencyKey", "description", "quickPay", "order", "checkoutOptions", "prePopulatedData", "paymentNote", ], description: "Creates a Square-hosted checkout page.", execute: (api, input) => api.checkout.paymentLinks.create(input), name: "Create Square Payment Link", replaySafety: "unsafe", requiredKeys: [], scopes: ["ORDERS_READ", "ORDERS_WRITE", "PAYMENTS_WRITE"], }) /** Deletes a payment link. */ export const deleteSquarePaymentLink = defineSquareOperation< Square.checkout.DeletePaymentLinksRequest, Square.DeletePaymentLinkResponse >({ allowedKeys: ["id"], description: "Deletes a payment link.", execute: (api, input) => api.checkout.paymentLinks.delete(input), name: "Delete Square Payment Link", replaySafety: "safe", requiredKeys: ["id"], scopes: ["ORDERS_READ", "ORDERS_WRITE"], }) /** Lists all payment links. */ export const listSquarePaymentLinks = defineSquareOperation< Square.checkout.ListPaymentLinksRequest, Square.ListPaymentLinksResponse >({ allowedKeys: ["cursor", "limit"], description: "Lists all payment links.", execute: (api, input) => api.checkout.paymentLinks.list(input), name: "List Square Payment Links", replaySafety: "safe", requiredKeys: [], scopes: ["ORDERS_READ"], }) /** Retrieves the location-level settings for a Square-hosted checkout page. */ export const retrieveSquareLocationSettings = defineSquareOperation< Square.RetrieveLocationSettingsRequest, Square.RetrieveLocationSettingsResponse >({ allowedKeys: ["locationId"], description: "Retrieves the location-level settings for a Square-hosted checkout page.", execute: (api, input) => api.checkout.retrieveLocationSettings(input), name: "Retrieve Square Location Settings", replaySafety: "safe", requiredKeys: ["locationId"], scopes: ["MERCHANT_PROFILE_READ"], }) /** Retrieves the merchant-level settings for a Square-hosted checkout page. */ export const retrieveSquareMerchantSettings = defineSquareOperation< Record, Square.RetrieveMerchantSettingsResponse >({ allowedKeys: [], description: "Retrieves the merchant-level settings for a Square-hosted checkout page.", execute: (api, _input) => api.checkout.retrieveMerchantSettings(), name: "Retrieve Square Merchant Settings", replaySafety: "safe", requiredKeys: [], scopes: ["MERCHANT_PROFILE_READ", "PAYMENT_METHODS_READ"], }) /** Retrieves a payment link. */ export const retrieveSquarePaymentLink = defineSquareOperation< Square.checkout.GetPaymentLinksRequest, Square.GetPaymentLinkResponse >({ allowedKeys: ["id"], description: "Retrieves a payment link.", execute: (api, input) => api.checkout.paymentLinks.get(input), name: "Retrieve Square Payment Link", replaySafety: "safe", requiredKeys: ["id"], scopes: ["ORDERS_READ"], }) /** Updates the location-level settings for a Square-hosted checkout page. */ export const updateSquareLocationSettings = defineSquareOperation< Square.UpdateLocationSettingsRequest, Square.UpdateLocationSettingsResponse >({ allowedKeys: ["locationId", "locationSettings"], description: "Updates the location-level settings for a Square-hosted checkout page.", execute: (api, input) => api.checkout.updateLocationSettings(input), name: "Update Square Location Settings", replaySafety: "safe", requiredKeys: ["locationId", "locationSettings"], scopes: ["MERCHANT_PROFILE_READ", "MERCHANT_PROFILE_WRITE"], }) /** Updates the merchant-level settings for a Square-hosted checkout page. */ export const updateSquareMerchantSettings = defineSquareOperation< Square.UpdateMerchantSettingsRequest, Square.UpdateMerchantSettingsResponse >({ allowedKeys: ["merchantSettings"], description: "Updates the merchant-level settings for a Square-hosted checkout page.", execute: (api, input) => api.checkout.updateMerchantSettings(input), name: "Update Square Merchant Settings", replaySafety: "safe", requiredKeys: ["merchantSettings"], scopes: [ "MERCHANT_PROFILE_READ", "MERCHANT_PROFILE_WRITE", "PAYMENT_METHODS_READ", ], }) /** Updates a payment link. */ export const updateSquarePaymentLink = defineSquareOperation< Square.checkout.UpdatePaymentLinkRequest, Square.UpdatePaymentLinkResponse >({ allowedKeys: ["id", "paymentLink"], description: "Updates a payment link.", execute: (api, input) => api.checkout.paymentLinks.update(input), name: "Update Square Payment Link", replaySafety: "safe", requiredKeys: ["id", "paymentLink"], scopes: ["ORDERS_READ", "ORDERS_WRITE", "PAYMENTS_WRITE"], })