DROP TABLE IF EXISTS `plugin_postfinance`;
CREATE TABLE IF NOT EXISTS `plugin_postfinance` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `foreign_id` int(10) unsigned DEFAULT NULL,
  `postfinance_id` varchar(255) DEFAULT NULL,
  `token` varchar(255) DEFAULT NULL,
  `amount` decimal(9,2) unsigned DEFAULT NULL,
  `currency` varchar(3) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `foreign_id` (`foreign_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

INSERT INTO `plugin_payment_options` (`payment_method`) VALUES ('postfinance');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'payment_methods_ARRAY_postfinance', 'arrays', 'payment_methods_ARRAY_postfinance', 'script');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'postfinance', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_payment_title', 'frontend', 'postfinance plugin / Payment title', 'script');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'postfinance payment', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_allow', 'backend', 'postfinance plugin / Allow postfinance Payments', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Allow postfinance payments', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_public_key', 'backend', 'postfinance plugin / Public Key', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'postfinance public key:', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_public_key_text', 'backend', 'postfinance plugin / Public Key Text', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'This is your postfinance public key.', 'plugin');


INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_private_key', 'backend', 'postfinance plugin / Secret Key', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'postfinance secret key:', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_private_key_text', 'backend', 'postfinance plugin / Secret Key Text', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'This is your postfinance secret key.', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_space_id', 'backend', 'postfinance plugin / Space Id', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Space Id:', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`) VALUES
  (NULL, 'plugin_postfinance_space_id_text', 'backend', 'postfinance plugin / Space Id Text', 'plugin');
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES
  (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'This is your postfinance Space Id.', 'plugin');

INSERT INTO `plugin_base_fields` VALUES (NULL, 'payment_plugin_messages_ARRAY_postfinance', 'arrays', 'payment_plugin_messages_ARRAY_postfinance', 'script', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` VALUES (NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Your order is saved. Redirecting to postfinance Checkout...', 'script');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_menu_payments', 'backend', 'postfinance plugin / Payments', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Payments', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_info_title', 'backend', 'postfinance plugin / postfinance payments', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Payment details', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_foreign_id', 'backend', 'postfinance plugin / Foreign ID', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Foreign ID', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_postfinance_id', 'backend', 'postfinance plugin / postfinance ID', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'postfinance ID', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_token', 'backend', 'postfinance plugin / Token', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Token', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_created', 'backend', 'postfinance plugin / Created', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Date / Time', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_amount', 'backend', 'postfinance plugin / Amount', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Amount', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_currency', 'backend', 'postfinance plugin / Currency', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Currency', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_btn_view', 'backend', 'postfinance plugin / Button view', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'View', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_btn_close', 'backend', 'postfinance plugin / Button close', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Close', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_description', 'backend', 'postfinance plugin / Description', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Description', 'plugin');

INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_msg', 'backend', 'postfinance plugin / Redirect message', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'If your browser does not redirects you in 3 seconds, please click the button below.', 'plugin');


INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_submit', 'backend', 'postfinance plugin / Pay with postfinance', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Pay with postfinance', 'plugin');


INSERT INTO `plugin_base_fields` (`id`, `key`, `type`, `label`, `source`, `modified`) VALUES 
(NULL, 'plugin_postfinance_payment_label', 'backend', 'postfinance plugin / Label', 'plugin', NULL);
SET @id := (SELECT LAST_INSERT_ID());
INSERT INTO `plugin_base_multi_lang` (`id`, `foreign_id`, `model`, `locale`, `field`, `content`, `source`) VALUES 
(NULL, @id, 'pjBaseField', '::LOCALE::', 'title', 'Label', 'plugin');