Exemple #1
0
 /**
  * Create an instance
  * @since version 1.0.0
  * @access public
  * @return instance of self
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 protected function processBasic(\Icepay_PaymentObject_Interface_Abstract $paymentObject)
 {
     try {
         $basicmode = \Icepay_Basicmode::getInstance()->setMerchantID((string) $this->merchantId)->setSecretCode((string) $this->secretCode)->validatePayment($paymentObject);
         $this->url = $basicmode->getURL();
         $this->icepayTransactionId = null;
         $this->providerTransactionId = null;
         $this->testMode = null;
     } catch (\Exception $e) {
         throw new ApiException('There was a problem processing the basic payment', 0, $e);
     }
 }
Exemple #3
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);
     }
 }
Exemple #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();
 }
Exemple #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();
}
Exemple #6
0
 /**
  * Start an transaction
  *
  * @see Pronamic_WP_Pay_Gateway::start()
  */
 public function start(Pronamic_Pay_Payment $payment)
 {
     try {
         $locale = $payment->get_locale();
         $language = strtoupper(substr($locale, 0, 2));
         $country = strtoupper(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($payment->get_amount()))->setCountry($country)->setLanguage($language)->setReference($payment->get_order_id())->setDescription($payment->get_description())->setCurrency($payment->get_currency())->setIssuer($payment->get_issuer())->setOrderID($payment->get_id());
         /*
          * Payment method
          * @since 1.2.0
          */
         $icepay_method = null;
         switch ($payment->get_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::BANCONTACT:
             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);
     }
 }
Exemple #7
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;
 }