I was reading @mconsidine post about using the PHP PaymentGateway. Nice job.
I think I might be needing to do this with Authorize.Net so I adapted what was there based on Matt’s example.
<?php
global $modx;
$base_dir = $modx->config['rb_base_dir'];
$dbname = $modx->db->config['dbase'];
$dbprefix = $modx->db->config['table_prefix'];
$mod_table = $dbprefix."manager_shopkeeper";
$mod_config_table = $dbprefix."manager_shopkeeper_config";
$reportTpl = $_SESSION['reporttpl'] ? $_SESSION['reporttpl'] : $fields['reportTpl'];
$userLogged = isset($_SESSION['webValidated']) ? true : false;
//Get online payment info
$order_id = $_SESSION['shk_order_id'];
$fields['payment'] = $_SESSION['shk_payment_method'];
$price = $_SESSION['shk_order_price'];
$currency = $_SESSION['shk_currency'];
$userId = $_SESSION['shk_order_user_id'];
$order_email = $_SESSION['shk_order_user_email'];
require_once $base_dir."snippets/payment/PaymentGateway.php";
require_once $base_dir."snippets/payment/Authorize.php";
// Create an instance of the authorize.net library
$myAuthorize = new Authorize();
// Specify your authorize.net login and secret
$myAuthorize->setUserInfo('YOUR_LOGIN', 'YOUR_KEY');
// Specify the url where authorize.net will send the user on success/failure
$myAuthorize->addField('x_Receipt_Link_URL', 'http://www.google.com');
// Specify the url where authorize.net will send the IPN
$myAuthorize->addField('x_Relay_URL', 'http://www.google.com/working_on_this_part');
// Specify the product information
$myAuthorize->addField('x_Description', "Online order from " . $modx->config['site_name']);
$myAuthorize->addField('x_Amount', $price);
$myAuthorize->addField('x_Invoice_num', $order_id);
$myAuthorize->addField('x_Cust_ID', $order_email );
// passing customer info
$myAuthorize->addField('x_first_name', $_SESSION['shk_order_user_fname']);
$myAuthorize->addField('x_address', $_SESSION['shk_order_user_address']);
$myAuthorize->addField('x_city', $_SESSION['shk_order_user_city']);
$myAuthorize->addField('x_state', $_SESSION['shk_order_user_state']);
$myAuthorize->addField('x_email', $_SESSION['shk_order_user_email']);
// Enable test mode if needed
$myAuthorize->enableTestMode();
// Let's start the train!
$myAuthorize->submitPayment();
return true;
?>
But to get the customer information to the gateway I had to modify
shopkeeper.inc.php and added
// customer payment information
$_SESSION['shk_order_user_fname'] = $fields['name'];
$_SESSION['shk_order_user_address'] = $fields['address'];
$_SESSION['shk_order_user_city'] = $fields['city'];
$_SESSION['shk_order_user_state'] = $fields['state'];
// end add on
Is there a better way with out modifying the source?
After that I need to get the IPN to change the status of the order to paid.