Paypal different products options - php

I have paypal legacy code try to debug. I have different products with different price. In my project I found code
<div id="paypal_container" class="payment_container">
<div class="procesor font20 marg_bot20">Pay via PayPal</div>
<form action="<?php $server = base_url(); if (strpos($server,'http://cam.com/') !== false) echo 'https://www.paypal.com/cgi-bin/webscr'; else echo 'https://www.sandbox.paypal.com/cgi-bin/webscr'; ?>" method="post" target="_blank">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?php if (strpos($server,'http://camm') !== false) echo 'cdd'; else echo 'pptest'; ?>">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="notify_url" value="<?php echo base_url ('paypal/payment'); ?>">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted">
<table>
<tr>
<td class="font20 marg_bot20 inline-block">
<input type="hidden" name="on0" value="Package">Package
</td>
</tr>
<tr>
<td>
<select name="os0" class="input">
<option value="Basic1">Basic $5.00 USD</option>
<option value="Basic2">Basic $25.00 USD</option>
<option value="Basic3">Basic $50.00 USD</option>
<option value="VIP1">VIP1 $75.00 USD</option>
<option value="VIP2">VIP2 150.00 USD</option>
<option value="VIP3">VIP3 300.00 USD</option>
<option value="VIP4">VIP4 $500.00 USD</option>
<option value="VIP5">VIP5 $1,000.00 USD</option>
<option value="VIP6">VIP6 $1,500.00 USD</option>
<option value="Marquis">Marquis $3,000.00</option>
</select>
</td>
</tr>
</table>
<input type="hidden" name="custom" value="<?php echo $custom_pp; ?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="option_select0" value="Basic1">
<input type="hidden" name="option_amount0" value="5.00">
<input type="hidden" name="option_select1" value="Basic2">
<input type="hidden" name="option_amount1" value="25.00">
<input type="hidden" name="option_select10" value="Basic3">
<input type="hidden" name="option_amount10" value="50.00">
<input type="hidden" name="option_select2" value="VIP1">
<input type="hidden" name="option_amount2" value="75.00">
<input type="hidden" name="option_select3" value="VIP2">
<input type="hidden" name="option_amount3" value="150.00">
<input type="hidden" name="option_select8" value="Marquis1">
<input type="hidden" name="option_amount8" value="200.00">
<input type="hidden" name="option_select4" value="VIP3">
<input type="hidden" name="option_amount4" value="300.00">
<input type="hidden" name="option_select5" value="VIP4">
<input type="hidden" name="option_amount5" value="500.00">
<input type="hidden" name="option_select6" value="VIP5">
<input type="hidden" name="option_amount6" value="1000.00">
<input type="hidden" name="option_select7" value="VIP6">
<input type="hidden" name="option_amount7" value="1500.00">
<input type="hidden" name="option_select9" value="Marquis">
<input type="hidden" name="option_amount9" value="3000.00">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
But when I am redirected to sandbox paypal test page In cart I have proper product selected but price is always 0.01$.
Maybe I need something to add in my test facilitator or something in my html I am not sure how it works?

You can create Add to Cart button with drop down menu for different price.
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/paypal_shopping_cart/?mark=add%20to%20cart
Or, you can refer to the link below for the cart upload command.
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/cart_upload/?mark=add%20to%20cart

Related

paypal success url return null

i have simple paypal checkout form when i post it to paypal with sandbox credential when the paypments success, it gives me nothing like transaction and currency, i did print GET, but there is nothing. i am using codeigniter
below is the form code
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_click">
<input type="hidden" name="business" value="dev1#ferozitech.com">
<input type="hidden" name="item_name" value="test" class="slug">
<input type="hidden" name="item_number" value="2" class="proposalId">
<input type="hidden" name="custom" value="" class="userId">
<input type="hidden" name="amount" value="40" class="amount">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="<?php echo base_url('payment/payment_complete/') ?>">
<input type="hidden" name="cancel_return" value="<?php echo base_url('payment/payment_cancel') ?>">
<input type="image" name="submit" src="<?php echo base_url('images/checkoutpaypal.png'); ?>" alt="PayPal - The safer, easier way to pay online">
</form>
Try this code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="dev1#ferozitech.com">
<input type="hidden" name="item_name" value="test" class="slug">
<input type="hidden" name="item_number" value="2" class="proposalId">
<input type="hidden" name="custom" value="" class="userId">
<input type="hidden" name="amount" value="40" class="amount">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="lc" value=""/>
<input type="hidden" name="no_note" value="1"/>
<input type="hidden" name="return" value="<?php echo base_url('payment/payment_complete/') ?>">
<input type="hidden" name="cancel_return" value="<?php echo base_url('payment/payment_cancel') ?>">
<input type="hidden" name="notify_url" value="<?php echo base_url('payment/payment_complete/') ?>" />
<input type="image" name="submit" src="<?php echo base_url('images/checkoutpaypal.png'); ?>" alt="PayPal - The safer, easier way to pay online">
</form>
Return url notify_url payment_complete function
print_r($_REQUEST);die;

Paypal sandbox - your shoping cart is empty after i post variables with form?

