.NET API into WordPress Front End

It’s absolutely unholy.  .NET Standard with a WordPress front end!?  Yes, it’s possible.  This odd concoction happened when the front-end developer hired claimed he could consume/operate his design around any language, but actually could only produce WordPress websites.  My solution was to use a .NET Core API on top of our product database (MSSQL) and then write my own PHP WordPress Plugin that would list products by product line and then another plugin to display the products clicked in that product line.  All products are maintained in another .NET Core app that allows for the products to be centralized in one spot while the front end design can be just about anything.

To walk through how I did this,  I’ll start with the creation of the .NET Core API.

Continue Reading

PHP/Curl SSL Certificate Error with Payeezy

As I work toward syncing our as400 to our payment gateway, I’ve encountered an error both in PayTrace and Payeezy sample codes, generally when making a JSON post with Curl in PHP.

The error:

ssl certificate problem: self signed certificate in certificate chain

Almost ALL documentation / research on this suggests you turn off Curl verification (CURLOPT_SSL_VERIFYPEER off)  and yes, it works, but it’s just not an option when I’m trying to secure my server for payment transactions.

Continue Reading

PayTrace Client Side Encryption (PHP / IIS)

This is a quick for-developers-only guide of how to get your PHP/JS code (Windows) talking to PayTrace’s API.  I chose the Client Side Encryption as being our first time out, I wanted the least amount of strictness in PCI compliance.   This guide assumes you know PHP, JS, JQuery, a little of what an API does, enough to paste some JSON together and of course your HTML, CSS, etc.   You’re a developer, you have all the code provided open source, but this is a quick A-B-C of what code I used and how I got it working on Windows (IIS7) and hurdles I ran into.

All code here is readily available on GitHub, but if you’d like my version of it, download it on my Gist.

Continue Reading

Connecting to and Calling An AS400 Program with i5_toolkit

I’m starting to document some of the ways I’ve begun to use Aura’s EasyCom i5 Connect package to connect PHP to our as400. This has been a long process of trying to webify some of our programs and get the information out.  (btw, we’re a small business and yearly the package is about $600 – very, very reasonable.)

Currently, we have a webserver (Windows Server) that hosts our website. On it, we installed the required Aura software (a Windows exe GUI and a PHP extension) to connect to our as400. The PHP pages then utilize that PHP extension to make calls to our as400. On our as400 side, our programmer created small programs to access the larger programs we need. So, I pass say 3 parameters via PHP, make a call via Ericom i5, and then the RPG does the brainwork. It passes back my requested parameters and sets up a datafile I can query using basic ODBC and mySQL. We may change this in the future, but we like the logic work taking place in RPG on the as400 (where all our data resides anyway) and PHP being the fetcher of such data.

So, first up,  here’s how I connect to the as400 (after initial setup):

	*  AS400 Management
		// connect to the iSeries / prepare for procedure call - port can be set up thru Aura GUI
		// keeping username and password in session to be able to connect to as400 as needed
		function i5_conn_AS400(){
			$conn = i5_connect('as400.mydomain.com:9999', $_SESSION['CONN_USER'], $_SESSION['CONN_PASSWORD']);

			if (!$conn) {
				$error = i5_error();
				echo " Error during connection\n";
				echo "<BR> Error number: ".$error["num"];
				echo "<BR> Error category: ".$error["cat"];
				echo "<BR> Error message: ".$error["msg"];
				echo "<BR> Error description: ".$error["desc"];
				trigger_error("I5 connection fails", E_USER_ERROR);
			return $conn;

Then, here’s the preparation of parameters and call to the as400:

/* Set the Value of the Parameters */
$desc = array (
array ("name"=>"PARM1", "io"=>I5_INOUT, "type"=>I5_TYPE_CHAR, "length"=> 50),
array ("name"=>"PARM2", "io"=>I5_INOUT, "type"=> I5_TYPE_PACKED, "length"=> "8.0"),
array ("name"=>"PARM3", "io"=>I5_INOUT, "type"=>I5_TYPE_CHAR, "length"=> 1)

$prog = i5_program_prepare("PGMLIB/WEBLIB", $desc);

if ($prog === FALSE) {
$errorTab = i5_error();
echo "Program prepare failed <br>\n";

/* Execute Program */
$params = array ("PARM1"=>$sessID,"PARM2"=>$PARM2,"PARM3"=>$PARM3);
$retvals = array ("PARM1"=>"PARM1","PARM2"=>"PARM2","PARM3"=>"PARM3");

$ret = i5_program_call($prog, $params, $retvals) ;

if (!$ret){
trigger_error("i5_execute error : ".i5_errormsg(), E_USER_ERROR);

$ret = i5_program_close ($prog);

if (!$ret){
trigger_error("i5_program_close error : ".i5_errormsg(), E_USER_ERROR);

I’ve actually created a connection “class” for both the Aura i5 connect and the odbc connect. That way when needed, I can simply call a function and connect to each as needed. I’m still VERY new to this all (and I just learned PHP), but figure I’d document some of this process as I go along. I have two sites currently running on this logic.

Continue Reading