Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get billing_plan_id and product_id after creating recurring subscriptions ? #616

Closed
otnansirk opened this issue Feb 15, 2024 · 2 comments

Comments

@otnansirk
Copy link
Contributor

otnansirk commented Feb 15, 2024

Hi @srmklive : How to get billing_plan_id and product_id after creating recurring subscriptions
For example after I call this method how do I get the billing_plan_id and product_id that has been created ?

$response = $provider->addProduct('Demo Product', 'Demo Product', 'SERVICE', 'SOFTWARE')
            ->addCustomPlan('Demo Plan', 'Demo Plan', 150, 'MONTH', 3)
            ->setReturnAndCancelUrl('https://example.com/paypal-success', 'https://example.com/paypal-cancel')
            ->setupSubscription('John Doe', '[email protected]', '2021-12-10');

Response from this process only

{
	"status": "APPROVAL_PENDING",
	"id": "I-HM3SD1JSGGNM",
	"create_time": "2024-02-15T04:11:37Z",
	"links": [
		{
			"href": "https:\/\/www.sandbox.paypal.com\/webapps\/billing\/subscriptions?ba_token=BA-5NE174808K497913J",
			"rel": "approve",
			"method": "GET"
		},
		{
			"href": "https:\/\/api-m.sandbox.paypal.com\/v1\/billing\/subscriptions\/I-HM3SD1JSGGNM",
			"rel": "edit",
			"method": "PATCH"
		},
		{
			"href": "https:\/\/api-m.sandbox.paypal.com\/v1\/billing\/subscriptions\/I-HM3SD1JSGGNM",
			"rel": "self",
			"method": "GET"
		}
	]
}

I want to know the product ID and billing plan ID that was created previously

Like This:

{
	"billing_plan_id": "P-8VN97321HR2509310MXGY56A",
	"product_id": "PROD-0XP67721PM418662R",
	"status": "APPROVAL_PENDING",
	"id": "I-HM3SD1JSGGNM",
	"create_time": "2024-02-15T04:11:37Z",
	"links": [
		{
			"href": "https:\/\/www.sandbox.paypal.com\/webapps\/billing\/subscriptions?ba_token=BA-5NE174808K497913J",
			"rel": "approve",
			"method": "GET"
		},
		{
			"href": "https:\/\/api-m.sandbox.paypal.com\/v1\/billing\/subscriptions\/I-HM3SD1JSGGNM",
			"rel": "edit",
			"method": "PATCH"
		},
		{
			"href": "https:\/\/api-m.sandbox.paypal.com\/v1\/billing\/subscriptions\/I-HM3SD1JSGGNM",
			"rel": "self",
			"method": "GET"
		}
	]
}
@otnansirk
Copy link
Contributor Author

This makes it easy to see the plan_id that has been created directly, making it easy to save it into a local DB and use it to build many features.

for example changing the pricing scheme from a subscription that has been created.

@srmklive
Copy link
Owner

Already fixed #619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants