Esempio n. 1
0
 /**
  * Start an transaction
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_PaymentDataInterface $data, Pronamic_Pay_Payment $payment, $payment_method = null)
 {
     try {
         $locale = $data->get_language_and_country();
         $language = substr($locale, 0, 2);
         $country = substr($locale, 3, 2);
         /*
          * Order ID
          * Your unique order number.
          * This can be auto incremental number from your payments table
          *
          * Data type  = String
          * Max length = 10
          * Required   = Yes
          */
         // Payment object
         $payment_object = new Icepay_PaymentObject();
         $payment_object->setAmount(Pronamic_WP_Pay_Util::amount_to_cents($data->get_amount()))->setCountry($country)->setLanguage($language)->setReference($data->get_order_id())->setDescription($data->get_description())->setCurrency($data->get_currency())->setIssuer($data->get_issuer_id())->setOrderID($payment->get_id());
         // Payment method
         // @since 1.2.0
         $icepay_method = null;
         switch ($payment_method) {
             case Pronamic_WP_Pay_PaymentMethods::CREDIT_CARD:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/creditcard.php
                 $icepay_method = new Icepay_Paymentmethod_Creditcard();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::DIRECT_DEBIT:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ddebit.php
                 $icepay_method = new Icepay_Paymentmethod_Ddebit();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::IDEAL:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/ideal.php
                 $icepay_method = new Icepay_Paymentmethod_Ideal();
                 break;
             case Pronamic_WP_Pay_PaymentMethods::MISTER_CASH:
                 // @see https://github.com/icepay/icepay/blob/2.4.0/api/paymentmethods/mistercash.php
                 $icepay_method = new Icepay_Paymentmethod_Mistercash();
                 break;
         }
         if (isset($icepay_method)) {
             // @see https://github.com/icepay/icepay/blob/2.4.0/api/icepay_api_base.php#L342-L353
             $payment_object->setPaymentMethod($icepay_method->getCode());
         }
         // Protocol
         $protocol = is_ssl() ? 'https' : 'http';
         // Basic mode
         $basicmode = Icepay_Basicmode::getInstance();
         $basicmode->setMerchantID($this->config->merchant_id)->setSecretCode($this->config->secret_code)->setProtocol($protocol)->validatePayment($payment_object);
         // Payment
         $payment->set_action_url($basicmode->getURL());
     } catch (Exception $exception) {
         $this->error = new WP_Error('icepay_error', $exception->getMessage(), $exception);
     }
 }
Esempio n. 2
0
 public function form()
 {
     $billingService = BOL_BillingService::getInstance();
     $adapter = new OCSBILLINGICEPAY_CLASS_IcepayAdapter();
     $lang = OW::getLanguage();
     $sale = $billingService->getSessionSale();
     if (!$sale) {
         $url = $billingService->getSessionBackUrl();
         if ($url != null) {
             OW::getFeedback()->warning($lang->text('base', 'billing_order_canceled'));
             $billingService->unsetSessionBackUrl();
             $this->redirect($url);
         } else {
             $this->redirect($billingService->getOrderFailedPageUrl());
         }
     }
     $productAdapter = $billingService->getProductAdapter($sale->entityKey);
     if ($productAdapter) {
         $productUrl = $productAdapter->getProductOrderUrl();
     }
     if ($billingService->prepareSale($adapter, $sale)) {
         $country = $adapter->detectCountry();
         $language = $adapter->getLanguageByCountry($country);
         require_once OW::getPluginManager()->getPlugin('ocsbillingicepay')->getClassesDir() . 'api' . DS . 'icepay_api_basic.php';
         try {
             if (!$country) {
                 $country = '00';
             }
             $paymentObj = new Icepay_PaymentObject();
             $paymentObj->setAmount($sale->totalAmount * 100)->setCountry($country)->setLanguage($language)->setReference($sale->hash)->setDescription(strip_tags($sale->entityDescription))->setCurrency($sale->currency)->setOrderID($sale->id);
             $gwKey = OCSBILLINGICEPAY_CLASS_IcepayAdapter::GATEWAY_KEY;
             $merchantId = $billingService->getGatewayConfigValue($gwKey, 'merchantId');
             $encryptionCode = $billingService->getGatewayConfigValue($gwKey, 'encryptionCode');
             $basicmode = Icepay_Basicmode::getInstance();
             $basicmode->setMerchantID($merchantId)->setSecretCode($encryptionCode)->validatePayment($paymentObj);
             $url = $basicmode->getURL();
             $billingService->unsetSessionSale();
             header("Location: " . $url);
             exit;
         } catch (Exception $e) {
             OW::getFeedback()->warning($e->getMessage());
             $url = isset($productUrl) ? $productUrl : $billingService->getOrderFailedPageUrl();
             $this->redirect($url);
         }
     } else {
         OW::getFeedback()->warning($lang->text('base', 'billing_order_init_failed'));
         $url = isset($productUrl) ? $productUrl : $billingService->getOrderFailedPageUrl();
         $this->redirect($url);
     }
 }
Esempio n. 3
0
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Esempio n. 4
0
 /**
  * Get the payment url
  *
  * @param OrderInterface $order
  * @return string url
  */
 public function getPaymentURL(OrderInterface $order)
 {
     $icepay_config = \Drupal::config("uc_icepay.settings");
     $country = $icepay_config->get("country");
     $language = $icepay_config->get("language");
     $merchant_id = $icepay_config->get("merchant_id");
     $secret_code = $icepay_config->get("secret_code");
     $protocol = $icepay_config->get("https_protocol");
     $paymentObj = new \Icepay_PaymentObject();
     $paymentObj->setOrderID($order->id() . date('is'))->setReference($order->id())->setAmount(intval($order->getTotal() * 100))->setCurrency($order->getCurrency())->setCountry($country)->setLanguage($language);
     $payment_plugin_id = IcepayApi::getPaymentPluginId($order->getPaymentMethodId());
     $payment_method = IcepayApi::paymentPluginToIcepayPaymentMethod($payment_plugin_id);
     $paymentObj->setPaymentMethod($payment_method);
     if (isset($order->payment_details['ideal_issuer'])) {
         $paymentObj->setIssuer($order->payment_details['ideal_issuer']);
     }
     $basicmode = \Icepay_Basicmode::getInstance();
     $basicmode->setMerchantID($merchant_id)->setSecretCode($secret_code)->validatePayment($paymentObj);
     $protocol = $protocol == true ? 'https' : 'http';
     $basicmode->setProtocol($protocol);
     return $basicmode->getURL();
 }
Esempio n. 5
0
define('MERCHANTID', 12345);
//<--- Change this into your own merchant ID
define('SECRETCODE', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//<--- Change this into your own merchant ID
// Include the API into your project
require_once '../src/icepay_api_basic.php';
/* Apply logging rules */
$logger = Icepay_Api_Logger::getInstance();
$logger->enableLogging()->setLoggingLevel(Icepay_Api_Logger::LEVEL_ALL)->logToFile()->setLoggingDirectory(realpath("../logs"))->setLoggingFile("idealsample.txt")->logToScreen();
// Read paymentmethods from folder and ensures the classes are included
$api = Icepay_Api_Basic::getInstance()->readFolder(realpath('../src/paymentmethods'));
// Store all paymentmethods in an array, as an example for loading programmatically
$paymentmethods = $api->getArray();
// Start a new paymentmethod class
$ideal = new $paymentmethods["ideal"]();
//The same as: $ideal = new Icepay_Paymentmethod_Ideal();
// Retrieve the paymentmethod issuers for this example
$issuers = $ideal->getSupportedIssuers();
try {
    /* Set the payment */
    $paymentObj = new Icepay_PaymentObject();
    $paymentObj->setPaymentMethod($ideal->getCode())->setAmount(1000)->setCountry("NL")->setLanguage("NL")->setReference("My Sample Website")->setDescription("My Sample Payment")->setCurrency("EUR")->setIssuer($issuers[0])->setOrderID(1);
    // Merchant Settings
    $basicmode = Icepay_Basicmode::getInstance();
    $basicmode->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE)->setProtocol('http')->validatePayment($paymentObj);
    // <--- Required!
    // 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();
}
Esempio n. 6
0
// Read paymentmethods from folder, load the classes and filter the data
$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.
 *  a particular purpose and non-infringement. In no event shall the
 *  authors or copyright holders be liable for any claim, damages or
 *  other liability, whether in an action of contract, tort or otherwise,
 *  arising from, out of or in connection with the software or the use
 *  of other dealings in the software.
 *
 */
/*  Define your ICEPAY Merchant ID and Secret code. The values below are sample values and will not work, Change them to your own merchant settings. */
define('MERCHANTID', 12345);
//<--- Change this into your own merchant ID
define('SECRETCODE', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//<--- Change this into your own merchant ID
define('PINCODE', 123456);
// Include the API into your project
require_once '../api/icepay_api_webservice.php';
/* Set the payment */
$paymentObj = new Icepay_PaymentObject();
$paymentObj->setCountry('NL')->setLanguage("EN")->setCurrency("EUR")->setAmount(300)->setPaymentMethod("SMS")->setIssuer("DEFAULT")->setOrderID(1);
try {
    // Set the service
    $service = Icepay_Api_Webservice::getInstance()->paymentService();
    // Merchant Settings
    $service->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE);
    /* Start the transaction */
    $data = $service->SmsCheckout($paymentObj);
    var_dump($data);
} catch (Exception $e) {
    echo $e->getMessage();
}
?>
</pre>
Esempio n. 8
0
 /**
  * Create a new payment with Icepay
  * @param string $method The method used for the payment as returned from the list of payments
  * @param string $amount The amount of the payment
  * @param string $orderID The order ID
  * @param string|null $description A description of the payment
  * @param string|null $issuer The issuer of the payment method, if applicable
  * @param string|null $reference A reference for the payment
  * @return bool|string The URL to redirect for the payment if successful, false if unsuccessful
  * @throws \Exception
  */
 public function createPayment($method, $amount, $orderID, $description = null, $issuer = null, $reference = null)
 {
     $methodName = '\\Icepay_Paymentmethod_' . ucfirst(strtolower($method));
     $paymentMethod = new $methodName();
     $payment = new \Icepay_PaymentObject();
     $payment->setPaymentMethod($paymentMethod->getCode())->setAmount($amount)->setOrderID($orderID)->setDescription($description)->setReference($reference)->setLanguage($this->language)->setCountry($this->country)->setCurrency($this->currency)->setIssuer($issuer);
     $basicMode = \Icepay_Basicmode::getInstance();
     $basicMode->setMerchantId($this->merchantID)->setSecretCode($this->secretCode)->setProtocol('https')->validatePayment($payment);
     try {
         return $basicMode->getURL();
     } catch (\Exception $e) {
         \Yii::error($e->getMessage());
     }
     return false;
 }
 *  Disclaimer:
 *  These sample scripts are used for training purposes only and
 *  should not be used in a live environment. The software is provided
 *  "as is", without warranty of any kind, express or implied, including
 *  but not limited to the warranties of merchantability, fitness for
 *  a particular purpose and non-infringement. In no event shall the
 *  authors or copyright holders be liable for any claim, damages or
 *  other liability, whether in an action of contract, tort or otherwise,
 *  arising from, out of or in connection with the software or the use
 *  of other dealings in the software.
 *
 */
