Esempio n. 1
0
$api = Icepay_Api_Basic::getInstance()->readFolder(realpath('../src/paymentmethods'))->prepareFiltering()->filterByCurrency("EUR")->filterByCountry("NL")->filterByAmount(1000)->filterByLanguage("EN");
// Store the filtered data in an array;
$paymentmethods = $api->getArray();
// Checking if the user selected a paymentmethod
if (isset($_POST["paymentmethod"]) && $_POST["paymentmethod"] != "") {
    $postData = $_POST["paymentmethod"];
    //load the paymentmethod class
    $paymentmethod = new $postData();
    //Store the issuers for this paymentmethod into an array
    $issuers = $paymentmethod->getSupportedIssuers();
}
if (isset($_POST["issuer"]) && $_POST["issuer"] != "") {
    try {
        /* Set the paymentObject */
        $paymentObj = new Icepay_PaymentObject();
        $paymentObj->useBasicPaymentmethodClass($paymentmethod)->setAmount(1000)->setCountry("NL")->setLanguage("NL")->setReference("My Sample Website")->setDescription("My Sample Payment")->setCurrency("EUR")->setIssuer($_POST["issuer"])->setOrderID();
        // You should always set the order ID, however, this is ommitted here for testing purposes
        // Merchant Settings
        $basicmode = Icepay_Basicmode::getInstance();
        $basicmode->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE)->validatePayment($paymentObj)->setProtocol("http");
        // <--- Remove this if you're not on a local machine
        // In this testscript we're printing the url on screen.
        echo sprintf("<a href=\"%s\">%s</a>", $basicmode->getURL(), $basicmode->getURL());
    } catch (Exception $e) {
        echo $e->getMessage();
    }
}
/* The following script displays selectboxes.
 * Once a valid paymentmethod and issuer have been selected,
 * the URL will be generated.
 * Note that no OrderID is being used for testing purposes.