Exemplo n.º 1
0
    $_SESSION['orderinfo']['daylimit'] = (int) $prices['MonthNumber'] * 30;
    // Figure out what funding instruments are available for this buyer
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        try {
            $order = $_POST["order"];
            $id = $orderInfo['id'];
            /*  try {
                    $recoderId = insertKey($orderInfo["email"], $orderInfo["ime"], $orderInfo["deviceid"], $orderInfo["devicetype"]);
                } catch (Exception $ex) {
                    $message = $ex->getMessage();
                    $messageType = "error";
                }*/
            // Create the payment and redirect buyer to paypal for payment approval.
            if (isset($id)) {
                $baseUrl = getBaseUrl() . "/order_completion.php?orderid={$id}";
                $payment = makePaymentUsingPayPal($order['amount'], 'USD', sprintf("Payment license %s Months - \$%s ", $prices["MonthNumber"], $order['amount']), "{$baseUrl}&success=true", "{$baseUrl}&success=false");
                $_SESSION['orderinfo']['payment_id'] = $payment->getId();
                header("Location: " . getLink($payment->getLinks(), "approval_url"));
                exit;
            }
        } catch (\PayPal\Exception\PPConnectionException $ex) {
            $message = parseApiError($ex->getData());
            $messageType = "error";
        }
    }
}
?>
<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta charset='utf-8'>
Exemplo n.º 2
0
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $order = $_REQUEST['order'];
    try {
        if ($order['payment_method'] == 'credit_card') {
            // Make a payment using credit card.
            $user = getUser(getSignedInUser());
            $payment = makePaymentUsingCC($user['creditcard_id'], $order['amount'], 'USD', $order['description']);
            $orderId = addOrder(getSignedInUser(), $payment->getId(), $payment->getState(), $order['amount'], $order['description']);
            $message = "Your order has been placed successfully. Your Order id is <b>{$orderId}</b>";
            $messageType = "success";
        } else {
            if ($order['payment_method'] == 'paypal') {
                $orderId = addOrder(getSignedInUser(), NULL, NULL, $order['amount'], $order['description']);
                // Create the payment and redirect buyer to paypal for payment approval.
                $baseUrl = getBaseUrl() . "/order_completion.php?orderId={$orderId}";
                $payment = makePaymentUsingPayPal($order['amount'], 'USD', $order['description'], "{$baseUrl}&success=true", "{$baseUrl}&success=false");
                updateOrder($orderId, $payment->getState(), $payment->getId());
                header("Location: " . getLink($payment->getLinks(), "approval_url"));
                exit;
            }
        }
    } catch (\PayPal\Exception\PPConnectionException $ex) {
        $message = parseApiError($ex->getData());
        $messageType = "error";
    } catch (Exception $ex) {
        $message = $ex->getMessage();
        $messageType = "error";
    }
}
require_once 'orders.php';
Exemplo n.º 3
0
<?php

# Medicnexus - sistema de gestión médica desarrollado en php
# Medicnexus es un programa para la realización de consultas
# en línea con médicos especializados. El sitio cuenta con noticias
# y artículos que podrán mantener actualizados al cliente con los
# últimos acontecimientos existentes en el área. Cuenta con un sistema
# de respuesta rápida a partir de las consultas realizadas por el cliente.
# Todos los derechos reservados
/**
 * Establece la comunicación con la pasarela de pago Paypal.
 */
try {
    $payment = makePaymentUsingPayPal($idData, $GLOBALS['CURRENT_PAGE'] . '?success=true&idData=' . $idData, $GLOBALS['CURRENT_PAGE'] . '?success=false&idData=' . $idData);
    $_SESSION['paymentId'] = $payment->getId();
    foreach ($payment->getLinks() as $link) {
        if ($link->getRel() == 'approval_url') {
            $redirectUrl = $link->getHref();
            break;
        }
    }
    header("Location: " . $redirectUrl);
    exit;
} catch (PayPal\Exception\PPConnectionException $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);
} catch (Exception $ex) {
    echo "Exception: " . $ex->getMessage() . PHP_EOL;
    var_dump($ex->getData());
    exit(1);