Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,224 members, 7,822,138 topics. Date: Thursday, 09 May 2024 at 07:16 AM

Add Vorguepay Online Payment System To Your Website - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Add Vorguepay Online Payment System To Your Website (1138 Views)

Online Payment Plugin For Wordpress1 / How Do I Link An Online Payment To My Account / Payment System Integration Webpay(interswitch) With Php (2) (3) (4)

(1) (Reply) (Go Down)

Add Vorguepay Online Payment System To Your Website by pumpindkay(m): 8:12pm On Feb 23, 2015
Please I need your help on how to credit user account balance on my website after a successful payment through vorguepay.
Something like this:
if (payment = success){
User_balance += amount paid;
}
Please tell me the steps/algorithm to follow
Re: Add Vorguepay Online Payment System To Your Website by blenyo11(m): 11:22am On Feb 24, 2015
Using which language
Voguepay sends you a POST request to your supplied notification URL. You can use the transaction_id in the POST variable the get the translation details from https://voguepay.com/ and take what ever action you want based on the returned value.
The function below is a notification action of my controller

function notification(){
$activePage = 'transactions';

$this->loadModel('transaction');
$this->loadModel('user');

if(isset($_POST['transaction_id'])){

//get the full transaction details as an json from voguepay
$json = file_get_contents('https://voguepay.com/?v_transaction_id='.$_POST['transaction_id'].'&type=json');
//create new array to store our transaction detail
$transaction = json_decode($json, true);

$tran = new Transaction($transaction['merchant_ref']);

if($transaction['total'] == 0)
{
$tran->Status = 'Invalid total';
$tran->Save();
die('Invalid total');
}
if($transaction['status'] != 'Approved'){
$tran->Status = 'Failed transaction';
$tran->Save();
die('Failed transaction');
}


if($tran->Amount != $transaction['total']){
$tran->Status = 'Invalid total';
$tran->Save();
die('Invalid total');
}

$credit = $tran->Unit;
$success = $this->deductAccount($credit);
if($success == '1'){
$user = new User($tran->LoginId);
$user->Balance += $credit;
$user->Save();

$tran->Status = 'Completed';
$tran->Save();
}else{
$tran->Status = 'Payment made. Insufficient master balance';
$tran->Save();

}
}
}


You should copy to a good editor to have a better formatting for readability
Re: Add Vorguepay Online Payment System To Your Website by pumpindkay(m): 4:30pm On Feb 24, 2015
thanks for the reply.
I am working in .net environment. I need it in either c# or vb.net
Re: Add Vorguepay Online Payment System To Your Website by blenyo11(m): 10:38pm On Feb 24, 2015
Next time try to specify the language in which you need help
I didn't test this but it should be pointer to the right direction for you

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
public partial class Notification : Page
{
protected void Page_Load(object sender, EventArgs e)
{
var url = "https://voguepay.com/?v_transaction_id=" + Request.Form["transaction_id"] + "&type=json";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Method = "GET";
httpWebRequest.ContentType = "application/json";

//getting the respounce from the request
var httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
var responseStream = httpWebResponse.GetResponseStream();
var streamReader = new StreamReader(responseStream);
var response = streamReader.ReadToEnd();

var tran = (Transaction)Newtonsoft.Json.JsonConvert.DeserializeObject(response, typeof(Transaction));

var tran_ref = "some id from database";//This should be gotten from a db or so
if (tran.merchant_ref != tran_ref)
{
//invalid transaction
//this may have come from a man in the middle attacker
}

if (tran.total == 0)
{
//invalid amount
return;
}

if (tran.status == "Aproved" )
{
//transaction succeded
//perform action
}
}


class Transaction
{
public string status { get; set; }

public double total { get; set; }

public string merchant_ref { get; set; }
}
}
}

(1) (Reply)

Is Delphi Faster Than C# / Ahbeg It's Very Urgent... Who Could Help Me? / My Facebook Account Has Been Hacked

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.