PayPal Subscription for Recurring Payments in php - php

I'm using following code to make a Payment Subscription.
$paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; //Test PayPal API URL
$paypalID = ''; //Business Email
$usermail = $idarray->email;
<form action="<?php echo $paypalURL; ?>" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="<?php echo $paypalID; ?>">
<!-- Specify a Buy Now button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value=Elearning - Kurs">
<input type="hidden" name="item_number" value="1">
<input type="hidden" name="lc" value="IN">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="EUR">
<input type="hidden" name="a3" value="1">
<input type="hidden" name="p3" value="12">
<input type="hidden" name="t3" value="M">
<!-- Specify URLs -->
<input type='hidden' name='cancel_return' value='https://contao.netz-garage.de/fehlgeschlagen.html'>
<input type='hidden' name='return' value='http://contao.netz-garage.de/erfolgreich.html'>
<input type='hidden' name='notify_url' value='https://contao.netz-garage.de/ipn.php'>
<!-- Display the payment button. -->
<input type="submit" name="submit" value="submitted">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form><br><br>
I get to the confirm Site but after that I get to the following site:
failed

Related

How to make sure the paypal notify_url being called from paypal server?

I was working with paypal recurring payment subscription form and using sandbox account for testing
here is my form:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="testacc#email.com">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Standard Pack">
<input type="hidden" id="item_number" name="item_number" value="1233434-23213">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="user_id" value="13692">
<input type="hidden" id="package_id" name="package_id" value="<?php echo $package_type; ?>">
<input type="hidden" name="a1" value="0">
<input type="hidden" name="p1" value="1">
<input type="hidden" id="t1" name="t1" value="M">
<input type="hidden" id="a3" name="a3" value="10">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="no_shipping" value="1">
<input name="return" type="hidden" value="<?php echo base_url();?>package/new_payment_success" />
<input name="notify_url" type="hidden" value="<?php echo base_url();?>package/new_payment_notify" />
<input name="cancel_return" type="hidden" value="<?php echo base_url();?>package/new_payment_cancel" />
<div class="paypal-btn">
<input type="image" src="pay-with-paypal.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style='width: 125px'>
</div>
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
and it's working totally fine and sends a success information to notify_url url
now for security purpose im checking HTTP_USER_AGENT from $_SERVER variable but this can be modified too.
so how can i make sure that transection is done successfully before i update my database?
I think that you can verify the whole POST content by appending cmd=_notify-validate and sending it to PayPal. They will answer you with a Verified or Not verified response.
Please, check the link below for more information:
https://developer.paypal.com/docs/classic/ipn/gs_IPN/

does not work recurring paypal sandbox

my php code generates html form which is submitting automatically with redirection of customers:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" name="vm_paypal_form" id="vmPaymentForm" accept-charset="UTF-8">
<input type="hidden" name="charset" value="utf-8">
<input type="hidden" name="cmd" value="_xclick-subscriptions" />
<input type="hidden" name="business" value="bolpav#example.com" />
<input type="hidden" name="custom" value="otmjboutim6sl98u6olis61nm7" /
><input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="return" value="http://example.com/devportal/index.php?option=com_virtuemart&view=vmplg&task=pluginresponsereceived&on=3L99030&pm=1&Itemid=166&lang=" />
<input type="hidden" name="notify_url" value="http://example.com/devportal/index.php?option=com_virtuemart&view=vmplg&task=notify&tmpl=component&lang=" />
<input type="hidden" name="cancel_return" value="http://example.com/devportal/index.php?option=com_virtuemart&view=vmplg&task=pluginUserPaymentCancel&on=3L99030&pm=1&Itemid=166&lang=" />
<input type="hidden" name="rm" value="1" />
<input type="hidden" name="bn" value="VirtueMart_Cart_PPA" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="image_url" value="http://example.com/devportal/images/virtuemart/vendor/" />
<input type="hidden" name="item_name" value="Order Number: 3L99030" />
<input type="hidden" name="lc" value="EN" />
<input type="hidden" name="a3" value="105" />
<input type="hidden" name="p3" value="1" />
<input type="hidden" name="t3" value="M" />
<input type="hidden" name="src" value="1" />
<input type="hidden" name="srt" value="52" />
<input type="hidden" name="sra" value="1" />
<input type="submit" value="Please wait while redirecting to PayPal" />
</form>
After this form is submited i see page with order number, price and message : ". To complete your checkout using PayPal, please log in." After i click Login button then it redirects me to login page . But after i login then it open dasboard and forgets about payment . So payment procedure gets broken. I am using Sanbox business account for seller and sandbox personal account for customer. Can anybody help?
It seems to be a known issue at PayPal's end. The engineering team is working on this for a fix. Will update here once it gets fixed.

