public function paymentAction()
 {
     $configkey = \CoreShop\Model\Configuration::get('SOFORTUEBERWEISUNG.KEY');
     $sofort = new \Sofort\SofortLib\Sofortueberweisung($configkey);
     $sofort->setAmount(Tool::numberFormat($this->cart->getTotal()));
     $sofort->setVersion('CoreShop ' . \CoreShop\Version::getVersion());
     $sofort->setReason('Buy Order (CoreShop)');
     $sofort->setCurrencyCode(Tool::getCurrency()->getIsoCode());
     $sofort->setSuccessUrl(Pimcore\Tool::getHostUrl() . $this->getModule()->url($this->getModule()->getIdentifier(), 'payment-return'));
     $sofort->setAbortUrl(Pimcore\Tool::getHostUrl() . $this->getModule()->url($this->getModule()->getIdentifier(), 'payment-return-abort'));
     $sofort->sendRequest();
     if ($sofort->isError()) {
         var_dump($sofort);
         die('error');
     } else {
         $transactionId = $sofort->getTransactionId();
         $this->cart->setCustomIdentifier($transactionId);
         $this->cart->save();
         $this->redirect($sofort->getPaymentUrl());
     }
 }
示例#2
0
                echo "Order cancelled";
            } else {
                //In test mode, sofort will do a sandbox call.
                require __DIR__ . '/vendor/autoload.php';
                $configkey = '116339:240443:96a447a8f7781048364620e19fc024d0';
                $Sofortueberweisung = new \Sofort\SofortLib\Sofortueberweisung($configkey);
                $Sofortueberweisung->setAmount($price);
                $Sofortueberweisung->setCurrencyCode('EUR');
                $Sofortueberweisung->setReason('Alma Mater Wear', 'Bestellnr. (tbd)');
                $Sofortueberweisung->setSuccessUrl($success_url, true);
                $Sofortueberweisung->setAbortUrl($error_url);
                $Sofortueberweisung->setNotificationUrl($notification_url, 'pending,received');
                $Sofortueberweisung->sendRequest();
                $paymentID = $Sofortueberweisung->getTransactionId();
                mysqli_query($link, "UPDATE orders SET paymentID = '{$paymentID}' WHERE id = {$orderId}");
                $_SESSION["sofortID"] = $paymentID;
                if ($Sofortueberweisung->isError()) {
                    //SOFORT-API didn't accept the data
                    echo $Sofortueberweisung->getError();
                } else {
                    //buyer must be redirected to $paymentUrl else payment cannot be successfully completed!
                    $paymentUrl = $Sofortueberweisung->getPaymentUrl();
                    //var_dump($Sofortueberweisung);
                    echo $paymentUrl;
                }
            }
        }
    } else {
        echo "Order cancelled";
    }
}