Thursday, 8 May 2014

PayPal Payments Standard - Recurring

HTML Variables for Recurring Payments
































HTML FORM


<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" id="payment_form">
         <input type="hidden" name="business" value="psudhir20@gmail.com">
        <input type="hidden" name="email" value="<?php echo $email;?>">
        <input type="hidden" name="currency_code" value="USD">
        <input type="hidden" name="no_shipping" value="1">
        <input type="hidden" name="item_number" value="12">
        <input type="hidden" name="cmd" value="_xclick-subscriptions"/>
        <input type="hidden" name="a3" class="paidAmount" value="5.00">
         <input type="hidden" name="p3" value="1"> 
         <input type="hidden" name="t3" value="Y">
        <input type="hidden" name="rm" value="2">
         <input type="hidden" name="src" value="1">
         <input type="hidden" name="sra" value="1">
        <input type="hidden" name="cancel_return" value="cancel.php"/>
         <input type="hidden" name="return" value="return.php"/>
         <input type="hidden" name="notify_url"  value="notify.php"/>
</form>

notify.php

$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {         // Loop through the notification NV pairs
$value = urlencode(stripslashes($value));  // Encode these values
$req  .= "&$key=$value";                   // Add the NV pairs to the acknowledgement
}
if(USE_SANDBOX == true) {
$paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
} else {
$paypal_url = "https://www.paypal.com/cgi-bin/webscr";
}

$ch = curl_init($paypal_url);
if ($ch == FALSE) {
return FALSE;
}

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
$res = curl_exec($ch);

if (strcmp ($res, "VERIFIED") == 0) {
$email_text ='Payment Successfully';
$headers = "Content-type: text/html\r\n"; 
mail('psudhir20@gmail.com','Payment Confirmation',$req,$headers);
}
else if (strcmp ($res, "INVALID") == 0) {
$headers = "Content-type: text/html\r\n"; 
mail('promatics.sudhir@gmail.com','Payment Confirmation','Invalid',$headers );
}
curl_close($ch);
die;

0 comments:

Post a Comment