[278,295] -->
Oct 03

Small and simple php script to accept payments through paypal right away. I modified the code from paypal developer community. This is a quick and easy integration to your website for accepting payments and directing the user to authorized area.

$req = ‘cmd=_notify-validate’;

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= “&$key=$value”;
}

// post back to PayPal system to validate
$header .= “POST /cgi-bin/webscr HTTP/1.0\r\n”;
$header .= “Content-Type: application/x-www-form-urlencoded\r\n”;
$header .= “Content-Length: ” . strlen($req) . “\r\n\r\n”;
$fp = fsockopen (’ssl://www.paypal.com’, 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST[’item_name’];
$item_number = $_POST[’item_number’];
$payment_status = $_POST[’payment_status’];
$payment_amount = $_POST[’mc_gross’];
$payment_currency = $_POST[’mc_currency’];
$txn_id = $_POST[’txn_id’];
$receiver_email = $_POST[’receiver_email’];
$payer_email = $_POST[’payer_email’];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, “VERIFIED”) == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
}
else if (strcmp ($res, “INVALID”) == 0) {
// log for manual investigation
}
}
fclose ($fp);
}
?>

Sep 18

I have a bunch of customers with different requirements who can add and drop services at anytime. For every 30 day interval my cron script made using php will check for the services and bill the customer accordingly.

1. Will i be able to process such payments in cron through paypal?

2. If yes. Then if the customer is having a paypal account with the same credit card details on my server, then will i be able to process the payment? (Because, usually paypal always reports that the credit card used for the payment is already registered with a paypal account).

Post your responses in the comments section below

Thanks

Aug 05

This code will help you extract urls from google analytics account with analytics API by Felix Geisendörfer
// Start Code for getting the URLs

$pages = $this->Analytics->report(array(
‘profile’ => ‘PROFILE_NAME’,
‘report’ => ‘TopContent’,
‘trows’ => ‘500′
));
foreach ($pages[’AnalyticsReport’][’Report’][’Table’][’Row’] as $pages_individual):
$pages_urls[$pages_individual[’Key’][’#text’]] = $pages_individual[’Key’][’#text’];
endforeach;
$this->set(’pages_urls’,$pages_urls);

//End Code for getting URLs