Exemplo n.º 1
0
            $method = Mollie_API_Object_Method::IDEAL;
    }
    /*
     * Payment parameters:
     *   amount        Amount in EUROs.
     *   method        Payment method "ideal".
     *   description   Description of the payment.
     *   redirectUrl   Redirect location. The customer will be redirected there after the payment.
     *   metadata      Custom metadata that is stored with the payment.
     *   issuer        The customer's bank. If empty the customer can select it later.
     */
    $payment = $mollie->payments->create(array("amount" => $price, "method" => $method, "description" => "Muzikale Roadtrip " . $time, "redirectUrl" => "http://www.shot.utwente.nl/kaartverkoop/return.php?int={$time}", "webhookUrl" => "http://www.shot.utwente.nl/kaartverkoop/webhook.php", "metadata" => array("time" => $time)));
    /*
     * In this example we store the order with its payment status in a database.
     */
    database_write($payment->id, $_POST["firstname"], $_POST["lastname"], $_POST["e-mail"], $time, $payment->status, $tickets_concert, $tickets_ns, $payment->amount);
    /*
     * Send the customer off to complete the payment.
     */
    //header("Location: http://shot.utwente.nl/kaartverkoop/return.php");
    header("Location: " . $payment->getPaymentUrl());
} catch (Mollie_API_Exception $e) {
    echo "API call failed: " . htmlspecialchars($e->getMessage());
}
/*
 * Writes to the database with prepared statement
 */
function database_write($payment_id, $firstname, $lastname, $e_mail, $time, $status, $tickets_concert, $tickets_ns, $price)
{
    global $servername, $username, $password, $dbname;
    $conn = new mysqli($servername, $username, $password, $dbname);
     */
    $profiles = $mollie->profiles->all();
    $profile = reset($profiles);
    /*
     * Payment parameters:
     *   amount        Amount in EUROs. This example creates a � 10,- payment.
     *   description   Description of the payment.
     *   redirectUrl   Redirect location. The customer will be redirected there after the payment.
     *   webhookUrl    Webhook location, used to report when the payment changes state.
     *   metadata      Custom metadata that is stored with the payment.
     */
    $payment = $mollie->payments->create(array("amount" => 10.0, "description" => "My first API payment", "redirectUrl" => "{$protocol}://{$hostname}{$path}/03-return-page.php?order_id={$order_id}", "webhookUrl" => "{$protocol}://{$hostname}{$path}/02-webhook-verification.php", "metadata" => array("order_id" => $order_id), "profileId" => $profile->id));
    /*
     * In this example we store the order with its payment status in a database.
     */
    database_write($order_id, $payment->status);
    /*
     * Send the customer off to complete the payment.
     */
    if (PHP_SAPI === "cli") {
        echo "Redirect to: " . $payment->getPaymentUrl() . PHP_EOL;
        return;
    }
    header("Location: " . $payment->getPaymentUrl());
} catch (Mollie_API_Exception $e) {
    echo "API call failed: " . htmlspecialchars($e->getMessage());
}
/*
 * NOTE: This example uses a text file as a database. Please use a real database like MySQL in production code.
 */
function database_write($order_id, $status)
Exemplo n.º 3
0
     */
    require "initialize.php";
    /*
     * Check if this is a test request by Mollie
     */
    if (!empty($_GET['testByMollie'])) {
        die('OK');
    }
    /*
     * Retrieve the payment's current state.
     */
    $payment = $mollie->payments->get($_POST["id"]);
    /*
     * Update the order in the database.
     */
    database_write($payment->id, $payment->status, intval($payment->metadata->time));
} catch (Mollie_API_Exception $e) {
    echo "API call failed: " . htmlspecialchars($e->getMessage());
}
/*
 * NOTE: This example uses a text file as a database. Please use a real database like MySQL in production code.
 */
function database_write($payment_id, $status, $time)
{
    global $servername, $username, $password, $dbname;
    $conn = new mysqli($servername, $username, $password, $dbname);
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = $conn->prepare("UPDATE orders SET status=? WHERE payment_id=? AND unix_time=?");
    $sql->bind_param("ssi", $status, $payment_id, $time);