export type PaymentResourceId = string; export type LinkDescription = {href: string, rel: string, method?: ('GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'CONNECT' | 'OPTIONS' | 'PATCH') | undefined}; export type PaymentResourceBaseResponseDefinitionsLinkDescriptionList = Array; export type DateTime = unknown; export type Status = 'ACTIVE' | 'INACTIVE'; export type IntegrationMode = 'LINK'; export type PaymentResourceType = 'BUY_NOW'; export type Reusable = 'MULTIPLE'; export type CurrencyCode = unknown; export type Money = {currency_code: CurrencyCode, value: string}; export type Percentage = unknown; export type Tax = {name: string, percent: Percentage, amount?: Money | undefined, tax_note?: string | undefined}; export type TaxList = Array; export type ShippingName = {full_name?: string | undefined}; export type ShippingPhoneNumber = {country_code: string, national_number: string}; export type CountryCode = unknown; export type ShippingAddress = {address_line_1?: string | undefined, address_line_2?: string | undefined, admin_area_2?: string | undefined, admin_area_1?: string | undefined, postal_code?: string | undefined, country_code: CountryCode}; export type Shipping = {name?: ShippingName | undefined, phone_number?: ShippingPhoneNumber | undefined, type?: ('SHIPPING' | 'PICKUP_IN_PERSON' | 'PICKUP_IN_STORE' | 'PICKUP_FROM_PERSON') | undefined, address?: ShippingAddress | undefined}; export type ShippingList = Array; export type CustomerNote = {required?: boolean | undefined, label?: string | undefined}; export type CustomerNoteList = Array; export type DimensionOption = {label: string, unit_amount?: Money | undefined}; export type DimensionOptionList = Array; export type Dimension = {name: string, primary: boolean, options: DimensionOptionList}; export type DimensionList = Array; export type Variants = {dimensions: DimensionList}; export type AdjustableQuantity = {maximum: number}; export type LineItem = {name?: string | undefined, product_id?: string | undefined, description?: string | undefined, unit_amount?: Money | undefined, taxes?: TaxList | undefined, shipping?: ShippingList | undefined, collect_shipping_address?: boolean | undefined, customer_notes?: CustomerNoteList | undefined, variants?: Variants | undefined, adjustable_quantity?: AdjustableQuantity | undefined}; export type LineItemList = Array; export type Single = {body?: string | undefined}; export type CodeSnippetStacked = {framework: 'HTML' | 'REACT', head?: string | undefined, body?: string | undefined, button_placement?: string | undefined}; export type CodeSnippetStackedList = Array; export type CodeSnippet = {single?: Single | undefined, stacked?: CodeSnippetStackedList | undefined}; export type PaymentResourceDetailedResponse = {id?: PaymentResourceId | undefined, payment_link?: string | undefined, links?: PaymentResourceBaseResponseDefinitionsLinkDescriptionList | undefined, create_time?: DateTime | undefined, update_time?: DateTime | undefined, status?: Status | undefined, integration_mode: IntegrationMode, type: PaymentResourceType, reusable?: Reusable | undefined, return_url?: string | undefined, line_items?: LineItemList | undefined, code_snippets?: CodeSnippet | undefined}; export type UpdateApiV1CheckoutPaymentResourcesIdArgs = {id: string, 'Content-Type'?: string | undefined, 'PayPal-Auth-Assertion'?: string | undefined, body: PaymentResourceDetailedResponse}; export type UpdateApiV1CheckoutPaymentResourcesIdOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Replace a payment resource * * PUT /v1/checkout/payment-resources/{id} * * Also accepts auth: Oauth2 */ export const updateApiV1CheckoutPaymentResourcesId = async (args: UpdateApiV1CheckoutPaymentResourcesIdArgs, options?: UpdateApiV1CheckoutPaymentResourcesIdOptions) => { const {baseUrl = "https://api-m.paypal.com", fetch: fetchFn = fetch, Oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args['PayPal-Auth-Assertion'] != null) headers.set("PayPal-Auth-Assertion", String(args['PayPal-Auth-Assertion'])) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/checkout/payment-resources/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };