Using Infusionsoft user credentials with default Laravel Auth

Hello to the Infusionsoft community,

I’m new to these forums, we’re working on our 1st Infusionsoft integration project.

Our client is moving away from Memberium and Wordpress.

Memberium has a lot of features they don’t use and they wanted to scale up and move away from Wordpress so they chose Laravel.

They already had 500+ subscribers (3 products, monthly payments) using Memberium and those pre-existing users need to be able to log into the new app along with the new users who will be signing up.

Laravel’s default auth scaffolding is safe enough, we’re trying to import the pre-existing users so that they become the Laravel app’s users, and have the ability to add new users via a signup flow.

I reckon both the REST and the XML-RPC methods can be used if we use Oauth.

I suppose the new signups can be handled with a form embedded in an iframe, which then pushes them to a payment page where Infusionsoft eCommerce handles the payment.

This is all the functionality we need to develop:
• Old users from Memberium login with theis pre-existing credentials into the Laravel app via the default Laravel auth.

• Users can update payment / credit card info in the webapp, push changes into Infusionsoft.
• Users can cancel their membership from the webapp

Most of the website’s content will be locked behind the login gate, but that is simple enough to do.
Once users are logged in, they see the private pages, otherwise all they can see is an about page & contact page, both of which promt them to sign up or log in.

We’ll extend from here.


Please advise and share some guidane on how this can be done, we’re read some mixed things regarding the API calls.

Do we need to export the user’s email & password who are subscribed to the relevant products then save it to a table that the Laravel app will use as it’s users table?

Can we list all users subscribed to a specific productID, then extract theis username & password to store it in a table?

Is any of these doable via REST or is it better to use the XML-RPC API for this?

This Q&A says pulling the username/email and password via REST is not possible

This one says cancelling the membership this way is not possible yet with REST.

Please shed some light on how these simple functionalities can be performed and what API is the best to use it with.

This is our very first Infusionsoft integration project, but we’re planning to do much more :slight_smile:

Hi @Balazs_Pati, there are a few different parts of your integration so I’ll answer them individually.

Authentication

You’re correct that contact username/password fields are not available via the REST API. We are encouraging developers to move away from storing credentials inside of Infusionsoft using these legacy fields. For purposes of migration, I would suggest querying Infusionsoft on login of an existing user to verify their existing credentials. You would do this by loading the contact record and comparing the user/pass to what they provided to you.

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.load</methodName>
  <params>
    <param>
      <value><string>{{privateKey}}</string></value>
    </param>
    <param>
      <value><string>Contact</string></value>
    </param>
    <param>
      <value><int>{{contactId}}</int></value>
    </param>
    <param>
      <value><array>
        <data>
          <value><string>Username</string></value>
          <value><string>Password</string></value>
        </data>
      </array></value>
    </param>
  </params>
</methodCall>

Alternatively if you’re not keeping track of the contactId, you can query the contact table using the provided username like this.

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.query</methodName>
  <params>
    <param>
      <value><string>{{privateKey}}</string></value>
    </param>
    <param>
      <value><string>Contact</string></value>
    </param>
    <param>
      <value><int>10</int></value>
    </param>
    <param>
      <value><int>0</int></value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>Username</name>
            <value><string>{{username}}</string></value>
          </member>
        </struct>
      </value>
    </param>
    <param>
      <value>
        <array>
          <data>
            <value><string>Username</string></value>
            <value><string>Password</string></value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>

Once you’ve verified they are an existing user, I would prompt them to change their password and use Laravel Auth going forward for that user. New users should authenticate against Laravel Auth and never have their credentials inside of Infusionsoft.

Lastly, you could do what you suggested and export all username and passwords from Infusionsoft along with the contactId and import them into the Laravel app to use. I would still recommend having users enter a new password when they log in for the first time with the new system.

In order to verify that the contact has an active subscription, you could do something like this.

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.query</methodName>
  <params>
    <param>
      <value><string>{{privateKey}}</string></value>
    </param>
    <param>
      <value><string>RecurringOrder</string></value>
    </param>
    <param>
      <value><int>10</int></value>
    </param>
    <param>
      <value><int>0</int></value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>ContactId</name>
            <value><int>{{contactId}}</int></value>
          </member>
          <member>
            <name>ProductId</name>
            <value><int>{{productId}}</int></value>
          </member>
        </struct>
      </value>
    </param>
    <param>
      <value>
        <array>
          <data>
            <value><string>Status</string></value>
            <value><string>ProductId</string></value>
            <value><string>SubscriptionPlanId</string></value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>

Alternatively, there are rest hooks for subscriptions so you could keep track of the subscription status in your system and listen for when new subscriptions are added or edited to adjust the status on your system.

Update Credit Card Info

We don’t allow modification of existing credit card records but for your purposes you could use DataService.add to add a new credit card. Then you would need to update the RecurringOrder table to use the newly created credit card record by updating the field CC1.

Cancel Membership

As the post you linked to indicates, there isn’t a way to update subscriptions via the REST API. However, updating the record via XML-RPC (RecurringOrder table) would be sufficient. As a best practice, I would recommend setting Status to Inactive, EndDate to today (or whatever your business logic dictates), and AutoCharge to 0.