I have a problem after I am redirected on paypal site. It display error -> your shopping cart is empty. No idea what is wrong. Thank you.
HTML:
<form method="post" action="https://www.paypal.com/cgi-bin/webscr">
<input type="hidden" value="_cart" name="cmd">
<input type="hidden" value="1" name="upload">
<input type="hidden" value="jax.cj#seznam.cz" name="business">
<input type="hidden" value="super tričko" name="item_name_0">
<input type="hidden" value="1000" name="amount_0">
<input type="hidden" value="1" name="quantity_0">
<input type="hidden" value="" name="custom">
<input type="hidden" value="https://www.yoursite.com/storescripts/my_ipn.php" name="notify_url">
<input type="hidden" value="https://www.yoursite.com/checkout_complete.php" name="return">
<input type="hidden" value="2" name="rm">
<input type="hidden" value="Return to The Store" name="cbt">
<input type="hidden" value="https://www.yoursite.com/paypal_cancel.php" name="cancel_return">
<input type="hidden" value="CZ" name="lc">
<input type="hidden" value="CZK" name="currency_code">
<input type="image" alt="Make payments with PayPal - its fast, free and secure!" name="submit" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif">
</form>
Your item variables should start with 1 instead of 0. This is how your item related variables should look like:
<input type="hidden" value="super tričko" name="item_name_1">
<input type="hidden" value="1000" name="amount_1">
<input type="hidden" value="1" name="quantity_1">

Not getting response for paypal "add to cart" button followd by paypal checkout

My add to cart button is having this code.
<form target="paypal" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="ajith-facilitator#pavanathara.com">
<input type="hidden" name="lc" value="UK">
<input type="hidden" name="item_name" value="<?= #$row['prod_name'] ?>">
<input type="hidden" name="item_number" value="<?= #$row['prod_id'] ?>">
<input type="hidden" name="amount" value="<?= #$row['prod_price'] ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="https://paypalipn.my.phpcloud.com/payment-successful.php">
<input type="hidden" name="cancel_return" value="https://paypalipn.my.phpcloud.com/payment-cancelled.php">
<input type="hidden" name="tax_rate" value="<?= #$settings[0]['pbreakup_value'] ?>">
<input type="hidden" name="shipping" value="<?= #$settings[1]['pbreakup_value'] ?>">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="hidden" name="prod_id" value="<?= #$row['prod_id'] ?>">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_cart_LG.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
But on https://paypalipn.my.phpcloud.com/payment-successful.php I am not receiving any response from paypal.

How to let a user select quantity on website as opposed to on the shopping cart

I have a drop down list on my website that contains the quantity available for a specific product however, when the user adds the product to the cart only 1 is displayed as opposed to 3 for example. Is there anyway i can get this to work?
This is the code for the dropdownlist/add to cart button:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="LVDZ4V9LJ7QQW">
<table>
<tr><td><input type="hidden" name="on0" value="Qty">Qty</td></tr><tr><td><select name="os0">
<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>
</select> </td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
I managed to figure it out. I changed and added the following and it seems to work fine:
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="LVDZ4V9LJ7QQW">
<table>
<tr><td><input type="hidden" name="add" value="1">Qty</td></tr><tr><td>
<select name="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>
</select> </td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>'
You can create a text box or drop down to allow the buyer to select the quantity. Then you would just populate the value into the variable "quantity" and pass it over with the rest of your variables. You dont need to pass it over using the variable "on0".
You could do this using the upload cart cmd, that would let the user select an amount.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="item_name_1" value="item name" />
<input type="hidden" name="business" value="businessemail" />
<input type="hidden" name="upload" value="1">
<input type="hidden" name="item_number" value="Item Name">
<select name="quantity_1">
<?php for($x = 1; $x < 11; $x++){
echo '<option value="'.$x.'">'.$x.'</option>';
}?>
</select>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="amount_1" value="10.00" />
<input type="hidden" name="custom" value="" />
<input type="hidden" name="weight" value="1" />
<input type="hidden" name="weight_unit" value="kg" />
<input type="hidden" name="shipping_1" value="1" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="shopping_url" value="main_shop_url" />
<input type="hidden" name="return" value="success_url" />
<input type="hidden" name="cancel" value="cancel_url" />
<input type="submit" value="Order Now" />
</form>
This can be used for multiple items, for example you would append _x to each item_name_, quantity_, amount_ as you need. Full documentation can be found here

Prepare form with multiple product options for Paypal

How can I prepare the option selection in the form to be sent to paypal?
I have tried,
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="item_name_1" value="Book 1" />
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="amount_1" value="0.10" />
<input type="hidden" name="quantity_1" value="1"/>
<input type="hidden" name="option_name1" value="sizes">
<input type="hidden" name="option_select1" value="Large"/>
...
or
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="item_name_1" value="Book 1" />
<input type="hidden" name="item_number_1" value="1">
<input type="hidden" name="amount_1" value="0.10" />
<input type="hidden" name="quantity_1" value="1"/>
<input type="hidden" name="on0" value="sizes">
<input type="hidden" name="os0" value="Large"/>
But I can't get any option data returned from $_POST
Besides, what if I have multiple products with different options, then how do I prepare the form?
For instance, product 1 has the size small as the selection, while product 2 has the size large as the selection. I assume that it could be like this?
....
<input type="hidden" name="option_name1" value="sizes">
<input type="hidden" name="option_select1" value="Large"/>
....
<input type="hidden" name="option_name1" value="sizes">
<input type="hidden" name="option_select2" value="Small"/>
You have to give an unique name for each product,
if you want to get back the post value in PHP
suc as :-
<input type="hidden" name="option_name[$id1]" value="sizes">
<input type="hidden" name="option_select[$id1]" value="Large"/>
...
<input type="hidden" name="option_name[$id2]" value="sizes">
<input type="hidden" name="option_select[$id2]" value="Large"/>
You can also use option_name[],
but this only return an indexed array in the $_POST
Also, why are you using hidden for option?
This is my understanding of option :-
<select name="sizes[$id1]">
<option value="Large">Large</option>
<option value="Large">Small</option>
</select>
...
<select name="sizes[$id2]">
<option value="Large">Large</option>
<option value="Large">Small</option>
</select>

Categories