/** * 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); } }
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); } }
* 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>"; }
* 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(); }