Jump to content

Automatically creating/signing in customers in WHMCS from external App


chateaux

Recommended Posts

Background:

-------------

I have used WHMCS for some webhosting products and like it and have decided to see if I can get it to work for a networking (similar to dating) application I am writing for fun. The application signs people up who do the usual things such as adding profiles / pictures / etc.

 

So I essentially have two sites that need to talk to each other:

 

1. My app - the business logic

2. WHMCS - support and payments

 

Here are some scenarios I need some clarity on:

 

Scenario 1:

------------

For a user to contact another member, they need a valid subscription which can be purchased via WHMCS. To do so they are diverted to the WHMCS site to pick the desired subscription.

 

At this point WHMCS requires the user to sign in or create an account, so my first question is this. Is it possible to automatically create an account in WHMCS, using the information from my app, and include a "custom field" such as my apps customer ID?

 

Is there a best practice for something like this?

 

Scenario 2:

------------

Assuming we can create a WHMCS account (and log them in) on the fly, the next question is this. When a user makes a payment via one of the payment options, (I am trialing with 2co) how do I go about telling my app that a successful purchase was made, since I will need to update its subscriptions and orders table?

 

I am assuming I need to create a custom module for this?

 

Scenario 3:

------------

On purchase complete, is there anyway to divert the customer back to the site from whence they came (not a biggie as the payment can be made in a new window (or iframe) which the customer can simply close).

 

Thank you in advance for any insights on this.

Link to comment
Share on other sites

Just to follow up on this, thought my research would help other members:

 

My first question was how do I create an account on WHMCS remotely and how do I log a user in to WHMCS from an external application. The answer it seems is surprisingly easy.

 

Step 1: Wrote a simple php class to do all the things the WHMCS API offers.

Step 2: Think logically:

 

My APP is the dog, WHMCS is the tail

 

The one thought was to create an account on WHMCS when a user registers with the site. This I think is overkill as only a small percentage of users will become paying members or need support. So I have opted not to do this.

 

If users want support they can create their own account manually on WHMCS directly or log into a pre-existing account. This does not effect how my app works with WHMCS.

 

I only start to focus on WHMCS data when a user decides to make a payment from my app and is diverted to WHMCS. In order to make a connection between the WHMCS account and the APP account, the application must take control of this process and using the whmcs API and do a couple of checks before setting a session for the user on WHMCS.

 

Using:

1. ADD CLIENT

2. GET CLIENTS DETAILS

 

Step1: Check to see if a whmcs ID exists in my APP - if so, grab the details from WHMCS and log them in (set the session). If not:

Step2: Check to see if the users email exists in WHMCS, if so, update the customers WHMCS ID, and log them in. If not:

Step3: Create an account in WHMCS, using the customers APP details, and log them.

 

I was initially concerned that the user may change details from the wHMCS side and this would cause problems however I have come to realise that the tail does not wag the dog and that all my app needs is the correct WHMCS customer ID to serve the customer...

 

Will post how I get WHMCS to talk back to my app once that is done.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated