PayPal Subscriptions

Is it possible to create PayPal subscriptons on the fly, basically the same as creating a product item.

From this setup:

	return actions.order.create({
		application_context: {
        			shipping_preference: "NO_SHIPPING",
        			landing_page: "LOGIN", //my preference
        			user_action: "PAY_NOW", //my preference
        			payment_method: { payer_selected: "PAYPAL", payee_preferred: "IMMEDIATE_PAYMENT_REQUIRED" }
      			},
      			payer: {
		            name: { given_name: payer_name, surname: payer_last },
        			address: {
		              address_line_1: payer_ada,
		              address_line_2: payer_adb,
		              admin_area_2: payer_town,
		              admin_area_1: payer_county,
		              postal_code: payer_postcode,
		              country_code: "GB"
	            	},
		            email_address: payer_email,
		            payment_method: "PAYPAL",
		         },
      			purchase_units: [
		            {

To:

    return actions.subscription.create({
      /* Creates the subscription */
      plan_id: 'P-9P231956E4189481LNGFGWHQ'

But adding the custom data along the lines of:

  "product_id": "PROD-XXCD1234QWER65782",
  "name": "Video Streaming Service Plan",
  "description": "Video Streaming Service basic plan",
  "status": "ACTIVE",
  "billing_cycles": [
    {
      "frequency": {
        "interval_unit": "MONTH",
        "interval_count": 1
      },
      "tenure_type": "TRIAL",

?
Presumably you could send the create-plan message first, then the create-subscription one. But that is gonna get messy in your PayPal backend, because you’re effectively creating plans for each individual customer…

From working with PayPal subscriptions before, you generally can’t create a full subscription “product + plan” dynamically the same way you create a one-time order.

For subscriptions, PayPal expects a pre-created product and plan on their side. The actions.subscription.create() call usually just references an existing plan_id. That’s why trying to pass billing cycles or product data inline doesn’t work the same way as order.create().

If you really need dynamic behavior (like changing price or interval), one approach is:

  • Pre-create multiple plans (monthly, yearly, trial, etc.) and select the correct plan_id at runtime

  • Or use the PayPal API server-side to programmatically create plans before initiating the subscription

In practice, most production setups avoid creating plans on the fly during checkout because it adds complexity and potential API delays. Keeping plans predefined and selecting dynamically tends to be more stable.

Hope that helps clarify the difference :+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.