/** * RatePAY action method handles payment request */ public function RatepayRequestAction() { include_once dirname(__FILE__) . '/../../Views/Frontend/Ratenrechner/php/pi_ratepay_xml_service.php'; Shopware()->Session()->pi_ratepay_Confirm = false; $user = $this->getUser(); $payName = $this->getPaymentShortName(); $ratepay = new pi_ratepay_xml_service(); $ratepay->live = checkSandboxMode($payName); $request = $ratepay->getXMLObject(); setRatepayHead($request, 'PAYMENT_REQUEST', $user); if ($payName == 'RatePAYInvoice') $content = setRatepayContent($request, 'rechnung'); elseif ($payName == 'RatePAYDebit') $content = setRatepayContent($request, 'directDebit'); else $content = setRatepayContent($request, 'ratenzahlung'); $customer = $user['billingaddress']['firstname'] . ' ' . $user['billingaddress']['lastname']; $response = $ratepay->paymentOperation($request); if($payName == 'RatePAYDebit' ||($payName == 'RatePAYRate' && Shopware()->Session()->RatepayDirectDebit)) $request = checkBankDataSave($request, $user); writeLog("", Shopware()->Session()->pi_ratepay_transactionID, "PAYMENT_REQUEST", "", $request, $response, $customer, $payName); if ($response && (string) $response->head->processing->status->attributes()->code == "OK" && (string) $response->head->processing->result->attributes()->code == "402" ) { Shopware()->Session()->pi_ratepay_rechnung_descriptor = (string) $response->content->payment->descriptor; return $this->forward('end'); } else { Shopware()->Session()->pi_ratepay_no_ratepay = true; $sql = "SELECT `userID` FROM `s_user_billingaddress` WHERE `id` = ?"; $userID = Shopware()->Db()->fetchOne($sql, array((int)$user['billingaddress']['userID'])); $sql = "UPDATE `s_user` SET `paymentID` = ? WHERE `id` = ?"; Shopware()->Db()->query($sql, array((int)Shopware()->Config()->Defaultpayment, (int)$userID)); $this->saveStats(false); return $this->redirect(array('controller' => 'account', 'action' => 'payment', 'sTarget' => 'checkout', 'forceSecure' => true)); } }
/** * Payment change request * * @param String $ordernumber Current ordernumber * @param Array $articles Current articles * @param String $subtype Request subtype * @return boolean */ function paymentChange($ordernumber, $articles, $subtype) { $method = checkPaymentMethod($ordernumber); $liveMode = checkSandboxMode($method); $userData = getRatepayUserdata($ordernumber); $customer = $userData['firstname'] . ' ' . $userData['lastname']; include_once dirname(__FILE__) . '/../Views/Frontend/Ratenrechner/php/pi_ratepay_xml_service.php'; $operation = 'PAYMENT_CHANGE'; $ratepay = new pi_ratepay_xml_service(); $ratepay->live = $liveMode; $request = $ratepay->getXMLObject(); setRatepayHead($request, $operation, $subtype, $ordernumber); setRatepayContent($request, $operation, $subtype, $ordernumber, $articles); $response = $ratepay->paymentOperation($request); if ($response) { $sql = "SELECT `transactionID` FROM `s_order` WHERE `ordernumber` = ?"; $transactionID = Shopware()->Db()->fetchOne($sql, array($ordernumber)); writeLog($ordernumber, $transactionID, "PAYMENT_CHANGE", $subtype, $request, $response, $customer,$method); if ((string) $response->head->processing->status->attributes()->code == "OK" && (string) $response->head->processing->result->attributes()->code == "403") return true; else throw new Exception((string) $response->head->processing->status->attributes()->code); } else throw new Exception('Fehler bei der Bearbeitung: Keine Response'); }