function sofort_process_payment($purchase_data) { global $edd_options; // check there is a gateway name if (!isset($purchase_data['post_data']['edd-gateway'])) { return; } // collect payment data $payment_data = array('price' => $purchase_data['price'], 'date' => $purchase_data['date'], 'user_email' => $purchase_data['user_email'], 'purchase_key' => $purchase_data['purchase_key'], 'currency' => $edd_options['currency'], 'downloads' => $purchase_data['downloads'], 'user_info' => $purchase_data['user_info'], 'cart_details' => $purchase_data['cart_details'], 'status' => 'pending'); $errors = edd_get_errors(); if ($errors) { // problems? send back edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']); } else { $payment = edd_insert_payment($payment_data); // check payment if (!$payment) { edd_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['edd-gateway']); } else { if (!class_exists('SofortLib')) { require_once 'library/sofortLib.php'; } $return_url = add_query_arg('payment-confirmation', 'paypal', get_permalink($edd_options['success_page'])); $Sofort = new SofortLib_Multipay(trim($edd_options['sofort_config_id'])); $Sofort->setSofortueberweisung(); $Sofort->setAmount($purchase_data['price']); $Sofort->setReason('CartId ' . $payment, $purchase_data['post_data']['edd_first'] . ' ' . $purchase_data['post_data']['edd_last']); $Sofort->addUserVariable($payment); $Sofort->setSuccessUrl($return_url); $Sofort->setAbortUrl(edd_get_failed_transaction_uri()); $Sofort->setTimeoutUrl(edd_get_failed_transaction_uri()); $Sofort->setNotificationUrl(home_url('/?sofort=ipn')); $Sofort->sendRequest(); if ($Sofort->isError()) { //PNAG-API didn't accept the data wp_die($Sofort->getError(), 'Error'); } else { //buyer must be redirected to $paymentUrl else payment cannot be successfully completed! $paymentUrl = $Sofort->getPaymentUrl(); edd_empty_cart(); wp_redirect($paymentUrl); exit; } } } }
function onAfterOrderConfirm(&$order, &$methods, $method_id) { parent::onAfterOrderConfirm($order, $methods, $method_id); require_once dirname(__FILE__) . '/library/sofortLib.php'; $viewType = 'end'; if (empty($this->payment_params->return_url)) { $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=' . $order->order_id . $this->url_itemid; } else { $return_url = $this->payment_params->return_url; } $notify_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=' . $this->name . '&tmpl=component&lang=nl'; if (empty($this->payment_params->cancel_url)) { $cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order'; } else { $cancel_url = $this->payment_params->cancel_url; } $configkey = $this->payment_params->user_id . ':' . $this->payment_params->project_id . ':' . $this->payment_params->token; $amount = round($order->cart->full_total->prices[0]->price_value_with_tax, (int) $this->currency->currency_locale['int_frac_digits']); $order_text = "\r\n" . JText::sprintf('betaling Feeen en ridders: order ', $order->order_id); $transactionId = 0; $Sofort = new SofortLib_Multipay($configkey); $Sofort->setSofortueberweisung(); $Sofort->setAmount($amount, $this->currency->currency_code); $Sofort->setReason($order_text); $Sofort->addUserVariable($order->order_id); //$Sofort->setSofortrechnungOrderId($order->order_id); $Sofort->addUserVariable($method_id); $Sofort->setSuccessUrl($return_url); $Sofort->setAbortUrl($cancel_url); $Sofort->setTimeoutUrl($cancel_url); $Sofort->setNotificationUrl($notify_url); $Sofort->sendRequest(); if ($Sofort->isError()) { //PNAG-API didn't accept the data echo $Sofort->getError(); return false; } else { //buyer must be redirected to $paymentUrl else payment cannot be successfully completed! $this->redirect_url = $Sofort->getPaymentUrl(); //header('Location: '.$this->redirect_url); } return $this->showPage('end'); }
* Copyright (c) 2012 SOFORT AG * * Released under the GNU General Public License (Version 2) * [http://www.gnu.org/licenses/gpl-2.0.html] * * $Date: 2012-11-21 12:02:12 +0100 (Wed, 21 Nov 2012) $ * @version SofortLib 1.5.0rc $Id: example_sofortvorkasse.php 5724 2012-11-21 11:02:12Z rotsch $ * @author SOFORT AG http://www.sofort.com (integration@sofort.com) * */ require_once '../../library/sofortLib.php'; define('CONFIGKEY', '1111:2222:1f7d368b64eb8d3e69500885f1c13e7c'); //your configkey or userid:projektid:apikey $Sofort = new SofortLib_Multipay(CONFIGKEY); $Sofort->setSofortvorkasse(); $Sofort->setAmount(10); $Sofort->setReason('testueberweisung', 'verwendungszweck 2'); $Sofort->setSenderAccount('88888888', '12345678', 'Max Mustermann'); $Sofort->setSuccessUrl('https://{website}/'); $Sofort->setAbortUrl('https://{website}/'); $Sofort->setTimeoutUrl('https://{website}/'); $Sofort->setNotificationUrl('https://{website}/'); $Sofort->sendRequest(); if ($Sofort->isError()) { //PNAG-API didn't accept the data echo $Sofort->getError(); } else { //buyer must be redirected to $paymentUrl else payment cannot be successfully completed! $paymentUrl = $Sofort->getPaymentUrl(); header('Location: ' . $paymentUrl); }