Пример #1
0
 public function getUrl()
 {
     $order = $this->getOrder();
     $amount = number_format($order->getGrandTotal(), 2, '.', '');
     $billing = $order->getBillingAddress();
     $security = $this->getSecurityKey();
     $reason1_template = Mage::getStoreConfig('payment/sofort/pnsofort_reason_1', $this->getStore());
     $reason2_template = Mage::getStoreConfig('payment/sofort/pnsofort_reason_2', $this->getStore());
     $tmp_orderid = $order->getRealOrderId();
     $address = $order->getBillingAddress();
     $tmp_name = $this->_getFirstname($address) . " " . $this->_getLastname($address);
     $tmp_date = Mage::getModel('core/date')->date('d.m.Y');
     $tmp_storename = Mage::getStoreConfig('general/store_information/name', $this->getStore());
     $reason1 = preg_replace('#\\{\\{ordernr\\}\\}#', $tmp_orderid, $reason1_template);
     $reason2 = preg_replace('#\\{\\{ordernr\\}\\}#', $tmp_orderid, $reason2_template);
     $reason1 = preg_replace('#Order No.:#', Mage::helper('pnsofortueberweisung')->__('Order No.: '), $reason1);
     $reason2 = preg_replace('#Order No.:#', Mage::helper('pnsofortueberweisung')->__('Order No.: '), $reason2);
     $reason1 = preg_replace('#\\{\\{name\\}\\}#', $tmp_name, $reason1);
     $reason2 = preg_replace('#\\{\\{name\\}\\}#', $tmp_name, $reason2);
     $reason1 = preg_replace('#\\{\\{date\\}\\}#', $tmp_date, $reason1);
     $reason2 = preg_replace('#\\{\\{date\\}\\}#', $tmp_date, $reason2);
     $reason1 = preg_replace('#\\{\\{shopname\\}\\}#', $tmp_storename, $reason1);
     $reason2 = preg_replace('#\\{\\{shopname\\}\\}#', $tmp_storename, $reason2);
     $reason1 = preg_replace('#\\{\\{transaction\\}\\}#', '-TRANSACTION-', $reason1);
     $reason2 = preg_replace('#\\{\\{transaction\\}\\}#', '-TRANSACTION-', $reason2);
     $reason1 = preg_replace('#[^a-zA-Z0-9+-\\.,\\s]#', '', $reason1);
     $reason2 = preg_replace('#[^a-zA-Z0-9+-\\.,\\s]#', '', $reason2);
     $success_url = Mage::getUrl('pnsofortueberweisung/sofort/return', array('orderId' => $order->getRealOrderId(), '_secure' => true));
     $cancel_url = Mage::getUrl('pnsofortueberweisung/sofort/error', array('orderId' => $order->getRealOrderId()));
     $notification_url = Mage::getUrl('pnsofortueberweisung/sofort/notification', array('orderId' => $order->getRealOrderId(), 'secret' => $security));
     $sObj = new SofortLib_Multipay(Mage::getStoreConfig('payment/sofort/configkey', $this->getStore()));
     $sObj->setVersion(self::MODULE_VERSION);
     $sObj->setAmount($amount, $order->getOrderCurrencyCode());
     $sObj->setReason($reason1, $reason2);
     $sObj->setSuccessUrl($success_url);
     $sObj->setAbortUrl($cancel_url);
     $sObj->setNotificationUrl($notification_url);
     $sObj->addUserVariable($order->getRealOrderId());
     //$sObj->setEmailCustomer($order->customer['email_address']);
     //$sObj->setPhoneNumberCustomer($order->customer['telephone']);
     $sObj->setSofortueberweisung();
     $sObj->setSofortueberweisungCustomerprotection($this->getConfigData("pnsofort_customerprotection") == 1);
     $sObj->sendRequest();
     if (!$sObj->isError()) {
         $url = $sObj->getPaymentUrl();
         $tid = $sObj->getTransactionId();
         $order->getPayment()->setTransactionId($tid)->setIsTransactionClosed(0);
         $order->getPayment()->setAdditionalInformation('sofort_transaction', $tid);
         $order->getPayment()->setAdditionalInformation('sofort_lastchanged', 0);
         $order->getPayment()->setAdditionalInformation('sofort_secret', $security)->save();
         return $url;
     } else {
         $errors = $sObj->getErrors();
         foreach ($errors as $error) {
             Mage::getSingleton('checkout/session')->addError(Mage::helper('pnsofortueberweisung')->localizeXmlError($error));
         }
         return $cancel_url;
     }
 }
 /**
  * @param array   $dataArray
  * - amount (required)
  * - ...
  * @return array res
  */
 public function setExpressCheckout($data)
 {
     $defaults = array('reason' => __('Sale'), 'description' => '');
     $data = array_merge($defaults, $data);
     //Router::url($dataArray['returnurl'], true);
     $Sofort = new SofortLib_Multipay($this->_configKey());
     $Sofort->new($data['amount'], $this->settings['currency_code']);
     App::uses('Inflector', 'Utility');
     $Sofort->setAmount($data['amount'], $this->settings['currency_code']);
     $Sofort->setReason(Inflector::slug($data['reason']), Inflector::slug($data['description']));
     $Sofort->setSofortueberweisung();
     $Sofort->setLanguageCode(strtolower($this->settings['locale']));
     if (false) {
         $Sofort->setSofortueberweisungCustomerprotection(true);
     }
     //die(returns($Sofort->parameters));
     //die(returns($Sofort->parameters));
     $res = $Sofort->validateRequest();
     die(returns($res));
     $res = $Sofort->sendRequest();
     die(returns($res));
     return;
 }
