# give/4.18.0/src/PaymentGateways/Gateways/PayPalCommerce/resources/js/createSubscriptionPlan.tsx

GiveWP – Donation Plugin and Fundraising Platform, version 4.18.0. 27 lines.

- Page: https://pluginprobe.com/plugins/give/4.18.0/code/src/PaymentGateways/Gateways/PayPalCommerce/resources/js/createSubscriptionPlan.tsx
- Raw: https://pluginprobe.com/plugins/give/4.18.0/raw/src/PaymentGateways/Gateways/PayPalCommerce/resources/js/createSubscriptionPlan.tsx
- Modified: 2025-03-31T19:17:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.18.0/code/src/PaymentGateways/Gateways/PayPalCommerce/resources/js/createSubscriptionPlan.tsx#L10-L20`.

```tsx
import type {PayPalCommerceGateway} from '../../types';

/**
 * @since 4.0.0
 */
export default async function createSubscriptionPlan(url: string, gateway: PayPalCommerceGateway, formData: FormData) {
    const response = await fetch(url, {
        method: 'POST',
        body: formData,
    });

    const responseJson = await response.json();

    if (!responseJson.success) {
        throw responseJson.data.error;
    }

    const planId = responseJson.data.id;

    gateway.payPalPlanId = planId;

    return {
        planId,
        userAction: responseJson.data?.user_action,
    };
}

```
