コード例 #1
0
 /**
  * Tests Services_Paymill_Clients->delete()
  * @depends testUpdate
  */
 public function testDelete($clientId)
 {
     $client = $this->_clients->delete($clientId);
     $this->assertInternalType('array', $client);
     $this->assertEquals($clientId, $client["id"]);
     $client = $this->_clients->getOne($clientId);
     $this->assertEquals("Client not found", $client["error"]);
 }
コード例 #2
0
 private function _existingClient($data)
 {
     $client = $this->_clients->getOne($data->clientID);
     if ($client['email'] !== $_SESSION['customer']->customer_info['customers_email_address']) {
         $this->_clients->update(array('id' => $data->clientID, 'email' => $_SESSION['customer']->customer_info['customers_email_address']));
     }
     if (array_key_exists('email', $client)) {
         $this->_paymentProcessor->setClientId($client['id']);
     }
 }
コード例 #3
0
 /**
  * Return paymill client data
  * @return array
  */
 public function getClientData()
 {
     $clients = new Services_Paymill_Clients(Mage::helper('paymill/optionHelper')->getPrivateKey(), Mage::helper('paymill')->getApiUrl());
     $clientId = Mage::helper("paymill/fastCheckoutHelper")->getClientId();
     $client = null;
     if (!empty($clientId)) {
         $client = $clients->getOne($clientId);
         if (!array_key_exists('email', $client)) {
             $client = null;
         }
     }
     return $client;
 }
コード例 #4
0
ファイル: paymill.php プロジェクト: SiWe0401/paymill-opencart
 public function confirm()
 {
     $preauth = (bool) $this->config->get($this->getPaymentName() . '_preauth');
     // read transaction token from session
     if (isset($this->request->post['paymillToken'])) {
         $paymillToken = $this->request->post['paymillToken'];
     }
     if (isset($this->request->post['paymillFastcheckout'])) {
         $fastcheckout = $this->request->post['paymillFastcheckout'];
     }
     $this->_logId = time();
     $this->language->load('payment/' . $this->getPaymentName());
     // check if token present
     if (empty($paymillToken)) {
         $this->log("No paymill token was provided. Redirect to payments page.", '');
         $this->redirect($this->url->link('checkout/checkout'));
     } else {
         $this->log("Start processing payment with token.", $paymillToken);
         $this->load->model('checkout/order');
         $this->order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
         $amountRaw = $this->currency->format($this->order_info['total'], $this->order_info['currency_code'], false, false);
         $amount = number_format($amountRaw, 2, '.', '') * 100;
         $source = $this->getVersion() . "_opencart_" . VERSION;
         $privateKey = trim($this->config->get($this->getPaymentName() . '_privatekey'));
         $paymentProcessor = new Services_Paymill_PaymentProcessor();
         $paymentProcessor->setToken($paymillToken);
         $paymentProcessor->setAmount((int) $amount);
         $paymentProcessor->setPrivateKey($privateKey);
         $paymentProcessor->setApiUrl('https://api.paymill.com/v2/');
         $paymentProcessor->setCurrency($this->order_info['currency_code']);
         $paymentProcessor->setDescription(substr("OrderID:" . $this->session->data['order_id'] . " " . $this->order_info['email'], 0, 128));
         $paymentProcessor->setEmail($this->order_info['email']);
         $paymentProcessor->setLogger($this);
         $paymentProcessor->setName($this->order_info['firstname'] . ' ' . $this->order_info['lastname']);
         $paymentProcessor->setSource($source);
         if ($this->customer->getId() != null) {
             $table = $this->getDatabaseName();
             $row = $this->db->query("SELECT `clientId`, `paymentId` FROM {$table} WHERE `userId`=" . $this->customer->getId());
             if ($row->num_rows === 1) {
                 if ($fastcheckout === "true") {
                     $paymentID = empty($row->row['paymentId']) ? null : $row->row['paymentId'];
                     $paymentProcessor->setPaymentId($paymentID);
                 }
                 $clientObject = new Services_Paymill_Clients($privateKey, 'https://api.paymill.com/v2/');
                 $client = $clientObject->getOne($row->row['clientId']);
                 $paymentProcessor->setClientId($row->row['clientId']);
                 if (array_key_exists('email', $client)) {
                     if ($client['email'] !== $this->order_info['email']) {
                         $clientObject->update(array('id' => $row->row['clientId'], 'email' => $this->order_info['email']));
                         $this->log("Client-mail has been changed. Client updated", $this->order_info['email']);
                     }
                 }
             }
         }
         $captureNow = !$preauth;
         // process the payment
         $result = $paymentProcessor->processPayment($captureNow);
         $this->log("Payment processing resulted in: ", $result ? "Success" : "Fail");
         if (!$captureNow) {
             $preauthId = $paymentProcessor->getPreauthId();
             $transId = '';
         } else {
             $preauthId = '';
             $transId = $paymentProcessor->getTransactionId();
         }
         $comment = '';
         if ($this->getPaymentName() == 'paymilldirectdebit') {
             $daysUntil = (int) $this->config->get($this->getPaymentName() . '_sepa_date');
             $comment = $this->language->get('paymill_infotext_sepa') . ": ";
             $comment .= date("d.m.Y", strtotime("+ {$daysUntil} DAYS"));
         }
         // finish the order if payment was sucessfully processed
         if ($result === true) {
             $this->log("Finish order.", '');
             $this->_saveUserData($this->customer->getId(), $paymentProcessor->getClientId(), $paymentProcessor->getPaymentId());
             $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id'), $comment, true);
             $this->_updateOrderComment($this->session->data['order_id'], $comment);
             $this->_saveOrderDetails($this->session->data['order_id'], $transId, $preauthId);
             $this->redirect($this->url->link('checkout/success'));
         } else {
             $responseCode = array_key_exists($paymentProcessor->getErrorCode(), $this->_response_codes) ? $this->_response_codes[$paymentProcessor->getErrorCode()] : 'unknown error';
             $this->session->data['error_message'] = 'An error occured while processing your payment: ' . $responseCode;
             $this->redirect($this->url->link('payment/' . $this->getPaymentName() . '/error'));
         }
     }
 }
