Voguepay payment gateway for Exp:resso Store for ExpressionEngine

November 8th, 2012 by Sean Leave a reply »

I have just written a little extension for the Exp:resso Store extension for ExpressionEngine. It’s not a lot of code but, once again, opens the door for people in Nigeria to actually take payments via their website. This time it’s for EspressionEngine and not for WordPress, my CMS of choice.

It’s fairly simple to add but does require you FTP the flies up to the site. Now for the rest of this I am going to assume that you know how to use FTP and know where your ‘store’ directory is. ExpressionEngine isn’t something I use regularly so I shall stick to the  integration instructions for the moment.

Download

ExpressionEngine VoguePay module for Exp:resso Store (824 bytes)

Upload it to the following path:

expressionengine/third_party/store/ci-merchant/libraries/merchant/merchant_voguepay.php

File Changes

You need to edit the language file (I shall assume english in this case) to kind of register the gateway. Only two line additions for you to be aware of.

expressionengine/third_party/store/ci-merchant/language/english/merchant_lang.php

Add the following into the main array:

‘merchant_voguepay’ => ‘VoguePay’,
‘merchant_id’ => ‘VoguePay Merchant ID’,

The Code

For those interested this is the module itself.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Merchant_voguepay extends Merchant_driver {
 public function default_settings() {
 return array(
 'merchant_id' => '',
 );
 }
public function purchase() {
 $request = array();
 $request['v_merchant_id'] = $this->setting('merchant_id');
 $request['merchant_ref'] = $this->param('order_id');
 $request['memo'] = $this->param('description');
 $request['total'] = $this->amount_cents();
 $request['success_url'] = $this->param('return_url');
 $request['fail_url'] = $this->param('return_url');
$this->post_redirect($this->_process_url(), $request, 'Redirecting.. please wait.');
 }
public function purchase_return() {
 if ($transaction_id = $this->CI->input->post('transaction_id')){
 if (@$_SERVER['HTTP_USER_AGENT'] == 'VoguePay server to server') {
 die();
 }

 $json = file_get_contents('https://voguepay.com/?v_transaction_id=' . $transaction_id . '&type=json');
 $transaction = json_decode($json, true);

 if ($transaction['transaction_id'] == '') {
 return new Merchant_response(Merchant_response::FAILED, lang('merchant_invalid_response'));
 } else if ($transaction['status'] != 'Approved') {
 return new Merchant_response(Merchant_response::FAILED, lang('merchant_payment_failed'));
 } else {
 $amount = $this->CI->input->post('total');
 return new Merchant_response(Merchant_response::COMPLETE, NULL, $transaction_id, $amount);
 }
 } 
 }
private function _process_url() {
 return 'https://voguepay.com/pay/';
 }
}
?>

This plugin was sponsored by Lagos Labs, a web design company based in Nigeria. You can demo their example implementation at http://www.lagoslabs.com/store/

5 comments

  1. VoguePay says:

    I am excited by your interest in the VoguePay platform. Great work Sean

  2. Lincoln says:

    Hola Sean, thanks for the assist! In case any Nigerian client needs a e-commerce solution with this combo (expressionengine + voguepay payment processor) just get in contact with us at http://www.lagoslabs.com.

  3. Utibe Etim says:

    This is awesome Sean, I will get in touch with you for similar project

Leave a Reply