Example #1
0
 public function actionIpn()
 {
     require_once 'paypal/PPBootStrap.php';
     $log = new Log();
     $log->description = "";
     $ipnMessage = new PPIPNMessage(null, Configuration::getConfig());
     foreach ($ipnMessage->getRawData() as $key => $value) {
         $log->description .= "IPN: {$key} => {$value}\n";
     }
     if ($ipnMessage->validate()) {
         $log->description .= "Success: Got valid IPN data\n";
         //if($ipnMessage->getRawData()['business']=='*****@*****.**') {
         if ($ipnMessage->getRawData()['business'] == '*****@*****.**') {
             $reservation = Reservation::model()->findByPk(substr($ipnMessage->getRawData()['item_number'], 3, -1));
             if (isset($reservation)) {
                 if ($ipnMessage->getRawData()['mc_gross'] == $reservation->total) {
                     if ($ipnMessage->getRawData()['payment_status'] == 'Completed') {
                         $reservation->status = 'PAID';
                         $reservation->payment_date = date('Y-m-d H:i:s', strtotime($ipnMessage->getRawData()['payment_date']));
                         $reservation->note = $ipnMessage->getRawData()['memo'];
                     } else {
                         $reservation->status = 'ERROR';
                     }
                     if ($reservation->save()) {
                         $log->description .= "reservation saved\n";
                         $subject = 'Reservación';
                         $name = $reservation->user->name . " " . $reservation->user->lastname;
                         $body = "{$name} ha hecho una reservación y ha pagado exitosamente.\n" . "Fecha llegada: " . $reservation->arrival_date . "\n" . "Fecha salida: " . $reservation->departure_date . "\n" . "Max # personas: " . $reservation->number_people . "\n" . "Nota: " . $reservation->note . "\n" . "Total: \$" . $reservation->total;
                         $headers = "From: {$name} <*****@*****.**>\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8";
                         mail(Yii::app()->params['adminEmail'], $subject, $body, $headers);
                         $log->description .= "email sent\n";
                         $subject = 'Reservación EdenBlue';
                         $name = $reservation->user->name . " " . $reservation->user->lastname;
                         $body = "Has hecho una reservación y ha pagado exitosamente. Ahora puedes dirigirte a nuestras instalaciones.\n" . "Fecha llegada: " . $reservation->arrival_date . "\n" . "Fecha salida: " . $reservation->departure_date . "\n" . "Max # personas: " . $reservation->number_people . "\n" . "Total: \$" . $reservation->total;
                         $headers = "From: EdenBlue <*****@*****.**>\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8";
                         mail($ipnMessage->getRawData()['payer_email'], $subject, $body, $headers);
                         $log->description .= "email sent to payer\n";
                     } else {
                         $log->description .= "reservation no saved\n";
                     }
                 } else {
                     $log->description .= "bad total amount\n";
                 }
             } else {
                 $log->description .= "reservation not found\n";
             }
         } else {
             $log->description .= "bad receiver_id\n";
         }
     } else {
         $log->description .= "Error: Got invalid IPN data";
     }
     $log->creation_date = date('Y-m-d H:i:s');
     if ($log->save()) {
         echo "saved";
     } else {
         echo "no saved";
     }
 }
Example #2
0
<?php

/**
 * This is a sample implementation of an IPN listener
 * that uses the SDK's PPIPNMessage class to process IPNs
 * 
 * This sample simply validates the incoming IPN message
 * and logs IPN variables. In a real application, you will
 * validate the IPN and initiate some action based on the 
 * incoming IPN variables.
 */
require_once '../PPBootStrap.php';
// first param takes ipn data to be validated. if null, raw POST data is read from input stream
$ipnMessage = new PPIPNMessage(null, Configuration::getConfig());
foreach ($ipnMessage->getRawData() as $key => $value) {
    error_log("IPN: {$key} => {$value}");
}
if ($ipnMessage->validate()) {
    error_log("Success: Got valid IPN data");
} else {
    error_log("Error: Got invalid IPN data");
}
<?php

$managerConfig = new Configuration();
if (isset($_POST['validate'])) {
    $newConfig = array();
    $newConfig['version'] = "1.1";
    $newConfig['showRate'] = isset($_POST['showRate']) ? "true" : "false";
    $newConfig['responsive'] = isset($_POST['responsive']) ? "true" : "false";
    $newConfig['bp_shareActivity'] = isset($_POST['bp_shareActivity']) ? "true" : "false";
    $newConfig['bp_shareResult'] = isset($_POST['bp_shareResult']) ? "true" : "false";
    $newConfig['share_socialNetwork'] = isset($_POST['share_socialNetwork']) ? "true" : "false";
    $newConfig['showTag'] = isset($_POST['showTag']) ? "true" : "false";
    $newConfig['showGlossary'] = isset($_POST['showGlossary']) ? "true" : "false";
    $sizes = array("small", "medium", "large");
    $newConfig['sizePlayer'] = isset($_POST['sizePlayer']) && in_array($_POST['sizePlayer'], $sizes) ? $_POST['sizePlayer'] : $sizes[1];
    $managerConfig->InsertConfig($newConfig);
}
$configuration = $managerConfig->getConfig();
require_once __ROOT_PLUGIN__ . 'Views/admin/configuration.view.php';