User:Chughakshay16/paymentworkflow

From mediawiki.org
Jump to navigation Jump to search

This page goes over the basic details of a payment gateway(using paypal) ,that would be implemented for the ConventionExtension .

Basic Workflow[edit]

1. after user fills the registration information , he would be redirected to the paypal payment page.
2. and depending on if the transaction was successfully carried out , user would be directed to his/her user page(modified user page displaying the order made by the user)or the "Transaction Failed" page.
3. the success script that would run on the completion of transaction would store the details in the registration(wiki page) and the transactions table.

Sample Code :

class ConferencePaypalGateway
{
private $paypal_url='https://www.paypal.com/cgi-bin/webscr';
private $business_id;// this is the paypal_id of the account made for the conference transactions
public function getForm()
{
/**
*
*/
<form action='<?php echo $paypal_url; ?>' method='post' name='registrationForm;'>
<input type='hidden' name='business' value='<?php echo $business_id; ?>'>
<input type='hidden' name='cmd' value='_xclick'>
<input type='hidden' name='amount' value=''>//price for the registration
<input type='hidden' name='no_shipping' value='1'>
<input type='hidden' name='currency_code' value='USD'>
<input type='hidden' name='cancel_return' value=''>//value = script to run if transaction has failed 
<input type='hidden' name='return' value=''>//value = script to run if transaction has succeeded
<input type="image" src="https://paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" name="submit">
</form> '
}

//success script
<?php
session_start();
global $wgRequest;
$uid = $wgRequest->getSession('uid');
$username=$wgRequest->getSesstion('username');
$item_transaction = $wgRequest->getVal('tx'); // Paypal transaction ID
$item_price = $wgRequest->getVal('amt'); // Paypal received amount
$item_currency = $wgRequest->getVal('cc'); // Paypal received currency type
// and fetch some other registration related details
// creates a new registration page and corresponding to that page_id stores transaction details in transactions table
if(/**the transaction information is properly stored*/)
{
echo "<h1>Welcome, $username</h1>";
echo "<h1>Payment Successful</h1>";
}
}
else
{
echo "Payment Failed";
}
?>

//failure script
<?php
session_start();
global $wgRequest;
$username=$wgRequest->getVal('username');
echo "<h1>Welcome, $username</h1>";
echo "<h1>Payment Canceled</h1>";
?>