コード例 #5
0
ファイル: payment.php プロジェクト: paymill/pigmbhpaymill
 /**
  * Update paymill client data if necessary
  *
  * @param array $db_data
  */
 private function updatePaymillClient($db_data)
 {
     if ($db_data && $this->validateClient($db_data['clientId'])) {
         $client_object = new Services_Paymill_Clients(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), 'https://api.paymill.com/v2/');
         $old_client = $client_object->getOne($db_data['clientId']);
         if ($this->context->customer->email !== $old_client['email']) {
             $client_object->update(array('id' => $db_data['clientId'], 'email' => $this->context->customer->email));
         }
     }
 }
コード例 #6
0
}
if (Configuration::get('PIGMBH_PAYMILL_FASTCHECKOUT')) {
    if (Tools::getValue('payment') == 'creditcard') {
        $sql = 'SELECT `clientId`,`paymentId` FROM `pigmbh_paymill_creditcard_userdata` WHERE `userId`=' . $cart->id_customer;
    } elseif (Tools::getValue('payment') == 'debit') {
        $sql = 'SELECT `clientId`,`paymentId` FROM `pigmbh_paymill_directdebit_userdata` WHERE `userId`=' . $cart->id_customer;
    }
    try {
        $dbData = $db->getRow($sql);
    } catch (Exception $exception) {
        $dbData = false;
    }
}
if ($dbData && validateClient($dbData['clientId'])) {
    $clientObject = new Services_Paymill_Clients(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), "https://api.paymill.com/v2/");
    $oldClient = $clientObject->getOne($dbData['clientId']);
    if ($customer["email"] !== $oldClient['email']) {
        $clientObject->update(array('id' => $dbData['clientId'], 'email' => $customer["email"]));
    }
}
$payment = false;
if ($dbData && validatePayment($dbData['paymentId'])) {
    $paymentObject = new Services_Paymill_Payments(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), "https://api.paymill.com/v2/");
    $paymentResponse = $paymentObject->getOne($dbData['paymentId']);
    if ($paymentResponse['id'] === $dbData['paymentId']) {
        $payment = $dbData['paymentId'] !== '' ? $paymentResponse : false;
    }
    $payment['expire_date'] = null;
    if (isset($payment['expire_month'])) {
        $payment['expire_month'] = $payment['expire_month'] <= 9 ? '0' . $payment['expire_month'] : $payment['expire_month'];
        $payment['expire_date'] = $payment['expire_month'] . "/" . $payment['expire_year'];
コード例 #7
0
 /**
  * Handle paymill client update if exist
  * 
  * @param string $clientId
  */
 private function _existingClientHandling($clientId)
 {
     if (!empty($clientId)) {
         $clients = new Services_Paymill_Clients(trim(Mage::helper('paymill/optionHelper')->getPrivateKey()), Mage::helper('paymill')->getApiUrl());
         $quote = Mage::getSingleton('checkout/session')->getQuote();
         $client = $clients->getOne($clientId);
         if (Mage::helper("paymill/customerHelper")->getCustomerEmail($quote) !== $client['email']) {
             $clients->update(array('id' => $clientId, 'email' => Mage::helper("paymill/customerHelper")->getCustomerEmail($quote)));
         }
     }
 }
コード例 #8
0
 /**
  * Returns the client id of the chosen user
  *
  * @param string $userId
  *
  * @return String
  */
 public function getPaymillClientId($userId)
 {
     $sql = "SELECT paymill_client_id\n                FROM s_user_attributes a, s_user u\n                WHERE u.id = a.userID\n                AND u.id = ?\n                AND a.paymill_client_id IS NOT NULL";
     try {
         require_once dirname(__FILE__) . '/../lib/Services/Paymill/Clients.php';
         $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
         $clientId = Shopware()->Db()->fetchOne($sql, array($userId));
         $client = new Services_Paymill_Clients(trim($swConfig->get("privateKey")), 'https://api.paymill.com/v2/');
         $clientData = $client->getOne($clientId);
         if (!isset($clientData['id'])) {
             $clientId = "";
             $this->setPaymillClientId($userId, "");
         }
     } catch (Exception $exception) {
         $clientId = "";
     }
     return $clientId ? $clientId : "";
 }