How to add extra fields in Paypal subscription click method?

Here is my code. I need to add some extra variables example: license-type:Basic
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="business#email.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="Alice's Monthly Digest">
<input type="hidden" name="item_number" value="DIG Weekly">
<!-- Set the terms of the recurring payments. -->
<input type="hidden" name="a3" value="69.95">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="M">
<!-- Set recurring payments to stop after 6 billing cycles. -->
<input type="hidden" name="src" value="1">
<input type="hidden" name="srt" value="6">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypalobjects.com/en_US/i/btn/btn_subscribe_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
How to add extra field in this methods ? or I need next line in description tab.!!
This is an example
https://www.paypal.com/cgi-bin/webscr?cmd=_pdn_xclick_options_help_outside
Add this:
<input type="hidden" name="custom_input" value="Custom value" />
Please add this:
<input type="hidden" name="custom" value="your custom value">
this is an answer..!!!
<input type="hidden" name="item_name" value="INDIANJOBTIPS">
<input type="hidden" name="on0" value="Duration">
<input type="hidden" name="os0 " value="1 year">
<input type="hidden" name="on1" value="No of users">
<input type="hidden" name="os1 " value="1">

Want to connect my shopping cart total price to a paypal checkout

I have a displaycart.php page where it displays all items I have in a shopping cart, each item has an ItemUnitPrice field where it shows the unit price of the item.
If I have say 6 items in the cart then I want to add up the total ItemUnitPrice fields and set that amount to be paid with PayPal.
I have checked out PayPals button features which they allow and you can only set a given price for the user to pay for when you create the button.
Is there a way I can link the PayPal button to my database so it shows the total of all the ItemUnitPrice fields.
The variable which holds the total ItemUnitPrice:
<?php
$Total = $Quantity * $ItemUnitPrice;
?>
The PayPal 'Pay Now' Button:
<html>
<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="KAMQ5PVWVDYYN">
<input type="image" src="https://www.paypalobjects.com/en_GB/i/btn/btn_paynow_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>
</html>
Edit:
Yeah I've done something stupidly wrong!
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_BLANK">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="info#asianweddingservices.org" />
<input type="hidden" name="item_name" value="<? $ItemDesc ?>" />
<input type="hidden" name="item_number" value="<?$ItemCode ?>" />
<input type="hidden" name="amount" value="<?$Total ?>" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="lc" value="GB" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input src="paypal/purchase.png" name="Submit" type="image" value="purchase" alt="Purchase" />
</form>
Yes. Change the set value to your total.
Show your code and I can edit the answer to fix it for you.
Add this:
<input type="hidden" name="amount" value="<? echo $Total; ?>" />
If that doesn't work:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_BLANK">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="PAYPAL EMAIL" />
<input type="hidden" name="item_name" value="ITEM NAME" />
<input type="hidden" name="custom" value="CUSTOM VALUE" />
<input type="hidden" name="item_number" value="ITEM NUMBER" />
<input type="hidden" name="amount" value="TOTAL" />
<input type="hidden" name="currency_code" value="GBP" />
<input type="hidden" name="lc" value="GB" />
<input type="hidden" name="bn" value="PP-BuyNowBF" />
<input src="paypal/purchase.png" name="Submit" type="image" value="pruchase" alt="Purchase" />
</form>
Replacing the values to yours of-course.

custom parameter not getting returned in PAYPAL recursive transaction

Am going to implement the paypal in the form of user subscription...
Bellow code runs fine...
Transaction also works fine...
But am not getting back the 'custom parameters' which i have send(as shown in following code of form)...
<form name="_xclick" id="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="xxx#xxx.com">
<!-- Specify a Subscribe button. -->
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<!-- Identify the subscription. -->
<input type="hidden" name="item_name" value="<?php echo $description; ?>">
<!-- Set the terms of the regular subscription. -->
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="a3" value="<?php echo $amount; ?>">
<input type="hidden" name="p3" value="1">
<input type="hidden" name="t3" value="<?php echo $trial_period; ?>">
<!-- Set recurring payments until canceled. -->
<input type="hidden" name="src" value="1">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="notify_url" value="<?php echo $return_domain;?>">
<input type="hidden" name="cancel_return" value="<?php echo $cancel_return;?>">
<input type="hidden" name="return" id="return" value="<?php echo $return_domain;?>" />
<input type="hidden" name="custom" value="<?php echo $serialized_cust_par;?>" />
</form>

Categories