* @requirements PHP 5.3 and higher * @version 1.0 * @lastmodified June 19, 2015 * */ // Include WB config.php file, WB admin class and mollie class require '../../../../config.php'; require_once WB_PATH . '/framework/class.admin.php'; require_once dirname(__FILE__) . "/Mollie/API/Autoloader.php"; $payment_method = "molliev2"; if (isset($_SESSION['bakery'][$payment_method]['amount'])) { $partner_id = $_SESSION['bakery'][$payment_method]['partner_id']; $amount = $_SESSION['bakery'][$payment_method]['amount']; $description = $_SESSION['bakery'][$payment_method]['description']; $return_url = $_SESSION['bakery'][$payment_method]['return_url']; $report_url = $_SESSION['bakery'][$payment_method]['report_url']; $order_id = $_SESSION['bakery']['order_id']; try { $mollie = new Mollie_API_Client(); $mollie->setApiKey($partner_id); $payment = $mollie->payments->create(array("amount" => $amount, "description" => $description, "webhookUrl" => $report_url, "redirectUrl" => $return_url, "metadata" => array("order_id" => $order_id))); // Update transaction_id in customer table $transaction_id = $payment->id; $database->query("UPDATE " . TABLE_PREFIX . "mod_bakery_customer SET transaction_id = '{$transaction_id}' WHERE order_id = '{$order_id}'"); header("Location: " . $payment->getPaymentUrl()); exit; } catch (Mollie_API_Exception $e) { header('location: ' . $_POST['setting_continue_url'] . '?pay_error=1'); exit; } }
/** * @return \Mollie_API_Client * @throws \Mollie_API_Exception */ public function client() { $mollie = new \Mollie_API_Client(); $mollie->setApiKey($this->config['apiKeys']['live']); if ($this->config['testMode']) { $mollie->setApiKey($this->config['apiKeys']['test']); } return $mollie; }
public function __construct() { parent::__construct(); $this->displayName = $this->l('Mollie Payment Module'); $this->description = $this->l('Mollie Payments'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall the Mollie Payment Module?'); require_once dirname(__FILE__) . '/lib/src/Mollie/API/Autoloader.php'; try { $this->api = new Mollie_API_Client(); $this->api->setApiKey($this->getConfigValue('MOLLIE_API_KEY')); $this->api->addVersionString('Prestashop/' . (defined('_PS_VERSION_') ? _PS_VERSION_ : 'Unknown')); $this->api->addVersionString('MolliePrestashop/' . (isset($this->version) ? $this->version : 'Unknown')); } catch (Mollie_API_Exception_IncompatiblePlatform $e) { Logger::addLog(__METHOD__ . ' - System incompatible: ' . $e->getMessage(), Mollie::CRASH); } catch (Mollie_API_Exception $e) { $this->warning = $this->l('Payment error:') . $e->getMessage(); Logger::addLog(__METHOD__ . ' said: ' . $this->warning, Mollie::CRASH); } $this->statuses = array(Mollie_API_Object_Payment::STATUS_PAID => $this->getConfigValue('MOLLIE_STATUS_PAID'), Mollie_API_Object_Payment::STATUS_CANCELLED => $this->getConfigValue('MOLLIE_STATUS_CANCELLED'), Mollie_API_Object_Payment::STATUS_EXPIRED => $this->getConfigValue('MOLLIE_STATUS_EXPIRED'), Mollie_API_Object_Payment::STATUS_REFUNDED => $this->getConfigValue('MOLLIE_STATUS_REFUNDED'), Mollie_API_Object_Payment::STATUS_OPEN => $this->getConfigValue('MOLLIE_STATUS_OPEN')); // Load all translatable text here so we have a single translation point $this->lang = array(Mollie_API_Object_Payment::STATUS_PAID => $this->l('paid'), Mollie_API_Object_Payment::STATUS_CANCELLED => $this->l('cancelled'), Mollie_API_Object_Payment::STATUS_EXPIRED => $this->l('expired'), Mollie_API_Object_Payment::STATUS_REFUNDED => $this->l('refunded'), Mollie_API_Object_Payment::STATUS_OPEN => $this->l('bankwire pending'), 'This payment method is not available.' => $this->l('This payment method is not available.'), 'Click here to continue' => $this->l('Click here to continue'), 'This payment method is only available for Euros.' => $this->l('This payment method is only available for Euros.'), 'There was an error while processing your request: ' => $this->l('There was an error while processing your request: '), 'The order with this id does not exist.' => $this->l('The order with this id does not exist.'), 'We have not received a definite payment status. You will be notified as soon as we receive a confirmation of the bank/merchant.' => $this->l('We have not received a definite payment status. You will be notified as soon as we receive a confirmation of the bank/merchant.'), 'You have cancelled your payment.' => $this->l('You have cancelled your payment.'), 'Unfortunately your payment was expired.' => $this->l('Unfortunately your payment was expired.'), 'Thank you. Your payment has been received.' => $this->l('Thank you. Your payment has been received.'), 'The transaction has an unexpected status.' => $this->l('The transaction has an unexpected status.'), 'You are not authorised to see this page.' => $this->l('You are not authorised to see this page.'), 'Continue shopping' => $this->l('Continue shopping'), 'Welcome back' => $this->l('Welcome back'), 'Select your bank:' => $this->l('Select your bank:'), 'OK' => $this->l('OK'), 'Return to the homepage' => $this->l('Return to the homepage'), 'Pay with %s' => $this->l('Pay with %s'), 'Refund this order' => $this->l('Refund this order'), 'Mollie refund' => $this->l('Mollie refund'), 'Refund order #%d through the Mollie API.' => $this->l('Refund order #%d through the Mollie API.'), 'iDEAL' => $this->l('iDEAL'), 'Creditcard' => $this->l('Creditcard'), 'Mister Cash' => $this->l('Mister Cash'), 'Bank transfer' => $this->l('Bank transfer'), 'PayPal' => $this->l('PayPal'), 'paysafecard' => $this->l('paysafecard'), 'MiniTix' => $this->l('MiniTix'), 'Micropayments' => $this->l('Micropayments')); // If an update includes a new hook, it normally takes a manual reinstall for it to take effect // This would cause all config values to reset and the Mollie table to be cleared. // $this->reinstall() fixes the hook registration without those sad side effects. $version = $this->getConfigValue('MOLLIE_VERSION'); if ($version === FALSE || version_compare($version, $this->version, '<')) { $this->reinstall(); $this->updateConfigValue('MOLLIE_VERSION', $this->version); } }
/** * Get the Mollie client. Needs the Config array for multishop to retrieve the API key. * * @param array $config * * @return Mollie_API_Client */ public static function getAPIClientAdmin($config) { require_once realpath(DIR_SYSTEM . "/..") . "/catalog/controller/extension/payment/mollie-api-client/src/Mollie/API/Autoloader.php"; $mollie = new Mollie_API_Client(); $mollie->setApiKey(isset($config['mollie_api_key']) ? $config['mollie_api_key'] : null); $mollie->addVersionString("OpenCart/" . VERSION); $mollie->addVersionString("MollieOpenCart/" . self::PLUGIN_VERSION); return $mollie; }
/** * Get the Mollie client. Needs the Config object to retrieve the API key. * * @param Config $config * * @return Mollie_API_Client */ public static function getAPIClient($config) { if (!self::$api_client && self::apiClientFound()) { require_once realpath(DIR_SYSTEM . "/..") . "/catalog/controller/payment/mollie-api-client/src/Mollie/API/Autoloader.php"; $mollie = new Mollie_API_Client(); $mollie->setApiKey($config->get('mollie_api_key')); $mollie->addVersionString("OpenCart/" . VERSION); $mollie->addVersionString("MollieOpenCart/" . self::PLUGIN_VERSION); self::$api_client = $mollie; } return self::$api_client; }
/** * @param bool $test_mode * @return Mollie_API_Client * @throws Mollie_WC_Exception_InvalidApiKey */ public function getApiClient($test_mode = false) { global $wp_version; $api_key = $this->settings_helper->getApiKey($test_mode); if (empty($api_key)) { throw new Mollie_WC_Exception_InvalidApiKey(__('No API key provided.', 'mollie-payments-for-woocommerce')); } elseif (!preg_match('/^(live|test)_\\w+$/', $api_key)) { throw new Mollie_WC_Exception_InvalidApiKey(__('Invalid API key. The API key must start with \'live_\' or \'test_\' and can\'t further contain any special characters.', 'mollie-payments-for-woocommerce')); } if (empty(self::$api_client)) { $client = new Mollie_API_Client(); $client->setApiKey($api_key); $client->setApiEndpoint(self::getApiEndpoint()); $client->addVersionString('WordPress/' . (isset($wp_version) ? $wp_version : 'Unknown')); $client->addVersionString('WooCommerce/' . get_option('woocommerce_version', 'Unknown')); $client->addVersionString('MollieWoo/' . Mollie_WC_Plugin::PLUGIN_VERSION); self::$api_client = $client; } return self::$api_client; }
<?php /** * Created by PhpStorm. * User: Wouter * Date: 29-1-2016 * Time: 15:06 */ //create mollie api client $mollie = new Mollie_API_Client(); //insert api key $mollie->setApiKey("test_knXSwBN55uqRwLNHeGH2nHGsYZDi7d"); //creates a new payment and adds it to the list of payments $payment = $mollie->payments->create(array("amount" => 0.01, "description" => "My first API payment", "redirectUrl" => "http://google.nl")); //refresh the payment we just made $payment = $mollie->payments->get($payment->id); //if payment is paid, then echo something. if ($payment->isPaid()) { echo "Payment received!"; } //get a list if issuers (banks which support iDeal). This is a list of Mollie_API_Object_Issuer objects $issuers = $mollie->issuers->all(); /* * The Mollie_API_Object_Issuer object has an id, a name */ //Create an iDeal Payment $ideal_payment = $mollie->payments->create(array("amount" => 0.01, "description" => "My first API payment with iDeal", "redirectUrl" => "http://nos.nl", "method" => Mollie_API_Object_Method::IDEAL, "issuer" => $selected_issuer_id)); /* * Example 6 - How to get the currently activated payment methods. */ try {
<?php require_once dirname(__FILE__) . "/../src/Mollie/API/Autoloader.php"; /* * Initialize the Mollie API library with your API key. * * See: https://www.mollie.com/beheer/account/profielen/ */ $mollie = new Mollie_API_Client(); $mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
/** * @param NULL|string $key * * @return Mollie_API_Client * @throws Mollie_API_Exception */ public function _getMollieAPI($key = NULL) { $this->_setAutoLoader(); $key = $key === NULL ? $this->getApiKey() : $key; $api = new Mollie_API_Client(); $api->setApiKey($key); $api->addVersionString('Magento/' . Mage::getVersion()); $api->addVersionString('MollieMagento/' . $this->getExtensionVersion()); return $api; }
/** * @param null|string $key * @return Mollie_API_Client * @throws Mollie_API_Exception */ public function _getMollieAPI($key = null) { $this->_setAutoLoader(); $key = $key === null ? $this->getApiKey() : $key; $api = new Mollie_API_Client(); $api->setApiKey($key); $api->addVersionString('Magento/' . Mage::getVersion()); $api->addVersionString('MollieMagento/' . self::PLUGIN_VERSION); return $api; }
function eme_mollie_notification() { $api_key = get_option('eme_mollie_api_key'); require_once 'payment_gateways/Mollie/API/Autoloader.php'; $mollie = new Mollie_API_Client(); $mollie->setApiKey($api_key); $payment = $mollie->payments->get($_POST["id"]); $payment_id = $payment->metadata->payment_id; if ($payment->isPaid()) { eme_update_payment_payed($payment_id); } }
<div class="container wb" style="margin-top:30px;margin-bottom:30px"> <div class="row centered"> <div class="timeline-panel debits" style="border: 1px solid #d4d4d4; border-radius: 3px; background-color: #FFFFFF; color: #666; padding: 20px; position: relative; -webkit-box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.175); margin:20px; margin-bottom:70px;"> <span class="causale"> <?php $mollie = new Mollie_API_Client(); $mollie->setApiKey(Config::get('mollie.api_key')); $issuers = $mollie->issuers->all(); ?> {{ Form::open(array('route' => 'ideal')) }} <label for="issuer">Kies uw bank:</label> <select class="form-control" style="text-align: center;" name="issuer">'; <?php foreach ($issuers as $issuer) { if ($issuer->method == Mollie_API_Object_Method::IDEAL) { echo '<option value=' . htmlspecialchars($issuer->id) . '>' . htmlspecialchars($issuer->name) . '</option>'; } } ?> {{ Form::hidden('studentnummer', $studentNummer) }} </select><button type="submit" class="btn btn-default" style="margin-top: 20px;">Betaal</button> {{ Form::close() }}
function mollie_link($params, $method = Mollie_API_Object_Method::IDEAL) { global $whmcs; /** * * Setting requirements and includes * */ if (substr($params['returnurl'], 0, 1) == '/') { $params['returnurl'] = $params['systemurl'] . $params['returnurl']; } if (empty($params['language'])) { $params['language'] = isset($_SESSION['language']) ? $_SESSION['language'] : $whmcs->get_config('Language'); } if (empty($params['language'])) { $params['language'] = 'english'; } if (!file_exists(__DIR__ . '/lang/' . $params['language'] . '.php')) { $params['language'] = 'english'; } /* @var array $_GATEWAYLANG */ require __DIR__ . '/lang/' . $params['language'] . '.php'; $tableCheckQuery = full_query('SHOW TABLES LIKE \'gateway_mollie\''); if (mysql_num_rows($tableCheckQuery) != 1) { full_query('CREATE TABLE IF NOT EXISTS `gateway_mollie` (`id` int(11) NOT NULL AUTO_INCREMENT, `paymentid` varchar(15), `amount` double NOT NULL, `currencyid` int(11) NOT NULL, `ip` varchar(50) NOT NULL, `userid` int(11) NOT NULL, `invoiceid` int(11) NOT NULL, `status` ENUM(\'open\',\'paid\',\'closed\') NOT NULL DEFAULT \'open\', `method` VARCHAR(25) NOT NULL, `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `updated` timestamp NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `paymentid` (`paymentid`)) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;'); } $mollie = new Mollie_API_Client(); $mollie->setApiKey($params['key']); /** * * Check if good state to open transaction. * */ if (isset($_GET['check_payment']) && ctype_digit($_GET['check_payment'])) { $transactionQuery = select_query('gateway_mollie', '', array('id' => $_GET['check_payment']), null, null, 1); if (mysql_num_rows($transactionQuery) != 1) { return '<p>' . $_GATEWAYLANG['errorTransactionNotFound'] . '</p>'; } $transaction = mysql_fetch_assoc($transactionQuery); if ($transaction['status'] == 'paid') { header('location: ' . $params['returnurl'] . '&paymentsuccess=true'); exit; } else { if ($transaction['status'] == 'closed') { header('location: ' . $params['returnurl'] . '&paymentfailed=true'); exit; } else { return '<br/><img src="' . $params['systemurl'] . '/modules/gateways/mollie/ajax_loader.gif" /><br/>' . $_GATEWAYLANG['checkPayment'] . ' <script> window.onload = function(){ setTimeout("location.reload(true);", 2000); } </script>'; } } } else { if (isset($_POST['start']) || isset($_GET['a']) && $_GET['a'] == 'complete' || isset($_GET['action']) && ($_GET['action'] == 'addfunds' || $_GET['action'] == 'masspay') && isset($_POST['paymentmethod']) && $_POST['paymentmethod'] == 'mollie' . $method) { $transactionCurrency = select_query('tblcurrencies', '', array('code' => $params['currency']), null, null, 1); $transactionCurrency = mysql_fetch_assoc($transactionCurrency); $transactionId = insert_query('gateway_mollie', array('amount' => $params['amount'], 'currencyid' => $transactionCurrency['id'], 'ip' => $_SERVER['REMOTE_ADDR'], 'userid' => $params['clientdetails']['userid'], 'invoiceid' => $params['invoiceid'], 'method' => $method)); $payment = $mollie->payments->create(array('amount' => $params['amount'], 'method' => $method, 'description' => $params['description'], 'redirectUrl' => $params['returnurl'] . '&check_payment=' . $transactionId, 'webhookUrl' => $params['systemurl'] . '/modules/gateways/mollie/callback.php', 'metadata' => array('invoice_id' => $params['invoiceid']), 'issuer' => isset($_POST['issuer']) && !empty($_POST['issuer']) ? $_POST['issuer'] : NULL)); update_query('gateway_mollie', array('paymentid' => $payment->id), array('id' => $transactionId)); header('Location: ' . $payment->getPaymentUrl()); exit; } else { $return = '<form action="" method="POST">'; if ($method == Mollie_API_Object_Method::IDEAL) { $issuers = $mollie->issuers->all(); $return .= '<label for="issuer">' . $_GATEWAYLANG['selectBank'] . ':</label> '; $return .= '<select name="issuer">'; foreach ($issuers as $issuer) { if ($issuer->method == Mollie_API_Object_Method::IDEAL) { $return .= '<option value=' . htmlspecialchars($issuer->id) . '>' . htmlspecialchars($issuer->name) . '</option>'; } } $return .= '</select>'; } $return .= '<input type="submit" name="start" value="' . $_GATEWAYLANG['payWith' . ucfirst($method)] . '" /></form>'; return $return; } } }
exit; } $transaction = mysql_fetch_assoc($transactionQuery); $_GATEWAY = getGatewayVariables('mollie' . $transaction['method']); if ($transaction['status'] != 'open') { logTransaction($_GATEWAY['paymentmethod'], array_merge($transaction, $_POST), 'Callback - Failure 3 (Transaction not open)'); header('HTTP/1.1 500 Transaction not open'); exit; } // Get user and transaction currencies $userCurrency = getCurrency($transaction['userid']); $transactionCurrency = select_query('tblcurrencies', '', array('id' => $transaction['currencyid'])); $transactionCurrency = mysql_fetch_assoc($transactionCurrency); // Check payment $mollie = new Mollie_API_Client(); $mollie->setApiKey($_GATEWAY['key']); $payment = $mollie->payments->get($_POST['id']); if ($payment->isPaid()) { // Add conversion, when there is need to. WHMCS only supports currencies per user. WHY?! if ($transactionCurrency['id'] != $userCurrency['id']) { $transaction['amount'] = convertCurrency($transaction['amount'], $transaction['currencyid'], $userCurrency['id']); } // Check invoice $invoiceid = checkCbInvoiceID($transaction['invoiceid'], $_GATEWAY['paymentmethod']); checkCbTransID($transaction['paymentid']); // Add invoice addInvoicePayment($invoiceid, $transaction['paymentid'], $transaction['amount'], '', $_GATEWAY['paymentmethod']); update_query('gateway_mollie', array('status' => 'paid', 'updated' => date('Y-m-d H:i:s', time())), array('id' => $transaction['id'])); logTransaction($_GATEWAY['paymentmethod'], array_merge($transaction, $_POST), 'Callback - Successful (Paid)'); header('HTTP/1.1 200 OK'); exit;
public function updatePayment() { $payment = false; $mollie = new Mollie_API_Client(); $mollie->setApiKey($this->getApiKey()); $transaction = new TransactionModel(); $changed = false; // see if we are here for the webhook or user return url $mollie_id = Ajde::app()->getRequest()->getPostParam('id', false); // from webhook $order_id = Ajde::app()->getRequest()->getParam('order_id', false); // from user request if (!$mollie_id && $order_id) { // load from order_id $transaction->loadByField('secret', $order_id); $mollie_id = $transaction->payment_providerid; try { $payment = $mollie->payments->get($mollie_id); } catch (Mollie_API_Exception $e) { Ajde_Exception_Log::logException($e); $payment = false; } } else { if ($mollie_id) { // laod from mollie transaction id try { $payment = $mollie->payments->get($mollie_id); $order_id = $payment->metadata->order_id; $transaction->loadByField('secret', $order_id); } catch (Mollie_API_Exception $e) { Ajde_Exception_Log::logException($e); $payment = false; } } } if (!$payment || !$mollie_id || !$order_id || !$transaction->hasLoaded()) { Ajde_Log::log('Could not find transaction for Mollie payment for mollie id ' . $mollie_id . ' and transaction secret ' . $order_id); return ['success' => false, 'changed' => $changed, 'transaction' => $transaction]; } // what to return? $paid = false; $payment_details = $payment->details; if (is_object($payment_details) || is_array($payment_details)) { $payment_details = json_encode($payment_details); } // save details $details = 'PAYMENT STATUS: ' . (string) $payment->status . PHP_EOL . 'PAYMENT AMOUNT: ' . (string) $payment->amount . PHP_EOL . 'PAYMENT AT: ' . (string) $payment->paidDatetime . PHP_EOL . 'CANCELLED AT: ' . (string) $payment->cancelledDatetime . PHP_EOL . 'EXPIRED AT: ' . (string) $payment->expiredDatetime . PHP_EOL . 'PAYER DETAILS: ' . (string) $payment_details; $transaction->payment_details = $details; switch ($payment->status) { case 'open': if ($transaction->payment_status != 'requested') { $transaction->payment_status = 'requested'; $transaction->save(); $changed = true; } break; case 'paidout': case 'paid': $paid = true; // update transaction only once if ($transaction->payment_status != 'completed') { $transaction->paid(); $changed = true; } break; case 'cancelled': // update transaction only once if ($transaction->payment_status != 'cancelled') { $transaction->payment_status = 'cancelled'; $transaction->save(); $changed = true; } break; case 'expired': // update transaction only once if ($transaction->payment_status != 'refused') { $transaction->payment_status = 'refused'; $transaction->save(); $changed = true; } break; } return ['success' => $paid, 'changed' => $changed, 'transaction' => $transaction]; }
function bizz_check_mollie_response() { if (isset($_GET['mollie']) && $_GET['mollie'] != '') { // variables try { // Initialize require_once dirname(__FILE__) . "/mollie-api/src/Mollie/API/Autoloader.php"; $mollie = new Mollie_API_Client(); $api = $opt_s['pay_mollie_api'] != '' ? $opt_s['pay_mollie_api'] : 'test_W9vJrPAB2Jv4LGRZkGZgLmkznzDAs2'; $mollie->setApiKey($api); // Retrieve the payment's current state. $payment = $mollie->payments->get($_POST["id"]); $order_id = $payment->metadata->order_id; $post_id = $payment->metadata->post_id; // get booking meta $booking_custom = get_post_custom($post_id); foreach ($booking_custom as $key => $value) { $bookopts[$key] = $value[0]; } // Update the order in the database. if ($payment->isPaid() == TRUE) { /* * At this point you'd probably want to start the process of delivering the product to the customer. */ update_post_meta($post_id, 'bizzthemes_bookings_status', 'approved'); booking_send_notification('approved', $bookopts); } elseif ($payment->isOpen() == FALSE) { /* * The payment isn't paid and isn't open anymore. We can assume it was aborted. */ update_post_meta($post_id, 'bizzthemes_bookings_status', 'cancelled'); booking_send_notification('cancelled', $bookopts); } } catch (Mollie_API_Exception $e) { echo "API call failed: " . htmlspecialchars($e->getMessage()); } } }