PHP Paywall Form Outputs Black Screen - php

I wrote a basic PHP script that contains a form that is supposed to when submitted open a Paypal buy now dialog and then echo "paid" once it has been paid.
For some reason it just shows a black screen with a small square after submitting the first form. It never gets to the paypal button form.
I have tried passing variables through paypal to keep them when it returns to the page and the php syntax checker detects zero issues.
Here is the code:
if(!isset($_POST["form1"])) {
if (!isset($_POST["payment_status"])) {
echo '<form action="article.php" method="post" ><input type="url" name="logo" placeholder="your .PNG logo" size="14"><input type="text" name="title" placeholder="title" size="14"><input type="hidden" name="form1" value="form1" size="14"><input type="submit" name="submit" value="submit"></form>';
}
}
if(isset($_POST["form1"])) {
header('Content-type: image/png');
$title = $_POST["title"];
$image3 = $_POST["logo"];
$dataa = $title;
$dataa .= $logo;
echo '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<br>
<input name="currency_code" type="hidden" value="USD">
<input name="shipping" type="hidden" value="0.00">
<input name="tax" type="hidden" value="0.00">
<input type="hidden" name="amount" value="0.20">
<input name="return" type="hidden" value="http://example.com/article.php/?data=$dataa">
<input name="cancel_return" type="hidden" value="http://example.com">
<input name="notify_url" type="hidden" value="http://example.com/article.php">
<input name="cmd" type="hidden" value="_xclick">
<input name="business" type="hidden" value="example#example.com">
<input name="item_name" type="hidden" value="digital download">
<input name="no_note" type="hidden" value="1">
<input type="hidden" name="no_shipping" value="1">
<input name="lc" type="hidden" value="EN">
<input name="bn" type="hidden" value="PP-BuyNowBF">
<input name="custom" type="hidden" value="pass form data here">
<input type="submit" name="submit" value="download survey results $2">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>';
}
if (isset($_POST["payment_status"])) {
$payment_status = $_POST['payment_status'];
if ($payment_status == "Completed") {
echo "paid";
echo "<h1>Here is the unlocked article</h1>";
}
}
else {
echo "";
}
?>

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;

How to get Paypal 'Add to Cart' button response?

I m trying to add a Paypal Add to cart button in my application. For that i create code from paypal sanbox. This is my form,
<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="EGZD52TPWUERY">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Fees">
<input type="hidden" name="item_number" value="255">
<input type="hidden" name="amount" value="85.00">
<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="my-application/paypal/success">
<input type="hidden" name="tax_rate" value="0.000">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="item_id_<?php echo $res_1->id; ?>" value="<?php echo $res_1->id; ?>" />
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted">
<input type="image" src="https://www.sandbox.paypal.com/en_US/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.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
The payment transaction is completed successfully and the redirect is done perfectly to my application. But the problem is i didn't get any response in that page. I tried var_dump($_POST). It retruns null. Don't know why i didn't get any response. Any help is appreciated.
Check the following link and update your paypal account.The response is in $_GET
https://developer.paypal.com/webapps/developer/docs/classic/products/payment-data-transfer/

Problems with posting Paypal values

It is assumed that using the form, variables are passed by post method to return page, but it is not doing that, and I don't know what I can do about it, since transit through the Paypal website is out of my control.
Any idea?
This is my button. I have the same situation with another one.
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="name#dom.com">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="item_name" value="Algo">
<input type="hidden" name="amount" value="8.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="item_number" value="<?php echo $_GET['id'];?>">
<input type="hidden" name="custom" value="<?php echo $_GET['sub'];?>">
<input type="hidden" name="return" value="http://www.web.com/ok.php">
<input type="hidden" name="cancel_return" value="http://www.web.com/ko.php">
<input type="image" src="http://www.paypal.com/img/btn_buynow_LG.gif" border="0" name="submit" alt="Make payments with PayPal">
</form>
You can pass the variables by setting them as url parameters in the return page. Like this:
<input type="hidden" name="return" value="http://www.web.com/ok.php?id=<?php echo $_GET['id'];?>&custom=<?php echo $_GET['sub'];?>">

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.

Echoing textbox content into POST request not working

I am trying to take the textbox content from "mcname" ($custom) and POST that into "item_name" however it doesn't POST anything? I've looked around, but I still cannot find my solution?
At the top of my script before any HTML:
<?php
$custom = $_post['mcname'];
?>
The textbox, form post, and button in the middle of the script.
<input type="text" name="mcname" id="mcname" placeholder="Enter your username hereā€¦" />
<br/>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="formval">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="__#gmail.com">
<input type="hidden" name="item_name" value="<?php echo $custom; ?>">
<input type="hidden" name="amount" value="$10.00">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="hidden" name="return" value="http://__.com/upgrade" />
<input type="hidden" name="cancel_return" value="http://__.com/upgrade" />
<input type="hidden" name="notify_url" value="http://__.com/ipn/ipn.php">
<input type="hidden" name="custom" value="Iron">
<button type="submit" class="btn btn-primary" href="#" rel="tooltip" data-placement="bottom" title="Click here to continue to PayPal." ><i class="icon-shopping- cart"></i>Checkout</a>
</form>
POST is case sensitive, try:
$custom = $_POST['mcname'];
Well, your code is fine, the problem is:
$custom = $_post['mcname'];
change it to:
$custom = $_POST['mcname'];
POST is a super global and must be capitalized:
$custom = $_POST['mcname'];
Also, your textarea element is outside of your form, it needs to be inside the form tags.

Categories