Example #1
0
 /**
  * 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));
     }
 }
Example #2
0
 /**
  * Gets installment details. Delivers a JSON String with history details
  *
  * @see templates/backend/plugins/PigmbhRatePAYPayment/index.php
  */
 public function getRateConfigRequestAction()
 {
     $this->View()->setTemplate();
     include_once dirname(__FILE__) . '/../../Views/Frontend/Ratenrechner/php/pi_ratepay_xml_service.php';
     $ratepay = new pi_ratepay_xml_service;
     $ratepay->live = checkSandboxMode('RatePAYRate');
     $request = $ratepay->getXMLObject();
     $returnItems = array();
     $head = $request->addChild('head');
     $head->addChild('system-id', $_SERVER['REMOTE_ADDR']);
     $head->addChild('operation', 'CONFIGURATION_REQUEST');
     setRatepayHeadCredentials($head, 'CONFIGURATION_REQUEST', false, false);
     $response = $ratepay->paymentOperation($request);
     $response? $responseVar = $response: $responseVar=false;
     writeLog("", "", "CONFIGURATION_REQUEST", "", $request, $responseVar, Shopware()->Config()->Shopname, 'RatePAYRate' );
     $returnItems[0]['text'] = 'interestrate-min';
     $returnItems[0]['value'] = (string) $response->content->{'installment-configuration-result'}->{'interestrate-min'};
     $returnItems[1]['text'] = 'interestrate-default';
     $returnItems[1]['value'] = (string) $response->content->{'installment-configuration-result'}->{'interestrate-default'};
     $returnItems[2]['text'] = 'interestrate-max';
     $returnItems[2]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'interestrate-max'};
     $returnItems[3]['text'] = 'month-number-min';
     $returnItems[3]['value'] = (string) $response->content->{'installment-configuration-result'}->{'month-number-min'};
     $returnItems[4]['text'] = 'month-number-max';
     $returnItems[4]['value'] = (string) $response->content->{'installment-configuration-result'}->{'month-number-max'};
     $returnItems[5]['text'] = 'month-longrun';
     $returnItems[5]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'month-longrun'};
     $returnItems[6]['text'] = 'month-allowed';
     $returnItems[6]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'month-allowed'};
     $returnItems[7]['text'] = 'payment-firstday';
     $returnItems[7]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'payment-firstday'};
     $returnItems[8]['text'] = 'payment-amount';
     $returnItems[8]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'payment-amount'};
     $returnItems[9]['text'] = 'payment-lastrate';
     $returnItems[9]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'payment-lastrate'};
     $returnItems[10]['text'] = 'rate-min-normal';
     $returnItems[10]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'rate-min-normal'};
     $returnItems[11]['text'] = 'rate-min-longrun';
     $returnItems[11]['value'] =  (string) $response->content->{'installment-configuration-result'}->{'rate-min-longrun'};
     $returnItems[12]['text'] = 'service-charge';
     $returnItems[12]['value'] = (string) $response->content->{'installment-configuration-result'}->{'service-charge'};
     echo json_encode(array("total" => count($returnItems), "items" => $returnItems));
 }
Example #3
0
/**
 * 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');
}