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()); } }
$payment->setTransactions(array($transaction)); $payment->create($apiContext); //Nach erfolgreicher Bezahlung wird der Bezahlstatus auf 1 gesetzt. Dafür wird die Payment ID in der Datenbank gespeichert mysqli_query($link, "UPDATE orders SET paymentID = '{$payment->id}' WHERE id = {$orderId}"); //Der Ziellink wird ausgegeben und per JavaScript geöffnet $referer = $payment->links[1]->href; echo $referer; } else { if (USE_LIVE_PAYMENT) { //in live mode, Sofort is currently locked. 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!