// Define your ICEPAY Merchant ID and Secret code. The values below are sample values and will not work, Change them to your own merchant settings.
define('MERCHANTID', 'xxxxxx');
define('SECRETCODE', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
// Include the API into your project
require_once '../api/icepay_api_webservice.php';
$address = Icepay_Order_Address::create()->setInitials('Dhr.')->setPrefix('')->setLastName('Kwek')->setStreet('Zandstraat')->setHouseNumber('22')->setHouseNumberAddition('')->setZipCode('1058EA')->setCity('Amsterdam')->setCountry('NL');
Icepay_Order::getInstance()->setConsumer(Icepay_Order_Consumer::create()->setConsumerID('1')->setEmail('*****@*****.**')->setPhone('0611223344'))->setShippingAddress($address)->setBillingAddress($address)->addProduct(Icepay_Order_Product::create()->setProductID('1')->setProductName('iPhone')->setDescription('Test Description')->setQuantity('1')->setUnitPrice('200')->setVATCategory(Icepay_Order_VAT::getCategoryForPercentage(21)))->setShippingCosts(200);
$paymentObj = new Icepay_PaymentObject();
$paymentObj->setAmount(400)->setCountry("NL")->setLanguage("NL")->setIssuer('ACCEPTGIRO')->setPaymentMethod('AFTERPAY')->setReference("My Sample Website")->setDescription("My Sample Payment")->setCurrency("EUR")->setOrderID('test01');
try {
    $webservice = Icepay_Api_Webservice::getInstance()->paymentService();
    $webservice->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE);
    $transactionObj = $webservice->extendedCheckout($paymentObj);
    printf('<a href="%s">%s</a>', $transactionObj->getPaymentScreenURL(), $transactionObj->getPaymentScreenURL());
} catch (Exception $e) {
    echo "<pre>";
    var_dump($e);
    echo "</pre>";
}
Esempio n. 10
0
 *  should not be used in a live environment. The software is provided
 *  "as is", without warranty of any kind, express or implied, including
 *  but not limited to the warranties of merchantability, fitness for
 *  a particular purpose and non-infringement. In no event shall the
 *  authors or copyright holders be liable for any claim, damages or
 *  other liability, whether in an action of contract, tort or otherwise,
 *  arising from, out of or in connection with the software or the use
 *  of other dealings in the software.
 *
 */
/*  Define your ICEPAY Merchant ID and Secret code. The values below are sample values and will not work, Change them to your own merchant settings. */
define('MERCHANTID', 12345);
//<--- Change this into your own merchant ID
define('SECRETCODE', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//<--- Change this into your own merchant ID
// Include the API
require_once '../api/icepay_api_basic.php';
/* Apply logging rules */
$logger = Icepay_Api_Logger::getInstance();
$logger->enableLogging()->setLoggingLevel(Icepay_Api_Logger::LEVEL_ALL)->logToFile()->setLoggingDirectory(realpath("../logs"))->setLoggingFile("basicmode.txt")->logToScreen();
/* Set the paymentObject */
$paymentObj = new Icepay_PaymentObject();
$paymentObj->setAmount(1000)->setCountry("NL")->setLanguage("NL")->setReference("My Sample Website")->setDescription("My Sample Payment")->setCurrency("EUR")->setOrderID(1);
try {
    // Merchant Settings
    $basicmode = Icepay_Basicmode::getInstance();
    $basicmode->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE)->validatePayment($paymentObj);
    echo sprintf("<a href=\"%s\">%s</a>", $basicmode->getURL(), $basicmode->getURL());
} catch (Exception $e) {
    echo $e->getMessage();
}
 *  "as is", without warranty of any kind, express or implied, including
 *  but not limited to the warranties of merchantability, fitness for
 *  a particular purpose and non-infringement. In no event shall the
 *  authors or copyright holders be liable for any claim, damages or
 *  other liability, whether in an action of contract, tort or otherwise,
 *  arising from, out of or in connection with the software or the use
 *  of other dealings in the software.
 *
 */
/*  Define your ICEPAY Merchant ID and Secret code. The values below are sample values and will not work, Change them to your own merchant settings. */
define('MERCHANTID', 12345);
//<--- Change this into your own merchant ID
define('SECRETCODE', "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//<--- Change this into your own merchant ID
// Include the API into your project
require_once '../api/icepay_api_webservice.php';
/* Set the payment */
$paymentObj = new Icepay_PaymentObject();
$paymentObj->setCountry('NL')->setLanguage("EN")->setCurrency("EUR")->setAmount(300)->setPaymentMethod("IDEAL")->setIssuer("ING")->setOrderID(1);
try {
    // Set the service
    $service = Icepay_Api_Webservice::getInstance()->paymentService();
    // Merchant Settings
    $service->setMerchantID(MERCHANTID)->setSecretCode(SECRETCODE);
    /* Start the transaction */
    $transactionObj = $service->checkOut($paymentObj);
    /* Display the PaymentScreen URL */
    echo "<a href='" . $transactionObj->getPaymentScreenURL() . "'>" . $transactionObj->getPaymentScreenURL() . "</a>";
} catch (Exception $e) {
    echo $e->getMessage();
}