how to integrate paypal with return data? - php

I have created a new business account in paypal and created a button but I have these two problems;
1. when I passed the price for service, and user click (pay now) button then user go to paypal page but the price that I put is not showing as a primary price in paypal page.
the item price is empty in paypal. user has to put the price in paypal too.
and the price that has passed is in (Options: service price: 12) which is not counted in the total amount.
this is the code of the button that I insert it in my page:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="3YNEZFSSJNVR4">
<table>
<tr><td><input type="hidden" name="on0" value="service price">service price</td></tr><tr><td><input type="text" name="os0" maxlength="200"></td></tr>
</table>
<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">
the second problem how I can pass the transaction info to my website to record it in my database? is that need special account different than standard (free) account

it's look like you not have pass the amount value to paypal
<input type="hidden" name="amount" value="<?php echo $total; ?>">

Related

Error on Buy Button (Paypal Integration Gateway in CodeIgniter)

I'm using a CodeIgniter 3 and I'm having a hard time on implementing the paypal integration on my website . For now I'm trying it on the sandbox and followed this tutorial Paypal Integration Using CodeIgniter
Now the problem here is on my
views/products/index.php
<a href="<?php echo base_url().'products/buy/'.$product['id']; ?>">
<img src="<?php echo base_url(); ?>assets/images/x-click-but01.gif" style="width: 70px;">
</a>
Now when i click the button Paypal Buy Now now it
redirects me to
products/buy/1 was not found on this server.
I follow the instruction
and here is what on my database
Then i tried using the paypal button
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="S3RE65SMVGAHC">
<input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
</form>
and it redirects me to paypal but without the prices that i inputted on my database. SOMEONE HELP ME PLEASE
The error message
products/buy/1 was not found on this server.
is saying that the controller Products.php was not found.
Assuming the file is in the `applications/controllers' directory (it should be) then you need to make sure that the file name starts with an uppercase 'P'. In other words, the file name should be Products.php not products.php
Please try below sample codes.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="YOUR_ACCOUNT_EMAIL/MERCHANTID">
<input type="hidden" name="item_name" value="test">
<input type="hidden" name="amount" value="10">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal — The safer, easier way to pay online.">
</form>
And refer to below link for details of each variable.
https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/

PayPal IPN Simulator Custom Text Fields

I have the following PayPal button set up:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="SN3834XQZMRCW">
<table>
<tr><td><input type="hidden" name="on0" value="Minecraft Username:">Minecraft Username:</td></tr>
<tr><td><input type="text" name="os0" maxlength="200"></td></tr>
<tr><td><input type="hidden" name="on1" value="TeamSpeak UID:">TeamSpeak UID:</td></tr>
<tr><td><input type="text" name="os1" maxlength="200"></td></tr>
</table>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribeCC_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>
According to the documentation, the two hidden fields I have simply get passed to PayPal and then back to my PHP script. To get these values, would it be correct to use the following:
$_POST['TeamSpeak UID:'];
Before you ask, I can't seem to send these custom fields using the simulator, unless the fields are encapsulated within the custom field? The documentation and help seems to be lacking here. Thanks for any help.

How to protect user edit paypal button ?

How to protect user edit paypal button ?
this is paypal buy now button on my site
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="me#mybusiness.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Teddy Bear">
<input type="hidden" name="amount" value="12.99">
<input type="image" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
my customer will edit paypal button like currency_code, amount
i want to know , how can i protect user to edit paypal button ?
Log into your PayPal account and use the button tool to create a saved button. the saved button replaces all of the sensitive data in the button code with a "Hosted button ID. here is an example of the hosted button code:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="L7NSNLBNU69AC">
<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>

create dynamic billing button

I want to create dynamic billing button using paypal
when I used create button at the paypal.com it generate a button for me :
<form action='https://www.paypal.com/cgi-bin/webscr' method='post' target='_top'>
<input type='hidden' name='cmd' value='_s-xclick'>
<input type='hidden' name='hosted_button_id' value='BFKATLSGW6CTW'>
<input type='image' src='https://www.paypalobjects.com/en_US/i/btn/btn_buynow_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>
but it's with a static price
I tried to add a hidden input
<input type="hidden" name="amount" value="5.95">
but the price still static
I tried the automatic billing throw the paypal.com
but I got
You need to have a PayPal Business account and the Enhanced Recurring Payments package to create Automatic Billing or Installment Plan buttons
I viewd my profile and created a business app for it , but the message still the same
My last try to use this form
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can bill for payments. -->
<input type="hidden" name="business" value="BLWHUxxxxxx"> <!-- I put my merchant id---->
<!-- Specify an Automatic Billing button. -->
<input type="hidden" name="cmd" value="_xclick-auto-billing">
<!-- Specify details about the automatic billing plan. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Regular House Cleaning">
<input type="hidden" name="max_text" value="Regular House Cleaning">
<input type="hidden" name="set_customer_limit" value="max_limit_own">
<input type="hidden" name="min_amount" value="1.00">
<!-- Make sure you get the buyer's address during checkout. -- >
<input type="hidden" name="no_shipping" value="2">
<!-- Display the description and a text box to enter the maximum. -->
<table>
<tr>
<td><strong> </strong></td></tr>
<tr><td>
</td></tr>
<tr><td>$
<input type="hidden" name="amount" value="5.95">
<input type="text" name="max_amount" value="1000"> USD</td></tr>
<!-- Inform buyers of the monthly minimum payment -->
<tr><td> </td></tr>
</table>
<!-- Display the Automatic Billing button -->
<table>
<tr><td><input type="image" border="0" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif"
alt="PayPal - The safer, easier way to pay online!"></td></tr>
</table>
<img alt="" border="0" width="1" height="1" src="http://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" />
</form>
but the result is
This merchant is no longer authorized to offer this Autobilling plan.Please contact the merchant or choose another product.
any recommendations to have a script that take the price from the database to let the customer pay for the the services !
You are using Hosted button. It is not possible to over-write the amount value in Hosted Button . You can can clear text button to over-write the amount variable.
When you create a button in Paypal, make sure you uncheck the option "Save button at PayPal" in Step 2 . This makes the button "Clear Text" and provides option to over-write any variable using your custom logic.Automatic billing,Installments button work only if you have Enhanced Recurring Payments ERP

Returning custom input data from PayPal

I created a basic purchase script where a user enters their desired username and password, then they can purchase the membership on my website. But, when it goes to the return page, the values Username and Password don't show in the url. Here is the code:
<form 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="CKQH4CYEMYLWW">
<center>
<span id="msgbox" style="display:none;"></span>
<br><br>
<input type="text" id="rusername" name="rusername" placeholder="Desired Username" class="usernamelogin">
<br><br>
<input type="password" id="rpassword" name="rpassword" placeholder="Desired Password" class="passwordlogin">
<br><br>
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_buynowCC_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>
set cookie variable for each input variable and pass the data accordingly . . and on return from paypal you can simply check the cookie variable and pass the data in the individual input accordingly ..
Paypal Standard gives one variable 'custom' for passing custom data
so you can have a way to pass those values using this variable and getting back.
eg. you can seperate the values using | and get back
<input type="hidden" id="custom" name="custom" value="username|password"/>
you can set the values when your form is going to be submitted
when success page comes you can get the values
list($username,$password) = explode('|',$_POST['custom']);

Categories