Automattic / wp-calypso

The JavaScript and API powered WordPress.com
https://developer.wordpress.com
GNU General Public License v2.0
12.41k stars 1.98k forks source link

Marketplace: Product Licensing - Implement API route for getting subscription information #65347

Closed gavande1 closed 2 years ago

gavande1 commented 2 years ago

Summary

We need to create a WPCOM API through which vendors can get the subscription details (status, dateStart, dateEnd for a specific product & site. The GET an endpoint will include the siteUrl, productSlug in the URL.

Related to pdh6GB-1dL-p2#comment-1951

gavande1 commented 2 years ago

We need to implement route which will accept primary domain and product slug as URL parameter. The endpoint will return following fields as response;

Let's start with following fields and revisit them if needed.

obenland commented 2 years ago

Would active always be 1? Or will this endpoint also return inactive subscriptions?

gavande1 commented 2 years ago

Yes. active will be always 1 since we will looking for active subscriptions only.

obenland commented 2 years ago

How would you feel about dropping that field then? It feels redundant if it never changes.

obenland commented 2 years ago

In pdh6GB-1dL-p2#comment-2028 @cpapazoglou said that most 3PD need license type 2—could we select one or two of those and ask them what kinds of fields they'd expect/needed when querying this endpoint?

allilevine commented 2 years ago

In pdh6GB-1dL-p2#comment-2028 @cpapazoglou said that most 3PD need license type 2—could we select one or two of those and ask them what kinds of fields they'd expect/needed when querying this endpoint?

List of plugins we're talking to and license type (linked here): pdh6GB-TH-p2#comment-2236

gavande1 commented 2 years ago

How would you feel about dropping that field then? It feels redundant if it never changes.

@cpapazoglou, I am okay with dropping active field. Do you have any strong reason to keep it?

gavande1 commented 2 years ago

During our discussion in Slack, the team suggested that we should have wpcom/v2/vendor/subscriptions/SITE_DOMAIN/PRODUCT_SLUG route instead of wpcom/v2/marketplace/subscriptions/SITE_DOMAIN/PRODUCT_SLUG route for getting subscription information.

cpapazoglou commented 2 years ago

@cpapazoglou, I am okay with dropping active field. Do you have any strong reason to keep it?

I was thinking that we maybe show inactive ( expired / canceled ) subscriptions too, mainly for historical / debugging reasons. But I feel that it might derail us from the time being. We can drop it for now, and add it in a v2 version of the endpoint.

gavande1 commented 2 years ago

Diff created at: D84675-code

obenland commented 2 years ago

Over in https://github.com/Automattic/wp-calypso/issues/65348 we've been discussing Swagger as a docs engine. While I don't think we've committed to a path forward there yet, creating a separate API namespace for marketplace endpoints would make it easier to only show docs for those endpoints with the Swagger plugin. It might also be nice to have a bit of separation for external vendors etc.

marketplace/v1? Something more namespaced to dotcom?

gavande1 commented 2 years ago

I was thinking about the same from beginning. However, I was bit sceptical since it will create entire new namespace for the api. So +1 for marketplace/v1.

cpapazoglou commented 2 years ago

We wanted to avoid marketplace term since we are probably renaming to WordPress.com Store. Marketplace is an internal term only. Using a store namespace is not very clear though, and marketplace namespace isn't something that customer are seeing so I think we can go on with marketplace/v1.

obenland commented 2 years ago

It looks like marketplace is already used in the wpcom/v2/marketplace/products/ endpoint (2cfa1-pb/#plain). Maybe it would make sense to create a marketplace folder to denote that namespace and move those endpoint files there?

gavande1 commented 2 years ago

marketplace/v1? Something more namespaced to dotcom?

I had brief discussion on slack with Barry about introducing new namespace for marketplace. It seems they advised against it and asked us if we could implement new routes under /rest/ namespace.

Slack Convo Link: p1658895973548579-slack-C02AVAR9B

gavande1 commented 2 years ago

Deployed r249744-wpcom behind a11n check.

obenland commented 2 years ago

Based on the docs in 2d01d-pb/#plain I think we should continue to create them in v2. Using the wpcom/v2 namespace won't be the end of the world.

gavande1 commented 2 years ago

Agreed. TBH I was looking for the this docs when Barry asked how did you end up having this namespace? IIRC, I followed this docs when I first created /marketplace/products endpoint.