UNPKG

@paypal/react-paypal-js

Version:
18 lines (17 loc) 1.35 kB
/*! * react-paypal-js v10.1.2 (2026-07-07T20:12:38.513Z) * Copyright 2020-present, PayPal, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import"server-only";async function o(o){const{payload:t,signal:r,environment:e,headers:n}=o;if("production"!==e&&"sandbox"!==e)throw new Error('The "environment" option is required and must be either "production" or "sandbox"');const i=t??{},a="production"===e?"https://api-m.paypal.com":"https://api-m.sandbox.paypal.com";try{const o=await fetch(`${a}/v2/payments/find-eligible-methods`,{method:"POST",headers:n,body:JSON.stringify(i),signal:r});if(!o.ok)throw new Error(`Eligibility API error: ${o.status}`);return await o.json()}catch(o){throw new Error(`Failed to fetch eligible methods: ${o instanceof Error?o.message:String(o)}`)}}export{o as useFetchEligibleMethods};