function myideal_link($params) { require_once dirname(__FILE__) . "/myideal/myideal_lib.php"; require_once dirname(__FILE__) . "/myideal/ThinMPI.php"; $data = new DirectoryRequest(); $rule = new ThinMPI(); $result = $rule->ProcessRequest($data); $gatewayusername = $params['username']; $gatewaytestmode = $params['testmode']; $invoiceid = $params['invoiceid']; $description = $params['description']; $amount = $params['amount']; $duedate = $params['duedate']; $firstname = $params['clientdetails']['firstname']; $lastname = $params['clientdetails']['lastname']; $email = $params['clientdetails']['email']; $address1 = $params['clientdetails']['address1']; $address2 = $params['clientdetails']['address2']; $city = $params['clientdetails']['city']; $state = $params['clientdetails']['state']; $postcode = $params['clientdetails']['postcode']; $country = $params['clientdetails']['country']; $phone = $params['clientdetails']['phone']; $companyname = $params['companyname']; $systemurl = $params['systemurl']; $currency = $params['currency']; if (!$result->isOK()) { $code = $result->getConsumerMessage(); logTransaction("My iDEAL", $result->getErrorDetail(), "Link Error"); } else { $issuerArray = $result->getIssuerList(); if (count($issuerArray) == 0) { $code = "Lijst met banken niet beschikbaar, er is op dit moment geen betaling met iDEAL mogelijk."; } else { for ($i = 0; $i < count($issuerArray); $i++) { if ($issuerArray[$i]->issuerList == "Short") { $issuerArrayShort[] = $issuerArray[$i]; } else { $issuerArrayLong[] = $issuerArray[$i]; } } $code = "<form action=\"modules/gateways/myideal/TransReq.php\" method=\"post\" name=\"OrderForm\">" . "<select name=\"issuerID\">"; $code .= "<option value=\"0\">Kies uw bank...</option>"; for ($i = 0; $i < count($issuerArrayShort); $i++) { $code .= "<option value=\"" . $issuerArrayShort[$i]->issuerID . "\"> " . $issuerArrayShort[$i]->issuerName . " </option>"; } if (0 < count($issuerArrayLong)) { $code .= "<option value=\"0\">---Overige banken---</option>"; } for ($i = 0; $i < count($issuerArrayLong); $i++) { $code .= "<option value=\"" . $issuerArrayLong[$i]->issuerID . "\"> " . $issuerArrayLong[$i]->issuerName . " </option>"; } $code .= "</select><br />" . "<input name=\"clicksubmit\" type=\"submit\" value=\"Betaal Nu\"><br />" . ("<input name=\"grandtotal\" type=\"hidden\" value=\"" . $amount . "\">") . "<input name=\"ordernumber\" type=\"hidden\" value=\"" . substr(myideal_RandomString($invoiceid), 0, 15) . "\">" . ("<input name=\"currency\" type=\"hidden\" value=\"" . $currency . "\">") . ("<input name=\"description\" type=\"hidden\" value=\"" . $invoiceid . "\">") . "</form>"; } } return $code; }
require "../../../init.php"; $whmcs->load_function("gateway"); $whmcs->load_function("invoice"); require_once dirname(__FILE__) . "/myideal_lib.php"; require_once dirname(__FILE__) . "/ThinMPI.php"; $GATEWAY = getGatewayVariables("myideal"); if (!$GATEWAY['type']) { exit("Module Not Activated"); } $urltowhmcs = $CONFIG['SystemURL'] . "/"; $whmcslogo = $CONFIG['LogoURL']; $data = new AcquirerStatusRequest(); $transID = $_GET['trxid']; $transID = str_pad($transID, 16, "0"); $data->setTransactionID($transID); $rule = new ThinMPI(); $result = $rule->ProcessRequest($data); if (!$result->isOK()) { $error_message = $result->getErrorMessage(); } else { if (!$result->isAuthenticated()) { $error_message = "Uw bestelling is helaas niet betaald, probeer het nog eens"; } else { $transactionID = $result->getTransactionID(); $invoiceid = get_query_val("mod_myideal", "invoiceid", array("transid" => $transactionID)); $logdata = array("TransactionID" => $transactionID, "InvoiceID" => $invoiceid); if (!$invoiceid) { logTransaction("iDEAL", $logdata, "Invoice ID Not Found"); } logTransaction("iDEAL", $logdata, "Successful"); addInvoicePayment($invoiceid, $transactionID, "", "", "myideal");
function uc_ideal_payment_api_statreq_call($arg1, $arg2) { $transaction_id = $_GET['trxid']; $order_id = $_GET['ec']; //echo $transaction_id; /*START ThinMPI code for TransrReq*/ require_once drupal_get_path('module', 'ideal_payment_api') . "/lib/ThinMPI.php"; require_once drupal_get_path('module', 'ideal_payment_api') . "/lib/AcquirerStatusRequest.php"; //Create StatusRequest $q_data =& new AcquirerStatusRequest(); $transID = str_pad($transaction_id, 16, "0"); $q_data->setTransactionID($transID); //Create ThinMPI instance and process request $rule = new ThinMPI(); $result = $rule->ProcessRequest($q_data); if (!$result->isOK()) { //StatusRequest failed, let the consumer click to try again $Msg = $result->getErrorMessage(); drupal_set_message(t('We could not verify the payment status automaticaly, we will check your payment manualy, pleas contact us regarding this. IDEAL error:')) . '<br>' . $Msg; drupal_goto('ideal'); } else { if (!$result->isAuthenticated()) { //Transaction failed, inform the consumer drupal_set_message(t('Your IDEAL payment has been canceled by you or by the IDEAL process. Please try again or go back to select another payment method.'), 'ERROR'); if ($order_id == $_SESSION['ideal_payment_api_order_id']) { //Check if orer_id is valid // This lets us know it's a legitimate access of the review page. $_SESSION['do_review'] = TRUE; // Ensure the cart we're looking at is the one that payment was attempted for. $_SESSION['cart_order'] = uc_cart_get_id(); drupal_goto('ideal/review'); } else { drupal_goto('cart'); } } else { drupal_set_message(t('Thank you for shopping with us, your payment is processed sucessfuly')); $transactionID = $result->getTransactionID(); //Here you should retrieve the order from the database, mark it as "payed" $order = uc_order_load($order_id); if ($order == FALSE) { //Check if order exist watchdog('ideal_api', t('iDeal payment completion attempted for non-existent order.'), WATCHDOG_ERROR); return; } //uc_order_update_status($order_id, 1); *Uitgezet 281107 KK uc_order_update_status($order->order_id, uc_order_state_default('post_checkout')); //Todo?? //uc_payment_enter($order_id, 'ideal_payment_api', $payment_amount, $order->uid, NULL, $comment); //uc_cart_complete_sale($order); //uc_order_comment_save($order_id, 0, t('iDeal Pro reported a payment of !amount !currency.', array('!amount' => uc_currency_format($payment_amount, FALSE), '!currency' => $payment_currency)), 'admin'); unset($_SESSION['ideal_payment_api_order_id']); // This lets us know it's a legitimate access of the complete page. $_SESSION['do_complete'] = TRUE; drupal_goto('ideal/complete'); exit; } } }
function do_payment($payment_id, $member_id, $product_id, $price, $begin_date, $expire_date, &$vars) { global $config, $db; $products = $product_id; $orig_product_id = $product_id; if (is_array($product_id)) { $product_id = $product_id[0]; } $product =& get_product($product_id); if (count($orig_product_id) > 1) { $product->config['title'] = $config['multi_title']; } $member = $db->get_user($member_id); //Put information from form in variables $amount = $price * 100; //Multiply amount by 100 to remove decimals $issuerID = $_POST['issuerID']; if (!$issuerID) { $issuerID = $_GET['issuerID']; } if (!$issuerID) { $issuerID = $payment['data']['issuerID']; } if ($issuerID == 0) { //print("Kies uw bank uit de lijst om met iDEAL te betalen<br>"); //exit(); $db->log_error('Kies uw bank uit de lijst om met iDEAL te betalen'); return 'iDeal payment error. Please contact site administrator.'; } //Create ThinMPI instance $rule = new ThinMPI(); //Create TransactionRequest $data =& new AcquirerTrxRequest(); //Set parameters for TransactionRequest $data->setIssuerID($issuerID); $data->setMerchantReturnURL($rule->conf['MERCHANTRETURNURL']); $data->setPurchaseID($payment_id); $data->setAmount($amount); $data->setCurrency($rule->conf['CURRENCY']); $data->setExpirationPeriod($rule->conf['EXPIRATIONPERIOD']); $data->setLanguage($rule->conf['LANGUAGE']); //$description = $rule->conf['DESCRIPTION']; //$description = $product->config['description']; $description = substr($product->config['title'], 0, 32); $data->setDescription($description); $data->setEntranceCode($rule->conf['ENTRANCECODE']); //$data->setAcqURL( $rule->conf['ACQUIRERURL'] ); $result = new AcquirerTrxResponse(); //Process Request $result = $rule->ProcessRequest($data); if ($result->isOK()) { $transactionID = $result->getTransactionID(); //Here you should store the transactionID along with the order (in the database //of your webshop system) so you can later retrieve the order with the //transactionID. $payment = $db->get_payment($payment_id); $payment['receipt_id'] = $transactionID; $db->update_payment($payment_id, $payment); //Get IssuerURL en decode it $ISSURL = $result->getIssuerAuthenticationURL(); $ISSURL = html_entity_decode($ISSURL); //Redirect the browser to the issuer URL html_redirect($ISSURL, '', 'Please wait', 'Please wait'); exit; } else { //TransactionRequest failed, inform the consumer //print("Er is helaas iets misgegaan. Foutmelding van iDEAL:<br>"); $Msg = $result->getErrorMessage(); $db->log_error('Er is helaas iets misgegaan. Foutmelding van iDEAL: ' . $Msg); return 'iDeal payment error. Please contact site administrator.'; } }