[eluser]darkhouse[/eluser]
I really like Bean Stream, their system is pretty simple. Here's a library we use for them.
Code:
<?php
if( !defined('BASEPATH') )
exit('No direct script access allowed');
class Beanstream
{
var $CI = null;
// PROD merchant ID
// var $merchant_id = 'xxx'; //put your production merchant id here
// DEV merchant ID
var $merchant_id = 'xxx'; //put your development merchant id here
function Beanstream()
{
$this->CI = &get;_instance();
}
function ProcessPayment($orderNumber, $amount, $cardOwner, $cardNumber, $expMonth, $expYear, $email, $name, $phone, $address1, $address2, $city, $provinceCode, $postalCode, $countryCode)
{
$pf = array(
'requestType=' . urlencode('BACKEND'),
'merchant_id=' . urlencode($this->merchant_id),
'trnOrderNumber=' . urlencode(sprintf('d', $orderNumber)),
'trnAmount=' . urlencode($amount),
'trnCardOwner=' . urlencode($cardOwner),
'trnCardNumber=' . urlencode($cardNumber),
'trnExpMonth=' . urlencode(sprintf('d', $expMonth)),
'trnExpYear=' . urlencode(sprintf('d', substr($expYear, -2))),
'ordEmailAddress=' . urlencode($email),
'ordName=' . urlencode($name),
'ordPhoneNumber=' . urlencode($phone),
'ordAddress1=' . urlencode($address1),
'ordAddress2=' . urlencode($address2),
'ordCity=' . urlencode($city),
'ordProvince=' . urlencode($provinceCode),
'ordPostalCode=' . urlencode($postalCode),
'ordCountry=' . urlencode($countryCode)
);
$post_str = implode('&', $pf);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, "https://www.beanstream.com/scripts/process_transaction.asp");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_str);
$txResult = curl_exec($ch);
curl_close($ch);
$response = array();
parse_str($txResult, $response);
return $response;
}
}
And then usage in a controller is just like this:
Code:
$txnResult = $this->beanstream->ProcessPayment(
$your_order_number,
$total,
$cardholder,
$cc_number,
$exp_month,
$exp_year,
$email,
$first_name.' '.$last_name,
$phone,
$address,
$address2,
$city,
$province,
$postal,
$country
);
if($txnResult['trnApproved']){
//process data and display receipt/thank you page
} else {
$error = $txnResult['messageText'];
//display error
}
Good luck.