in

AlertPay Developers Community

Buy Now Button Without a Specific Quantity

Last post 12-02-2008 1:29 PM by AlertPay_Phoun. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 12-02-2008 12:09 PM

    Buy Now Button Without a Specific Quantity

    Problem:

    User can not specify the quantity of an item they want to buy. They can only get a quantity of 1 for a given item and you want them to be able to choose.

     

    Solution:

    The code below will allow the user the enter a specific quantity, click "Buy Now" button and pay for the total cost.

     

     

    -----------------------------------------------------------------------------
    1- Log into your AlertPay account
    2- Click on Business Tools
    3- Click on Generate a Buy Now button in the Advanced Integration section

    Enter all the required fields. For the quantity you may enter any quantity for now, for instance, 1.


    In the button code that is generated after, please change the following line
    <input type='hidden'  name='ap_quantity' value='1'>
    with
    <input type="text" name="ap_quantity" value=""/>


    Now the customer can enter the quantity they wish to have and when they click on the Buy Now button, a total will be calculated according to that quantity.

    -----------------------------------------------------------------------------

     

    Here is a sample code that you can copy/paste in a .html file.

     <form method="post" action="https://www.alertpay.com/PayProcess.aspx" > 
         <input type="hidden" name="ap_purchasetype" value="item-goods"/> 
         <input type="hidden" name="ap_merchant" value="apdevforum@gmail.com"/> 
         <input type="hidden" name="ap_itemname" value="Hat"/> 
         <input type="hidden" name="ap_currency" value="USD"/> 
         <input type="hidden" name="ap_returnurl" value="http://www.alertpay.com"/> 
         <input type="hidden" name="ap_itemcode" value="01"/> 
         <input type="text" name="ap_quantity" value=""/> 
         <input type="hidden" name="ap_description" value="Example"/> 
         <input type="hidden" name="ap_amount" value="10.00"/> 
         <input type="hidden" name="ap_cancelurl" value="http://dev.alertpay.com"/> 
         <input type="image" name="ap_image" src="https://www.alertpay.com/Images/BuyNow/pay_now_3.gif"/>
     </form>       

    ***This is a Developers Forum, any other questions should be addressed to our Customer Support department or you can find the answers in our FAQ page.***
  • 12-02-2008 1:21 PM In reply to

    Re: Dynamic Quantity Value on Buy Now Button

    Problem:

    You do not want the user enter any random quantity, you want to restrict them to defined sets of quantity.

     

    Solution:

    To allow the user to choose a specific quantity from a dropdown menu. Make the following modifications in your button code.

     

    Thank you benmanns for submitting the code in this post.

     

     -----------------------------------------------------------------------------

     <form method="post" action="https://www.alertpay.com/PayProcess.aspx" > 
         <input type="hidden" name="ap_purchasetype" value="item-goods"/> 
         <input type="hidden" name="ap_merchant" value="apdevforum@gmail.com"/> 
         <input type="hidden" name="ap_itemname" value="Shoes"/> 
         <input type="hidden" name="ap_currency" value="USD"/> 
         <input type="hidden" name="ap_returnurl" value="http://www.alertpay.com"/> 
         <input type="hidden" name="ap_itemcode" value="01"/> 

        <label>Quantity:</label>
        <select id="ap_quantity" name="ap_quantity">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
        </select>


         <input type="hidden" name="ap_description" value="Example"/> 
         <input type="hidden" name="ap_amount" value="30.00"/> 
         <input type="hidden" name="ap_cancelurl" value="http://dev.alertpay.com"/> 
         <input type="image" name="ap_image" src="https://www.alertpay.com/Images/BuyNow/pay_now_3.gif"/>
     </form>  

     

    ***This is a Developers Forum, any other questions should be addressed to our Customer Support department or you can find the answers in our FAQ page.***
  • 12-02-2008 1:29 PM In reply to

    Re: Dynamic Quantity Value on Buy Now Button

    Problem:

    You do not want the user enter any random quantity, you want to restrict them to defined sets of quantity.

     

    Solution:

    To allow the user to choose a quantity from a dropdown menu with the use of javascript. Make the following modifications in your button code.

     

    Thank you dejangex for submitting the code in this post

     

     

     -----------------------------------------------------------------------------

    <script type="text/javascript">
        function ChangeNumberOfRings(x)
        {
            val = x.options[x.selectedIndex].value;
          
            quantity_field = document.getElementById("quantity");
            buybutton = document.getElementById("buybutton");
          
            quantity_field.value = val;
            buybutton.value="Buy " + val + " Rings";
        }
    </script>
    <noscript>Please enable javascript, or this page might not work correctly</noscript>


    <form method="POST" action="https://www.alertpay.com/PayProcess.aspx">
    <input type="hidden" name="ap_purchasetype" value="item-goods"/>
    <input type="hidden" name="ap_merchant" value="apdevforum@gmail.com"/>
    <input type="hidden" name="ap_itemname" value="Ring"/>
    <input type="hidden" name="ap_currency" value="USD"/>
    <input type="hidden" name="ap_itemcode" value="R1"/>
    <input type="hidden" name="ap_description" value="Example"/>
    <input type="hidden" name="ap_amount" value="10.00"/>
    <input type="hidden" name="ap_returnurl" value="http://www.alertpay.com"/>
    <input type="hidden" name="ap_cancelurl" value="http://dev.alertpay.com"/> 

    <input type="hidden" name="ap_quantity" id="quantity" value="1"/>

        <label>Choose number of Rings you want to buy:
            <select onchange="ChangeNumberOfRings(this);">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="5">5</option>
                <option value="10">10</option>
            </select>
        </label>


    <input type="submit" id="buybutton" value="Buy 1 Ring"/>
    </form>
     

    ***This is a Developers Forum, any other questions should be addressed to our Customer Support department or you can find the answers in our FAQ page.***
Page 1 of 1 (3 items)

  AlertPay - Verified by Visa AlertPay - secure credit card and checking services BBBOnline Reliability Program