Friday, November 23, 2012

Payment Get-way with ASP.NET and Payaza (Previously AlertPay)


Payment get-ways are important when you are creating a web application for selling items. Here i'm using Payaza as the payment get-way (Previously well known as Alertpay). Many people develop payment get-ways using Paypal and this is also a similar application for that.


You can download a sample application from below link.
http://www.4shared.com/rar/ZQX_126a/PaymentGetway.html


Below image shows you hoe your application would look like when you run it.

















Once the user click on the "Buy Now" user will be redirected to his/her Payaza account for authentication. Once the user authenticate the payment will be done. Below is the screen where user will be redirected















This is a very simple process below you have the code where you need to include in your .aspx page. Payaza requires parameters to be passed in the request body and the hidden fields are named as it is required by Payaza. So do not change the hidden field names and you can change any other parameter. Below are some required parameters and others are optional.

ap_merchant - Merchant email the account where money will be deposited.
ap_purchasetype - This should be "item-goods" as payaza requires.
ap_itemname - Item name
ap_amount - Item price
ap_currency - Currency
ap_quantity - Quantity required
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Payment.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function LoadValues() {
            form1.ap_itemname.value = document.getElementById('lblItemName').innerHTML;
            form1.ap_amount.value = document.getElementById('lblAmount').innerHTML;
            form1.ap_quantity.value = form1.txtQuntity.value;
            form1.ap_itemcode.value = document.getElementById('lblItemCode').innerHTML;
            form1.ap_description.value = document.getElementById('lblDescription').innerHTML;
            form1.ap_taxamount.value = document.getElementById('lblTax').innerHTML;
            form1.ap_additionalcharges.value =document.getElementById('lblAdditional').innerHTML;
            form1.ap_shippingcharges.value = document.getElementById('lblShppping').innerHTML;
            form1.ap_discountamount.value = document.getElementById('lblDiscount').innerHTML;
        }
 </script>
 </head>
<body>
    <form id="form1" runat="server">

     <input type="hidden" name="ap_merchant" value="apdevforum@gmail.com"/>
    <input type="hidden" name="ap_purchasetype" value="item-goods"/>
    <input type="hidden" name="ap_itemname" value=""/>
    <input type="hidden" name="ap_amount" value=""/>
    <input type="hidden" name="ap_currency" value="USD"/>

    <input type="hidden" name="ap_quantity" value=""/>
    <input type="hidden" name="ap_itemcode" value=""/>
    <input type="hidden" name="ap_description" value=""/>
    <input type="hidden" name="ap_returnurl" value="http://www.example.com/thankyou.html"/>
    <input type="hidden" name="ap_cancelurl" value="http://www.example.com/cancel.html"/>

    <input type="hidden" name="ap_taxamount" value=""/>
    <input type="hidden" name="ap_additionalcharges" value=""/>
    <input type="hidden" name="ap_shippingcharges" value=""/>

    <input type="hidden" name="ap_discountamount" value=""/>
    <input type="hidden" name="apc_1" value="Blue"/>
    <br />
    <table>
        <tr>
            <td rowspan="11">
                <asp:Image ID="Image1" runat="server" Height="275px"
                    ImageUrl="~/switch-3-large.jpg" Width="257px" />
            </td>
            <td> Item Name:</td>
            <td><asp:Label ID="lblItemName" runat="server" Text="Bag"></asp:Label></td>
        </tr>
        <tr>
            <td>Currency:</td>
            <td>USD</td>
        </tr>
        <tr>
            <td>Amount:</td>
            <td><asp:Label ID="lblAmount" runat="server" Text="100"></asp:Label></td>
        </tr>
        <tr>
            <td>Quntity:</td>
            <td><asp:TextBox ID="txtQuntity" runat="server"></asp:TextBox></td>
        </tr>
        <tr>
            <td>ItemCode:</td>
            <td><asp:Label ID="lblItemCode" runat="server" Text="C001"></asp:Label></td>
        </tr>
        <tr>
            <td>Description:</td>
            <td><asp:Label ID="lblDescription" runat="server" Text="This is a Good Item"></asp:Label>          </td>
        </tr>
        <tr>
            <td>Tax:</td>
            <td><asp:Label ID="lblTax" runat="server" Text="10"></asp:Label></td>
        </tr>
        <tr>
            <td>Additional:</td>
            <td><asp:Label ID="lblAdditional" runat="server" Text="2"></asp:Label></td>
        </tr>
        <tr>
            <td>Shipping Charges:</td>
            <td><asp:Label ID="lblShppping" runat="server" Text="10"></asp:Label></td>
        </tr>
        <tr>
            <td>Discount:</td>
            <td><asp:Label ID="lblDiscount" runat="server" Text="2"></asp:Label></td>
        </tr>
        <tr>
            <td colspan="2">
    <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="https://www.payza.com/images/payza-buy-now.png"
     PostBackUrl="https://secure.payza.com/checkout" OnClientClick="LoadValues();" />
      </td>
        </tr>
    </table>
    <br />
    </form>
</body>
</html>




No comments:
Write comments
Recommended Posts × +