Exemplo n.º 1
0
     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!
             $paymentUrl = $Sofortueberweisung->getPaymentUrl();
             //var_dump($Sofortueberweisung);
             echo $paymentUrl;
         }
     }
 }