Skip to Content Skip to Menu

Subscription Licence Key

  • pastoweb
  • pastoweb
  • OFFLINE
  • Posts: 163
  • Thanks: 11
  • Karma: 0
3 years 10 months ago #322680 by pastoweb
Subscription Licence Key was created by pastoweb
Hi, I'd like to automatically generate a unique licence number or code when a user pays for a plan subscription.
It will be the user "membership number" or "licence", to be used i.e to possibly generate a membership card or badge, or to be called through a webservice to verify if the user subscription is still valid

Any idea?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
3 years 10 months ago - 3 years 9 months ago #322690 by krileon
Replied by krileon on topic Subscription Licence Key
Probably easiest way is a custom database table to store your unique ids then use CBSubs SQL Actions to insert a new row when they subscribe. You can generate the unique ids using the UUID() MySQL function. Alternative is CB Auto Actions and a Code action and use PHP to do this.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 3 years 9 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • pastoweb
  • pastoweb
  • OFFLINE
  • Posts: 163
  • Thanks: 11
  • Karma: 0
3 years 9 months ago #322973 by pastoweb
Replied by pastoweb on topic Subscription Licence Key
Thanks, probably we don't really need a different licence number. We need to be able to check a subscription valitdity fron an external woocommerce website, so we could try to work on that side.
I'm thinking to develop a woocommerce plugin that checks the subscription status by its ID and username: do you think it's feasable?
Do joomla/CB provide any webservice to support this kind of integration?

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
3 years 9 months ago - 3 years 9 months ago #322990 by krileon
Replied by krileon on topic Subscription Licence Key

I'm thinking to develop a woocommerce plugin that checks the subscription status by its ID and username: do you think it's feasable?

Yes, I suppose that's doable.

Do joomla/CB provide any webservice to support this kind of integration?

Not out of the box, but you can create custom API endpoints using CB Auto Actions. Example of how do this is as follows.


Global
Triggers: None
Type: Code
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Custom > Value
Custom Value: [get_key]
Operator: Equal To
Value: API_KEY_HERE
Condition 2
Field: Custom > Value
Custom Value: [get_plan]
Operator: Not Empty
Action
Method: PHP
Code:
Code:
$planId = (int) '[get_plan]'; $isActive = false; foreach ( cbpaidSomethingMgr::getAllSomethingOfUser( $user ) as $subscriptions ) { foreach ( array_keys( $subscriptions ) as $k ) { if ( $subscriptions[$k]->getPlan()->get( 'id' ) != $planId ) { continue; } $isActive = true; break 2; } } return array( 'active' => $isActive );
Output
Display: JSON

You'd then call the below URL from your custom woocommerce plugin.

Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&users=USER_ID_HERE&plan=PLAN_ID_HERE&key=API_KEY_HERE&format=raw

Be sure to replace ACTION_ID_HERE, USER_ID_HERE, PLAN_ID_HERE, and API_KEY_HERE. If you only have username and not user id then use the below.

Code:
index.php?option=com_comprofiler&view=pluginclass&plugin=cbautoactions&action=action&actions=ACTION_ID_HERE&username=USERNAME_HERE&plan=PLAN_ID_HERE&key=API_KEY_HERE&format=raw

You'll need to make the following changes so the auto action can build User from username.

Global
User: Code
Code
Code:
return \CBuser::getUserDataInstance( 0 )->loadByUsername( '[get_username]' );

Note the above has not been tested. It is purely an example and may require adjustments.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 3 years 9 months ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum