Skip to content

Commit

Permalink
Merge pull request #3 from paymill/shopware_five
Browse files Browse the repository at this point in the history
Shopware five port
  • Loading branch information
Stefan Harenkamp committed Sep 21, 2015
2 parents c626aa3 + 9dea676 commit 3f35d02
Show file tree
Hide file tree
Showing 75 changed files with 1,950 additions and 1,845 deletions.
315 changes: 111 additions & 204 deletions Frontend/PaymPaymentCreditcard/Bootstrap.php

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions Frontend/PaymPaymentCreditcard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#Release Notes

##1.5.2
- added controller and action check to onCheckoutConfirm event handler #2

##1.5.1
- removed transactionId in checkout

##1.5.0
- added webhooks for refunds

##1.4.7
- fixed refund

##1.4.6
- fixed sepa/elv for shopware 4.1.4

##1.4.5
- improved SQL Statements for CSV-Reader

##1.4.4
- Blocked multiple clicks on the "Pay" Button.
- Set Customer/Preauthorization/Transaction max. Description length to 128 chars
- Fixed a Bug with wrong Prenotification Date, when "Days to Debit" is set to 0
- improved SQL Statements

##1.4.3
- Hotfix: fixed overwriting of email templates

##1.4.2
- fixed Update bug from version 1.3.0 or higher to 1.4.1

##1.4.1
- added improved update-method

##1.4.0
- united SEPA and regular ELV forms
- added backend option to show credit card logos in frontend
- added prenotification in order mail for direct debit

##1.3.1
- Fixed Translation Bug for mainshop

##1.3.0
- Added Support for Conexco Responsive Template
- Added improved iban validation
- Added support for various languages
- Added improved early pan detection

##1.2.0
- Added additional validation to the fast checkout process
- Implemented optional SEPA direct debit form. Only payments from germany are supported

##1.1.4
- Fixed a bug keeping unregistered users from changing the Supplier country in the shopping cart
- Fixed a bug causing crashes on language changes in the shopping cart

##1.1.3
- Fixed a bug causing the first Payment attempt for new customers to crash under some circumstances

##1.1.2
- Fixed a bug causing crashes during checkout

##1.1.1
- Updated Lib
- Updated README.md files
- Added CHANGELOG.md
- Implemented improved error feedback
- Added Snippets to support the improved feedback
- Fixed a bug causing the cvc tooltip to be english in all languages
- Removed logging for successful installations and updates

##1.1.0
- Lib has been updated
- Checkout Form is now always being displayed, showing masked customer information if there is fast checkout data. This allows customers to change their credit card or bank details after the data has been saved.
- Improved the CVC tool-tip in the checkout form
- Customers will now get identified on their first usage of a PAYMILL payment mean and will now always use the same id, even if fast checkout is not enabled.
- Added pre authorization as a plug-in option: If active, credit card transactions will be authorized during checkout and can be captured from a new tab in the order detail view
- Added refund option from the detail tab. Any transaction booked after the update can be completely refunded at will
- Implemented special handling for Maestro cards during the checkout: cards without CVC are now supported
- Improved the translation routine to prepare the support for different languages in the frontend.
- Added status updates for PAYMILL transactions.
- Improved the log to allow search
- Fixed a bug causing the debug option not to work
- Added translations for the payment names.
- Improved update routine: from this version onwards the Shopware update function will be completely functional with this module
- Improved code readability

##1.0.6
- Added dynamic cc-brands
- Added supplier, updated link and support in the plugin description

##1.0.5
- Added translation of payment names as a paragraph to the readme file
- Added Translation of payment method displaynames section to the readme file

##1.0.4
- Fixed a bug causing crashes if no shop with english language is available
- Adjusted description for shopware community store
- Added trim for used keys
- Checking GTC before creating a token.
- Update readme file with supported versions
- Added source parameter
- Improved translation handling

##1.0.3
- Added snippets and translations

##1.0.2
- Rewrote Plugin from scratch

##1.0.1
- Updated Lib to v2
- Added ELV as a payment mean

##1.0.0
- Initial release
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?php
require_once dirname(__FILE__) . '/../../../lib/Services/Paymill/Payments.php';

class Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_Checkout_Form_PrefillData
{
/**
* @var Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper
*/
private $modelHelper;

/**
* @var Services_Paymill_Payments
*/
private $servicePayments;

/**
* @var string
*/
private $apiUrl = "https://api.paymill.com/v2/";

/**
* Creates an instance for this class
*/
public function __construct()
{
$swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
$this->modelHelper = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper();
$this->privateKey = trim($swConfig->get("privateKey"));
$this->servicePayments = new Services_Paymill_Payments(trim($swConfig->get("privateKey")), $this->apiUrl);
}

public function isDataAvailable($paymentName, $userId){
return $this->modelHelper->getPaymillPaymentId($paymentName, $userId);
}

/**
* Returns the prefill data for creditcard and directdebit
*
* @param array $userData
* @return array
*/
public function prefill($userData){
$userId = 0;
$userFullName = '';
if(array_key_exists('billingaddress', $userData)){
if(array_key_exists('userID', $userData['billingaddress'])){
$userId = $userData['billingaddress']['userID'];
}
if(array_key_exists('firstname', $userData['billingaddress']) && array_key_exists('lastname', $userData['billingaddress'])){
$userFullName = $userData['billingaddress']['firstname'] . " " . $userData['billingaddress']['lastname'];
}
}

$creditcardData = $this->prefillCreditcard($userId, $userFullName);
$directdebitData = $this->prefillDirectdebit($userId, $userFullName);
return array_merge($creditcardData, $directdebitData);
}

/**
* Returns the prefilldata for creditcard
*
* @param integer $userId
* @param string $userFullName
* @return array
*/
private function prefillCreditcard($userId, $userFullName){
$prefillData = array(
'paymillCardHolder' => $userFullName,
'paymillCardNumber' => '',
'paymillCvc' => '',
'paymillMonth' => '',
'paymillYear' => ''
);

$paymentId = $this->modelHelper->getPaymillPaymentId('cc', $userId);
if ($paymentId != "") {
$paymentObject = $this->servicePayments->getOne($paymentId);
$prefillData['paymillCardNumber'] = "..." . $paymentObject['last4'];
$prefillData['paymillCvc'] = "***";
$prefillData['paymillMonth'] = $paymentObject['expire_month'];
$prefillData['paymillYear'] = $paymentObject['expire_year'];
$prefillData['paymillCardHolder'] = $paymentObject['card_holder'];
$prefillData['paymillBrand'] = $paymentObject['card_type'];
}
return $prefillData;
}

/**
* 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;
}
}
102 changes: 0 additions & 102 deletions Frontend/PaymPaymentCreditcard/Components/ConfigHelper.php

This file was deleted.

37 changes: 14 additions & 23 deletions Frontend/PaymPaymentCreditcard/Components/CsvReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,13 @@ private function _setLanguages()
*/
private function _loadCsvFiles()
{
try {
if (($files = scandir($this->getPath()))) {
foreach ($files as $file) {
if (is_file($this->getPath() . $file)) {
$this->_loadCsvFileByName($file);
}
if (($files = scandir($this->getPath()))) {
foreach ($files as $file) {
if (is_file($this->getPath() . $file)) {
$this->_loadCsvFileByName($file);
}
}
} catch (Exception $exc) {
Shopware()->Log()->Error($exc->getTraceAsString());
}

return $this->_prepareDbInsert($this->_translations);
}

Expand Down Expand Up @@ -114,23 +109,19 @@ private function _loadCsvFileByName($filename)
private function _prepareDbInsert()
{
$result = "";
try {
$snippetsArray = $this->_translations;
$shopIdsSql = "SELECT id FROM s_core_shops WHERE locale_id = ?";
foreach ($snippetsArray as $localeId => $snippets) {
$shopIds = Shopware()->Db()->fetchAll($shopIdsSql, array($localeId));
foreach ($shopIds as $list => $shopId) {
foreach ($snippets as $name => $value) {
$baseString = "('Paymill', ". Shopware()->Db()->quote(array($name, $value, $localeId, $shopId['id'])) .", NOW(), NOW()),";
$result .= $baseString;
}
$snippetsArray = $this->_translations;
$shopIdsSql = "SELECT id FROM s_core_shops WHERE locale_id = ?";
foreach ($snippetsArray as $localeId => $snippets) {
$shopIds = Shopware()->Db()->fetchAll($shopIdsSql, array($localeId));
foreach ($shopIds as $list => $shopId) {
foreach ($snippets as $name => $value) {
$baseString = "('Paymill', ". Shopware()->Db()->quote(array($name, $value, $localeId, $shopId['id'])) .", NOW(), NOW()),";
$result .= $baseString;
}
}
$result = substr_replace($result ,"",-1);
$result .= ";";
} catch (Exception $exc) {
Shopware()->Log()->Error($exc->getTraceAsString());
}
$result = substr_replace($result ,"",-1);
$result .= ";";
return $result;
}

Expand Down
Loading

0 comments on commit 3f35d02

Please sign in to comment.