UNPKG

@paypal/react-paypal-js

Version:
18 lines (17 loc) 1.21 kB
/*! * react-paypal-js v9.2.0 (2026-04-27T17:34:47.479Z) * 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 t(t){const{payload:e,signal:o,environment:r,headers:i}=t,a=e??{},n="production"===r?"https://api-m.paypal.com":"https://api-m.sandbox.paypal.com";try{const t=await fetch(`${n}/v2/payments/find-eligible-methods`,{method:"POST",headers:i,body:JSON.stringify(a),signal:o});if(!t.ok)throw new Error(`Eligibility API error: ${t.status}`);return await t.json()}catch(t){throw new Error(`Failed to fetch eligible methods: ${t instanceof Error?t.message:String(t)}`)}}export{t as useFetchEligibleMethods};