Пример #3
0
 function sendTransactionRequest($cart, $order, $doRedirect = true)
 {
     $session = JFactory::getSession();
     $return_context = $session->getId();
     //$this->_debug = $method->debug;
     //$this->debugLog('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     vmdebug('SOFORT sendTransactionRequest');
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('TableVendors')) {
         require VMPATH_ADMIN . DS . 'tables' . DS . 'vendors.php';
     }
     $this->getPaymentCurrency($this->_currentMethod);
     $email_currency = $this->getEmailCurrency($this->_currentMethod);
     $currency_code_3 = shopFunctions::getCurrencyByID($this->_currentMethod->payment_currency, 'currency_code_3');
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $this->_currentMethod->payment_currency);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($this->_currentMethod, 'create_order');
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_currency'] = $this->_currentMethod->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $this->_currentMethod->tax_id;
     $dbValues['sofort_custom'] = $return_context;
     $security = self::getSecurityKey();
     $dbValues['security'] = $security;
     $this->debugLog('comes from' . (int) $doRedirect . ' order number' . $order['details']['BT']->order_number, "sendTransactionRequest ", 'debug');
     if (!class_exists('SofortLib')) {
         require VMPATH_ROOT . DS . 'plugins' . DS . 'vmpayment' . DS . 'sofort' . DS . 'sofort' . DS . 'library' . DS . 'sofortLib.php';
     }
     $sofort = new SofortLib_Multipay(trim($this->_currentMethod->configuration_key));
     $sofort->setVersion(self::RELEASE);
     $sofort->setAmount($totalInPaymentCurrency['value'], $currency_code_3);
     $sofort->setReason($order['details']['BT']->order_number);
     $sofort->setSuccessUrl(self::getSuccessUrl($order));
     $sofort->setAbortUrl(self::getCancelUrl($order));
     $sofort->setNotificationUrl(self::getNotificationUrl($security, $order['details']['BT']->order_number));
     $sofort->setSofortueberweisung();
     $sofort->setSofortueberweisungCustomerprotection($this->_currentMethod->buyer_protection);
     $jlang = JFactory::getLanguage();
     $lang = $jlang->getTag();
     $langArray = explode("-", $lang);
     $lang = strtolower($langArray[1]);
     $sofort->setLanguageCode($lang);
     $sofort->sendRequest();
     vmdebug('SOFORT sendTransactionRequest ... SofortLib_Multipay ... sendRequest()');
     if ($sofort->isError()) {
         $errors = $sofort->getErrors();
         vmdebug('SOFORT sendTransactionRequest ... SofortLib_Multipay ... getErrors()', $errors);
         $this->displayErrors($errors);
         $this->redirectToCart();
         return;
     }
     $url = $sofort->getPaymentUrl();
     $dbValues['sofort_response_transaction'] = $sofort->getTransactionId();
     $this->storePSPluginInternalData($dbValues);
     if ($doRedirect) {
         $mainframe = JFactory::getApplication();
         $mainframe->redirect($url);
     }
 }
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;
            }
        }
    }
}
Пример #5
0
 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&notif_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()) {
         echo $Sofort->getError();
         return false;
     } else {
         $this->redirect_url = $Sofort->getPaymentUrl();
     }
     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();
 /**
  * append items, shipping and discount to the payment object
  * 
  * @param Mage_Sales_Model_Order_Item $order
  * @param SofortLib_Multipay $sofortPayment
  */
 private function _appendItems($order, $sofortPayment)
 {
     //items
     $discountTax = 19;
     foreach ($order->getAllVisibleItems() as $item) {
         if (($item->product_type == 'downloadable' || $item->product_type == 'virtual') && $item->getRowTotal() > 0) {
             throw new Exception(Mage::helper('pnsofortueberweisung')->__('Kauf auf Rechnung not allowed for downloadable or virtual products'));
         }
         $name = $item->getName();
         $uid = $item->getSku() . "-" . $item->getItemId();
         // FIXME getDescription is not default method for Mage_Sales_Model_Order_Item ?
         $desc = $item->getDescription();
         // configurable product
         if ($item->product_type == 'configurable') {
             $productOptions = unserialize($item->product_options);
             // check attributes
             if (!empty($productOptions['attributes_info'])) {
                 $configAttr = array();
                 foreach ($productOptions['attributes_info'] as $pOp) {
                     $configAttr[] = $pOp['value'];
                 }
                 if (!empty($configAttr)) {
                     $desc = implode(", ", $configAttr) . "\n" . $desc;
                 }
             }
         } else {
             if ($item->product_type == 'bundle') {
                 $productOptions = unserialize($item->product_options);
                 // check bundle options
                 if (!empty($productOptions['bundle_options'])) {
                     $bundleTitle = array();
                     foreach ($productOptions['bundle_options'] as $pOp) {
                         if (!empty($pOp['value'])) {
                             foreach ($pOp['value'] as $bValue) {
                                 $bundleTitle[] = $bValue['title'];
                             }
                         }
                     }
                     if (!empty($bundleTitle)) {
                         $desc = implode(", ", $bundleTitle) . "\n" . $desc;
                     }
                 }
             }
         }
         // add item
         $sofortPayment->addSofortrechnungItem(md5($uid), $item->getSku(), $name, $this->_getPriceInclTax($item), 0, $desc, $item->getQtyOrdered() - $item->getQtyCanceled() - $item->getQtyRefunded(), $item->getTaxPercent());
         if ($item->getTaxPercent() > 0) {
             // tax of discount is min of cart-items
             $discountTax = min($item->getTaxPercent(), $discountTax);
         }
     }
     //shipping
     if ($order->getShippingAmount() != 0) {
         $shippingTax = round($order->getShippingTaxAmount() / $order->getShippingAmount() * 100);
     } else {
         $shippingTax = 0;
     }
     // check if amount is removed
     if ($order->getShippingAmount() - $order->getShippingRefunded() > 0) {
         $sofortPayment->addSofortrechnungItem(1, 1, $order->getShippingDescription(), $this->_getShippingInclTax($order), 1, '', 1, $shippingTax);
     }
     //discount
     if ($order->getDiscountAmount() != 0) {
         $sofortPayment->addSofortrechnungItem(2, 2, Mage::helper('sales')->__('Discount'), $order->getDiscountAmount(), 2, '', 1, $discountTax);
     }
 }
 public function getUrl()
 {
     $order = $this->getOrder();
     $session = Mage::getSingleton('core/session');
     $amount = number_format($order->getGrandTotal(), 2, '.', '');
     $security = $this->getSecurityKey();
     $reason1 = Mage::helper('pnsofortueberweisung')->__('Order No.: ') . $order->getRealOrderId();
     $reason1 = preg_replace('#[^a-zA-Z0-9+-\\.,]#', ' ', $reason1);
     $reason2 = Mage::getStoreConfig('general/store_information/name');
     $reason2 = preg_replace('#[^a-zA-Z0-9+-\\.,]#', ' ', $reason2);
     $success_url = Mage::getUrl('pnsofortueberweisung/sofort/return', array('orderId' => $order->getRealOrderId(), '_secure' => true));
     $cancel_url = Mage::getUrl('pnsofortueberweisung/sofort/error', array('orderId' => $order->getRealOrderId()));
     $notification_url = Mage::getUrl('pnsofortueberweisung/sofort/notification', array('orderId' => $order->getRealOrderId(), 'secret' => $security));
     $sObj = new SofortLib_Multipay(Mage::getStoreConfig('payment/sofort/configkey'));
     $sObj->setVersion(self::MODULE_VERSION);
     $sObj->setAmount($amount, $order->getOrderCurrencyCode());
     $sObj->setReason($reason1, $reason2);
     $sObj->setSuccessUrl($success_url);
     $sObj->setAbortUrl($cancel_url);
     $sObj->setNotificationUrl($notification_url);
     $sObj->addUserVariable($order->getRealOrderId());
     $sObj->setEmailCustomer($order->getCustomerEmail());
     $sObj->setSenderAccount($session->getLsBankCode(), $session->getLsAccountNumber(), $session->getLsHolder());
     // set address
     $sObj->setLastschriftAddress($this->_getFirstname($order->getBillingAddress()), $this->_getLastname($order->getBillingAddress()), $this->_getStreet($order->getBillingAddress()), $this->_getNumber($order->getBillingAddress()), $this->_getPostcode($order->getBillingAddress()), $this->_getCity($order->getBillingAddress()), '');
     //$sObj->setPhoneNumberCustomer($order->getCustomerTelephone());
     $sObj->setLastschrift();
     $sObj->sendRequest();
     if (!$sObj->isError()) {
         $url = $sObj->getPaymentUrl();
         $tid = $sObj->getTransactionId();
         $order->getPayment()->setTransactionId($tid)->setIsTransactionClosed(0);
         $order->getPayment()->setAdditionalInformation('sofort_transaction', $tid);
         $order->getPayment()->setAdditionalInformation('sofort_lastchanged', 0);
         $order->getPayment()->setAdditionalInformation('sofort_secret', $security)->save();
         return $url;
     } else {
         $errors = $sObj->getErrors();
         foreach ($errors as $error) {
             Mage::getSingleton('checkout/session')->addError(Mage::helper('pnsofortueberweisung')->localizeXmlError($error));
         }
         return $cancel_url;
     }
 }
/**
 * 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_lastschrift_by_sofort.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:9f5d237b65eb833e69520985f1c14e7c');
//your configkey or userid:projektid:apikey
$Sofort = new SofortLib_Multipay(CONFIGKEY);
$Sofort->setLastschrift();
$Sofort->setReason('Testzweck', 'Testzweck2');
$Sofort->setLastschriftAddress('Vorname', 'Nachname', 'Strasse', '12', '35578', 'Wetzlar', 2);
$Sofort->setSenderAccount('88888888', '12345678', 'Max Mustermann');
$Sofort->setAmount(10);
$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!