/**
  * Tests Services_Paymill_Payments->getOne()
  */
 public function testGetWithWrongId()
 {
     try {
         $payment = $this->_payments->getOne('card_123456789paymill');
     } catch (Exception $e) {
         $this->assertInstanceOf('Services_Paymill_Exception', $e);
         $this->assertEquals(404, $e->getCode());
     }
 }
 /**
  * Return payment data if available
  * 
  * @param string $code
  * @return array
  */
 public function getPaymentData($code)
 {
     $payment = array();
     if ($this->hasData($code)) {
         $payments = new Services_Paymill_Payments(Mage::helper('paymill/optionHelper')->getPrivateKey(), Mage::helper('paymill')->getApiUrl());
         $payment = $payments->getOne($this->getPaymentId($code));
         if (!array_key_exists('last4', $payment) && !array_key_exists('code', $payment)) {
             $payment = array();
         }
     }
     return $payment;
 }
 /**
  * Returns the prefilldata for directdebit
  *
  * @param integer $userId
  * @return array
  */
 private function prefillDirectdebit($userId, $userFullName)
 {
     $prefillData = array('paymillAccountholder' => $userFullName, 'paymillAccountNumber' => '', 'paymillBankCode' => '');
     $paymentId = $this->modelHelper->getPaymillPaymentId('elv', $userId);
     if ($paymentId != "") {
         $paymentObject = $this->servicePayments->getOne($paymentId);
         $prefillData['paymillAccountHolder'] = $paymentObject['holder'] != null ? $paymentObject['holder'] : $userFullName;
         $prefillData['paymillAccountNumber'] = $paymentObject['iban'] != null ? $paymentObject['iban'] : $paymentObject['account'];
         $prefillData['paymillBankCode'] = $paymentObject['bic'] != null ? $paymentObject['bic'] : $paymentObject['code'];
     }
     return $prefillData;
 }
Beispiel #4
0
 /**
  * Update paymill payment data if necessary
  *
  * @param array $db_data
  * @return boolean|array
  */
 private function updatePaymillPayment($db_data)
 {
     $payment = false;
     if ($db_data && $this->validatePayment($db_data['paymentId'])) {
         $payment_object = new Services_Paymill_Payments(Configuration::get('PIGMBH_PAYMILL_PRIVATEKEY'), 'https://api.paymill.com/v2/');
         $payment_response = $payment_object->getOne($db_data['paymentId']);
         if ($payment_response['id'] === $db_data['paymentId']) {
             $payment = $db_data['paymentId'] !== '' ? $payment_response : 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'];
         }
     }
     return $payment;
 }
Beispiel #5
0
 public function index()
 {
     global $config;
     $this->baseUrl = preg_replace("/\\/index\\.php/", "", $this->request->server['SCRIPT_NAME']);
     $this->load->model('checkout/order');
     $this->order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $amount = $this->currency->format($this->order_info['total'], $this->order_info['currency_code'], false, false);
     $this->data['paymill_amount'] = $amount;
     $this->data['paymill_currency'] = $this->order_info['currency_code'];
     $this->data['paymill_fullname'] = $this->order_info['firstname'] . ' ' . $this->order_info['lastname'];
     $this->data['paymill_css'] = $this->baseUrl . '/catalog/view/theme/default/stylesheet/paymill_styles.css';
     $this->data['paymill_iframe_css'] = $this->baseUrl . '/catalog/view/theme/default/stylesheet/paymill_iframe_styles.css';
     $this->data['paymill_image_folder'] = $this->baseUrl . '/catalog/view/theme/default/image/payment';
     $this->data['paymill_js'] = $this->baseUrl . '/catalog/view/javascript/paymill/';
     $this->data['paymill_publickey'] = trim($this->config->get($this->getPaymentName() . '_publickey'));
     $this->data['paymill_debugging'] = $this->config->get($this->getPaymentName() . '_debugging');
     $this->data['paymill_buttonSolution'] = $this->config->get($this->getPaymentName() . '_buttonSolution');
     $this->data['button_confirm'] = $this->language->get('button_confirm');
     $this->language->load('payment/' . $this->getPaymentName());
     $this->data['paymill_accountholder'] = $this->language->get('paymill_accountholder');
     $this->data['paymill_accountnumber'] = $this->language->get('paymill_accountnumber');
     $this->data['paymill_banknumber'] = $this->language->get('paymill_banknumber');
     $this->data['paymill_iban'] = $this->language->get('paymill_iban');
     $this->data['paymill_bic'] = $this->language->get('paymill_bic');
     $this->data['paymill_cardholder'] = $this->language->get('paymill_cardholder');
     $this->data['paymill_cardnumber'] = $this->language->get('paymill_cardnumber');
     $this->data['paymill_cvc'] = $this->language->get('paymill_cvc');
     $this->data['paymill_expirydate'] = $this->language->get('paymill_expirydate');
     $this->data['paymill_description'] = $this->language->get('paymill_description');
     $this->data['paymill_paymilllabel_cc'] = $this->language->get('paymill_paymilllabel_cc');
     $this->data['paymill_paymilllabel_elv'] = $this->language->get('paymill_paymilllabel_elv');
     $this->data['paymill_icon_text'] = $this->language->get('paymill_icon_text');
     $this->data['paymill_error'] = isset($this->session->data['error_message']) ? $this->session->data['error_message'] : null;
     $this->data['paymill_javascript_error'] = $this->language->get('error_javascript');
     $this->data['paymill_translation_fields'] = array('cardholder' => $this->language->get('paymill_cardholder'), 'cardnumber' => $this->language->get('paymill_cardnumber'), 'expire_date' => $this->language->get('paymill_expirydate'), 'cvc' => $this->language->get('paymill_cvc'), 'changebutton' => $this->language->get('paymill_change_button'), 'lang' => $this->language->get('paymill_lang'));
     $this->data['paymill_icon_visa'] = $this->config->get($this->getPaymentName() . '_icon_visa');
     $this->data['paymill_icon_master'] = $this->config->get($this->getPaymentName() . '_icon_master');
     $this->data['paymill_icon_amex'] = $this->config->get($this->getPaymentName() . '_icon_amex');
     $this->data['paymill_icon_jcb'] = $this->config->get($this->getPaymentName() . '_icon_jcb');
     $this->data['paymill_icon_maestro'] = $this->config->get($this->getPaymentName() . '_icon_maestro');
     $this->data['paymill_icon_diners_club'] = $this->config->get($this->getPaymentName() . '_icon_diners_club');
     $this->data['paymill_icon_discover'] = $this->config->get($this->getPaymentName() . '_icon_discover');
     $this->data['paymill_icon_china_unionpay'] = $this->config->get($this->getPaymentName() . '_icon_china_unionpay');
     $this->data['paymill_icon_dankort'] = $this->config->get($this->getPaymentName() . '_icon_dankort');
     $this->data['paymill_icon_carta_si'] = $this->config->get($this->getPaymentName() . '_icon_carta_si');
     $this->data['paymill_icon_carte_bleue'] = $this->config->get($this->getPaymentName() . '_icon_carte_bleue');
     $this->data['paymill_icon'] = $this->showCreditcardIcons();
     $table = $this->getDatabaseName();
     $payment = null;
     if ($this->customer->getId() != null) {
         $row = $this->db->query("SELECT `paymentID` FROM {$table} WHERE `userId`=" . $this->customer->getId());
         if (!empty($row->row['paymentID'])) {
             $privateKey = trim($this->config->get($this->getPaymentName() . '_privatekey'));
             $paymentObject = new Services_Paymill_Payments($privateKey, 'https://api.paymill.com/v2/');
             $payment = $paymentObject->getOne($row->row['paymentID']);
         }
     }
     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'];
     } else {
         $payment['expire_date'] = null;
     }
     $this->data['paymill_prefilled'] = $payment;
     if ($this->getPaymentName() == 'paymillcreditcard') {
         $this->data['paymill_form_action'] = "index.php?route=payment/paymillcreditcard/confirm";
     } elseif ($this->getPaymentName() == 'paymilldirectdebit') {
         $this->data['paymill_form_action'] = "index.php?route=payment/paymilldirectdebit/confirm";
     }
     $this->data['paymill_activepayment'] = $this->getPaymentName();
     if ($this->getPaymentName() == "paymillcreditcard" && !$this->config->get($this->getPaymentName() . '_pci')) {
         $this->data['paymill_load_frame_fastcheckout'] = false;
         if (isset($payment['last4']) && isset($payment['expire_date'])) {
             $this->data['paymill_load_frame_fastcheckout'] = true;
         }
         $this->template = 'default/template/payment/paymill_pci_frame.tpl';
         if (file_exists($this->config->get('config_template') . '/template/payment/paymill_frame.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/payment/paymill_frame.tpl';
         }
     } else {
         $this->template = 'default/template/payment/paymill.tpl';
         if (file_exists($this->config->get('config_template') . '/template/payment/paymill.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/payment/paymill.tpl';
         }
     }
     $this->render();
 }
        $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'];
    }
}
$currency = Currency::getCurrency((int) $cart->id_currency);
$_SESSION['pigmbhPaymill']['authorizedAmount'] = (int) round($cart->getOrderTotal(true, Cart::BOTH) * 100);
$brands = array();
foreach (json_decode(Configuration::get('PIGMBH_PAYMILL_ACCEPTED_BRANDS'), true) as $brandKey => $brandValue) {
    $brands[str_replace('-', '', $brandKey)] = $brandValue;
}
 /**
  * Returns the payment id of the chosen payment for the given user
  *
  * @param string $paymentShortTag Either "cc" or "elv" depending of the desired payment method
  * @param string $userId
  *
  * @return mixed
  */
 public function getPaymillPaymentId($paymentShortTag, $userId)
 {
     $sql = null;
     switch ($paymentShortTag) {
         case "cc":
         case "paymillcc":
             $sql = "SELECT paymill_payment_id_cc\n                    FROM s_user_attributes a, s_user u\n                    WHERE u.id = a.userID\n                    AND u.id = ?\n                    AND a.paymill_payment_id_cc IS NOT NULL";
             break;
         case "elv":
         case "paymilldebit":
             $sql = "SELECT paymill_payment_id_elv\n                    FROM s_user_attributes a, s_user u\n                    WHERE u.id = a.userID\n                    AND u.id = ?\n                    AND a.paymill_payment_id_elv IS NOT NULL";
             break;
     }
     try {
         require_once dirname(__FILE__) . '/../lib/Services/Paymill/Payments.php';
         $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
         $paymentId = Shopware()->Db()->fetchOne($sql, array($userId));
         $payment = new Services_Paymill_Payments(trim($swConfig->get("privateKey")), 'https://api.paymill.com/v2/');
         $paymentData = $payment->getOne($paymentId);
         if (!isset($paymentData['id'])) {
             $paymentId = "";
         }
         if (isset($paymentData['client'])) {
             if ($paymentData['client'] !== $this->getPaymillClientId($userId)) {
                 $paymentId = "";
             }
         }
     } catch (Exception $exception) {
         $paymentId = "";
     }
     return $paymentId ? $paymentId : "";
 }