summaryrefslogtreecommitdiff
path: root/addons/payment_authorize/static
diff options
context:
space:
mode:
Diffstat (limited to 'addons/payment_authorize/static')
-rw-r--r--addons/payment_authorize/static/description/icon.pngbin0 -> 6290 bytes
-rw-r--r--addons/payment_authorize/static/description/icon.svg1
-rw-r--r--addons/payment_authorize/static/src/img/authorize_icon.pngbin0 -> 2966 bytes
-rw-r--r--addons/payment_authorize/static/src/js/payment_form.js160
4 files changed, 161 insertions, 0 deletions
diff --git a/addons/payment_authorize/static/description/icon.png b/addons/payment_authorize/static/description/icon.png
new file mode 100644
index 00000000..235f1adb
--- /dev/null
+++ b/addons/payment_authorize/static/description/icon.png
Binary files differ
diff --git a/addons/payment_authorize/static/description/icon.svg b/addons/payment_authorize/static/description/icon.svg
new file mode 100644
index 00000000..c2755ee6
--- /dev/null
+++ b/addons/payment_authorize/static/description/icon.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="70" height="70"><defs><path id="a" d="M4 0h61c4 0 5 1 5 5v60c0 4-1 5-5 5H4c-3 0-4-1-4-5V5c0-4 1-5 4-5z"/><linearGradient id="c" x1="100%" x2="0%" y1="0%" y2="100%"><stop offset="0%" stop-color="#94B6C8"/><stop offset="100%" stop-color="#6A9EBA"/></linearGradient><path id="d" d="M19.25 46h2.714v1.212c0 .188.152.343.339.343h26.394a.342.342 0 0 0 .339-.343V37.5H33.625l-2.62-6.5h18.031v-3.212a.342.342 0 0 0-.339-.343H29.765l-1.018-2.742h20.289c1.5 0 2.714 1.228 2.714 2.742v20.11c0 1.514-1.213 2.742-2.714 2.742H21.964c-1.5 0-2.714-1.228-2.714-2.742V46zm-3.79 9.642h-1.037V55h2.833v.642h-1.037v2.832h-.76v-2.832zM17.422 55h1.07l.809 2.389h.01L20.075 55h1.07v3.474h-.711v-2.462h-.01l-.847 2.462h-.586l-.848-2.438h-.01v2.438h-.711V55zm17.163-12.266c0 .228-.19.342-.57.342-.253 0-.481-.013-.684-.038l-4.826-.076-4.826.076a4.036 4.036 0 0 1-.57.038c-.507 0-.76-.127-.76-.38 0-.279.342-.418 1.026-.418 2.23-.025 3.344-.253 3.344-.684 0-.025-.025-.127-.076-.304l-.304-1.026-.19-.532c-.228-.785-.785-2.52-1.672-5.206h-8.132c-1.52 4.053-2.28 6.384-2.28 6.992 0 .355.152.57.456.646.076.025.71.076 1.9.152.735.025 1.102.152 1.102.38 0 .253-.33.38-.988.38-1.165 0-2.52-.05-4.066-.152-.38-.025-.773-.038-1.178-.038-.405 0-.798.025-1.178.076A4.157 4.157 0 0 1 9.62 43c-.355 0-.532-.114-.532-.342 0-.228.399-.355 1.197-.38.798-.025 1.374-.146 1.729-.361s.633-.627.836-1.235c3.268-9.323 5.928-16.809 7.98-22.458a5.04 5.04 0 0 1 .304-1.026l.19-.684c.076-.279.177-.418.304-.418.076 0 .14.076.19.228.33.988 1.077 3.053 2.242 6.194.912 2.457 3.18 8.626 6.802 18.506.203.557.462.912.779 1.064.317.152.969.24 1.957.266.659.025.988.152.988.38zM24.25 33.652l-2.014-5.662-1.824-5.206c-1.064 2.787-2.343 6.41-3.838 10.868h7.676z"/><path id="e" d="M19.25 44h2.714v1.212c0 .188.152.343.339.343h26.394a.342.342 0 0 0 .339-.343V35.5H33.625l-2.62-6.5h18.031v-3.212a.342.342 0 0 0-.339-.343H29.765l-1.018-2.742h20.289c1.5 0 2.714 1.228 2.714 2.742v20.11c0 1.514-1.213 2.742-2.714 2.742H21.964c-1.5 0-2.714-1.228-2.714-2.742V44zm-3.79 9.642h-1.037V53h2.833v.642h-1.037v2.832h-.76v-2.832zM17.422 53h1.07l.809 2.389h.01L20.075 53h1.07v3.474h-.711v-2.462h-.01l-.847 2.462h-.586l-.848-2.438h-.01v2.438h-.711V53zm17.163-12.266c0 .228-.19.342-.57.342-.253 0-.481-.013-.684-.038l-4.826-.076-4.826.076a4.036 4.036 0 0 1-.57.038c-.507 0-.76-.127-.76-.38 0-.279.342-.418 1.026-.418 2.23-.025 3.344-.253 3.344-.684 0-.025-.025-.127-.076-.304l-.304-1.026-.19-.532c-.228-.785-.785-2.52-1.672-5.206h-8.132c-1.52 4.053-2.28 6.384-2.28 6.992 0 .355.152.57.456.646.076.025.71.076 1.9.152.735.025 1.102.152 1.102.38 0 .253-.33.38-.988.38-1.165 0-2.52-.05-4.066-.152-.38-.025-.773-.038-1.178-.038-.405 0-.798.025-1.178.076A4.157 4.157 0 0 1 9.62 41c-.355 0-.532-.114-.532-.342 0-.228.399-.355 1.197-.38.798-.025 1.374-.146 1.729-.361s.633-.627.836-1.235c3.268-9.323 5.928-16.809 7.98-22.458a5.04 5.04 0 0 1 .304-1.026l.19-.684c.076-.279.177-.418.304-.418.076 0 .14.076.19.228.33.988 1.077 3.053 2.242 6.194.912 2.457 3.18 8.626 6.802 18.506.203.557.462.912.779 1.064.317.152.969.24 1.957.266.659.025.988.152.988.38zM24.25 31.652l-2.014-5.662-1.824-5.206c-1.064 2.787-2.343 6.41-3.838 10.868h7.676z"/></defs><g fill="none" fill-rule="evenodd"><mask id="b" fill="#fff"><use xlink:href="#a"/></mask><g mask="url(#b)"><path fill="url(#c)" d="M0 0H70V70H0z"/><path fill="#FFF" fill-opacity=".383" d="M4 1h61c2.667 0 4.333.667 5 2V0H0v3c.667-1.333 2-2 4-2z"/><path fill="#393939" d="M4 69c-2 0-4-1-4-4V33.916l21.6-19.82 3.4 8.607h12.25L48 23l3.576 1.968-.236 22.01L39.224 69H4z" opacity=".324"/><path fill="#000" fill-opacity=".383" d="M4 69h61c2.667 0 4.333-1 5-3v4H0v-4c.667 2 2 3 4 3z"/><use fill="#000" fill-rule="nonzero" opacity=".3" xlink:href="#d"/><use fill="#FFF" fill-rule="nonzero" xlink:href="#e"/></g></g></svg> \ No newline at end of file
diff --git a/addons/payment_authorize/static/src/img/authorize_icon.png b/addons/payment_authorize/static/src/img/authorize_icon.png
new file mode 100644
index 00000000..5f039387
--- /dev/null
+++ b/addons/payment_authorize/static/src/img/authorize_icon.png
Binary files differ
diff --git a/addons/payment_authorize/static/src/js/payment_form.js b/addons/payment_authorize/static/src/js/payment_form.js
new file mode 100644
index 00000000..54007ce4
--- /dev/null
+++ b/addons/payment_authorize/static/src/js/payment_form.js
@@ -0,0 +1,160 @@
+odoo.define('payment_authorize.payment_form', function (require) {
+"use strict";
+
+var ajax = require('web.ajax');
+var core = require('web.core');
+var PaymentForm = require('payment.payment_form');
+
+var _t = core._t;
+
+PaymentForm.include({
+
+ //--------------------------------------------------------------------------
+ // Private
+ //--------------------------------------------------------------------------
+
+ /**
+ * Returns the parameters for the AcceptUI button that AcceptJS will use.
+ *
+ * @private
+ * @param {Object} formData data obtained by getFormData
+ * @returns {Object} params for the AcceptJS button
+ */
+ _acceptJsParams: function (formData) {
+ return {
+ 'class': 'AcceptUI d-none',
+ 'data-apiLoginID': formData.login_id,
+ 'data-clientKey': formData.client_key,
+ 'data-billingAddressOptions': '{"show": false, "required": false}',
+ 'data-responseHandler': 'responseHandler'
+ };
+ },
+
+ /**
+ * called when clicking on pay now or add payment event to create token for credit card/debit card.
+ *
+ * @private
+ * @param {Event} ev
+ * @param {DOMElement} checkedRadio
+ * @param {Boolean} addPmEvent
+ */
+ _createAuthorizeToken: function (ev, $checkedRadio, addPmEvent) {
+ var self = this;
+ if (ev.type === 'submit') {
+ var button = $(ev.target).find('*[type="submit"]')[0]
+ } else {
+ var button = ev.target;
+ }
+ var acquirerID = this.getAcquirerIdFromRadio($checkedRadio);
+ var acquirerForm = this.$('#o_payment_add_token_acq_' + acquirerID);
+ var inputsForm = $('input', acquirerForm);
+ var formData = self.getFormData(inputsForm);
+ if (this.options.partnerId === undefined) {
+ console.warn('payment_form: unset partner_id when adding new token; things could go wrong');
+ }
+ var AcceptJs = false;
+ if (formData.acquirer_state === 'enabled') {
+ AcceptJs = 'https://js.authorize.net/v3/AcceptUI.js';
+ } else {
+ AcceptJs = 'https://jstest.authorize.net/v3/AcceptUI.js';
+ }
+
+ window.responseHandler = function (response) {
+ _.extend(formData, response);
+
+ if (response.messages.resultCode === "Error") {
+ var errorMessage = "";
+ _.each(response.messages.message, function (message) {
+ errorMessage += message.code + ": " + message.text;
+ })
+ acquirerForm.removeClass('d-none');
+ return self.displayError(_t('Server Error'), errorMessage);
+ }
+
+ self._rpc({
+ route: formData.data_set,
+ params: formData
+ }).then (function (data) {
+ if (addPmEvent) {
+ if (formData.return_url) {
+ window.location = formData.return_url;
+ } else {
+ window.location.reload();
+ }
+ } else {
+ $checkedRadio.val(data.id);
+ self.el.submit();
+ }
+ }).guardedCatch(function (error) {
+ // if the rpc fails, pretty obvious
+ error.event.preventDefault();
+ acquirerForm.removeClass('d-none');
+ self.displayError(
+ _t('Server Error'),
+ _t("We are not able to add your payment method at the moment.") +
+ self._parseError(error)
+ );
+ });
+ };
+
+ if (this.$button === undefined) {
+ this.$button = $('<button>', this._acceptJsParams(formData));
+ this.$button.appendTo('body');
+ }
+ ajax.loadJS(AcceptJs).then(function () {
+ self.$button.trigger('click');
+ });
+ },
+ /**
+ * @override
+ */
+ updateNewPaymentDisplayStatus: function () {
+ var $checkedRadio = this.$('input[type="radio"]:checked');
+
+ if ($checkedRadio.length !== 1) {
+ return;
+ }
+
+ // hide add token form for authorize
+ if ($checkedRadio.data('provider') === 'authorize' && this.isNewPaymentRadio($checkedRadio)) {
+ this.$('[id*="o_payment_add_token_acq_"]').addClass('d-none');
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+
+ //--------------------------------------------------------------------------
+ // Handlers
+ //--------------------------------------------------------------------------
+
+ /**
+ * @override
+ */
+ payEvent: function (ev) {
+ ev.preventDefault();
+ var $checkedRadio = this.$('input[type="radio"]:checked');
+
+ // first we check that the user has selected a authorize as s2s payment method
+ if ($checkedRadio.length === 1 && this.isNewPaymentRadio($checkedRadio) && $checkedRadio.data('provider') === 'authorize') {
+ this._createAuthorizeToken(ev, $checkedRadio);
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+ /**
+ * @override
+ */
+ addPmEvent: function (ev) {
+ ev.stopPropagation();
+ ev.preventDefault();
+ var $checkedRadio = this.$('input[type="radio"]:checked');
+
+ // first we check that the user has selected a authorize as add payment method
+ if ($checkedRadio.length === 1 && this.isNewPaymentRadio($checkedRadio) && $checkedRadio.data('provider') === 'authorize') {
+ this._createAuthorizeToken(ev, $checkedRadio, true);
+ } else {
+ this._super.apply(this, arguments);
+ }
+ },
+});
+});