NetSuite-Magento-Paystand Integration Notes

Paystand is NOT a traditional payment gateway. It actually goes beyond that. It interacts directly with both NetSuite and Magento. An example: When a sales order is created in Magento and paid for using Paystand, a customer deposit is entered directly in NetSuite (and associated with the sales order in NetSuite) by Paystand. It’s awesome!

The Paystand bundle was initially installed in our provision of NetSuite by Paystand’s staff. We gave them access and they got it working. It was great. That was years ago. So earlier this year, we needed to do the same with Magento.

Paystand offers what they call a “Standard Plugin” for Magento. With this plugin in place, when a sales order is created in Magento and paid for via a credit card, the card is taken via an iFrame served from a Paystand server in the cloud. Once the payment posts, the payment details are appended to the sales order in Magento. It’s awesome.

With some additional customizations, Paystand will take this a step further and enter a customer deposit into NetSuite. This is where we ran into a LOT of confusion. Hopefully these notes will clear that up, for anyone including myself that ever needs to do this again.

To save time, I’m not going to tell you all the things that took us off track. I’m simply going to tell you how we did our “customizations”.

For starters, everything can be done from the NetSuite side. Our final solution included a very simple mod to Magento, whereby a new sales order triggered a RESTful API call back to NetSuite to start replicating the sales order in NetSuite. This could just as easily be done on a schedule, where a scheduled script wakes up on an interval and queries Magento for new sales orders.

Notes about the sales order in NetSuite… It MUST have the same total as the sales order in Magento. More on that in a second. One thing Paystand is not good at is acknowledging errors. If you break a rule, anything, no errors are thrown. One of the rules: A payment must be less than or equal to the NetSuite sales order’s grand total. Otherwise, it will be considered an overpayment.

So… the integration… Here’s the “How to” in a nutshell. For starters, you’ll need to get a connection to Magento. See my post on that subject:
https://followingnetsuite.wordpress.com/2023/06/07/netsuite-magento-integration-made-easy/

Next, you’ll need the security tokens from your Paystand dashboard. You’ll find these values filled in in the Integration tab of your dashboard.

Use the Magento API to get a copy of the sales order in Magento. As you can see, the response is robust! It’s got everything.

Create the matching sales order in NetSuite and get it’s Internal ID. The payment section of the Magento sales order (after some time) will contain the Paystand payment ID. My example above was not a credit card payment (but a purchase order).

In our integration, we opted to use the Paystand API to get the payment ID directly from Paystand, without waiting for it to show up in the Magento sales order. The key to this is using the Magento quote_id. It is present in both the Magento sales order and the Paystand Payment. Matching the two produces a hard link between the sales order in Magento and the payment in Paystand.

Since you just created the new sales order in NetSuite, you’ve got all you need to make the association with Paystand. Here’s how that’s done.

Request an access token from the Paystand API.

Use the token you just got back in the subsequent request. In Postman, I saved the token in the Authorization tab of the workspace. It could have gone directly into the “Assign Payment to Sales order” request header. Doing it this way is a good practice.

And finally, submit your request to associate the payment taken in Magento, with the sales order created in NetSuite.

Here are the other headers entered directly in the “Assign Payment to Sales Order” request. I know, I just broke my own “Good practice” recommendation.

The response to this is one of two things, and I’ve made Paystand aware. Either it returns a security violation, in which case your token has expired or you’ve connected to the wrong website (there is one letter different between the production and sandbox Paystand URLs), or you get a string that says “true.” If you get “true”, it is not a guarantee that it succeeded. Problem!

One other bit of info that took us off track: We were initially told that we could not use Postman to make API calls to Paystand. This violated PCI compliance. Calling the Paystand API from outside your staging or production website would accept the call, but not honor it, doing nothing. This lead us to believe that all calls to Paystand must come from within Magento. This is absolutely not true! All of my Postman examples work (including creating and fetching a single payment) in both production and sandbox Paystand implementations.

In Summary: If you familiarize yourself with both the Magento and Paystand APIs, it’s a relatively simple task to integrate sales orders and payments between NetSuite and Magento. This article gives any decent developer enough info to do the integration in a couple of days. This is far less than it took my team and far less than we were told to expect by Paystand. It’s just not that complicated, which is a good thing.

Leave a comment