diff --git a/gateway_selector/__init__.py b/gateway_selector/__init__.py index 95d1338..5dc637c 100644 --- a/gateway_selector/__init__.py +++ b/gateway_selector/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -__version__ = '0.0.1' +__version__ = '1.0.0' diff --git a/gateway_selector/gateway_selector/doctype/gateway_selector_item/gateway_selector_item.json b/gateway_selector/gateway_selector/doctype/gateway_selector_item/gateway_selector_item.json index db4903d..d495043 100644 --- a/gateway_selector/gateway_selector/doctype/gateway_selector_item/gateway_selector_item.json +++ b/gateway_selector/gateway_selector/doctype/gateway_selector_item/gateway_selector_item.json @@ -1,5 +1,6 @@ { "allow_copy": 0, + "allow_guest_to_view": 0, "allow_import": 0, "allow_rename": 0, "beta": 0, @@ -12,6 +13,7 @@ "engine": "InnoDB", "fields": [ { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -22,12 +24,13 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Gateway Service", "length": 0, "no_copy": 0, - "options": "Integration Service", + "options": "Payment Gateway", "permlevel": 0, "precision": "", "print_hide": 0, @@ -41,6 +44,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -51,6 +55,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Label", @@ -69,6 +74,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -79,6 +85,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, "label": "Icon", @@ -97,6 +104,7 @@ "unique": 0 }, { + "allow_bulk_edit": 0, "allow_on_submit": 0, "bold": 0, "collapsible": 0, @@ -108,6 +116,7 @@ "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, + "in_global_search": 0, "in_list_view": 1, "in_standard_filter": 0, "label": "Default", @@ -126,17 +135,17 @@ "unique": 0 } ], + "has_web_view": 0, "hide_heading": 0, "hide_toolbar": 0, "idx": 0, "image_view": 0, "in_create": 0, - "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 1, "max_attachments": 0, - "modified": "2017-03-09 15:46:11.689274", + "modified": "2017-08-28 07:00:32.710946", "modified_by": "Administrator", "module": "Gateway Selector", "name": "Gateway Selector Item", @@ -146,7 +155,9 @@ "quick_entry": 1, "read_only": 0, "read_only_onload": 0, + "show_name_in_global_search": 0, "sort_field": "modified", "sort_order": "DESC", + "track_changes": 1, "track_seen": 0 } \ No newline at end of file diff --git a/gateway_selector/gateway_selector/doctype/gateway_selector_settings/gateway_selector_settings.py b/gateway_selector/gateway_selector/doctype/gateway_selector_settings/gateway_selector_settings.py old mode 100644 new mode 100755 index 06bb7fc..57d28fb --- a/gateway_selector/gateway_selector/doctype/gateway_selector_settings/gateway_selector_settings.py +++ b/gateway_selector/gateway_selector/doctype/gateway_selector_settings/gateway_selector_settings.py @@ -7,27 +7,28 @@ import json from frappe import _dict from frappe.model.document import Document -from frappe.utils import get_url, call_hook_method, cint, flt -from urllib import urlencode +from frappe.utils import get_url, call_hook_method from awesome_cart.compat.customer import get_current_customer -from frappe.integration_broker.doctype.integration_service.integration_service import IntegrationService, get_integration_controller +from frappe.integrations.utils import get_payment_gateway_controller +from frappe.integrations.utils import create_payment_gateway -class GatewaySelectorSettings(IntegrationService): +class GatewaySelectorSettings(Document): service_name = "Gateway Selector" def validate(self): - pass + create_payment_gateway("Gateway Selector") + call_hook_method("payment_gateway_enabled", gateway=self.service_name) + def on_update(self): pass - def enable(self): - call_hook_method("payment_gateway_enabled", gateway=self.service_name) def validate_transaction_currency(self, currency): - for gateway in self.gateways: - controller = get_integration_controller(gateway.service) - controller.validate_transaction_currency(currency) + pass + # for gateway in self.gateways: + # controller = get_payment_gateway_controller(gateway.service) + # controller.validate_transaction_currency(currency) def get_payment_url(self, **kwargs): proxy = self.build_proxy(**kwargs) @@ -84,11 +85,11 @@ def get_awc_gateway_form(context={}): def is_gateway_embedable(name): """Returns True if the the gateway supports get_embed_form api""" - controller = get_integration_controller(name) + controller = get_payment_gateway_controller(name) return hasattr(controller, "is_embedable") and controller.is_embedable def is_gateway_available(name, context, is_backend=0): - controller = get_integration_controller(name) + controller = get_payment_gateway_controller(name) if hasattr(controller, "is_available"): return controller.is_available(context, is_backend=is_backend) @@ -97,7 +98,7 @@ def is_gateway_available(name, context, is_backend=0): def get_gateway_embed_form(name, context={}): """Gets the gateway's embedable form information""" - controller = get_integration_controller(name) + controller = get_payment_gateway_controller(name) return controller.get_embed_form(context=context) @frappe.whitelist(allow_guest=True) @@ -107,7 +108,7 @@ def get_url_from_gateway(gateway, data): if isinstance(data, unicode) or isinstance(data, str): data = json.loads(data) - gateway_selector = get_integration_controller("Gateway Selector") + gateway_selector = get_payment_gateway_controller("Gateway Selector") for g in gateway_selector.gateways: if g.service.replace(' ', '_').lower() == gateway: @@ -116,7 +117,7 @@ def get_url_from_gateway(gateway, data): else: gateway_name = None - controller = get_integration_controller(gateway_name) + controller = get_payment_gateway_controller(gateway_name) return controller.get_payment_url(**data) @@ -126,7 +127,7 @@ def get_gateways(context="{}", is_backend=0): context = json.loads(context) context['is_backend'] = is_backend - gateway_selector = get_integration_controller("Gateway Selector") + gateway_selector = get_payment_gateway_controller("Gateway Selector") gateways = [] for gateway in gateway_selector.gateways: if is_gateway_available(gateway.service, context, is_backend=is_backend): diff --git a/gateway_selector/public/css/select.css b/gateway_selector/public/css/select.css index 5c72474..28d5e32 100644 --- a/gateway_selector/public/css/select.css +++ b/gateway_selector/public/css/select.css @@ -11,9 +11,10 @@ margin-top: 1em; } +#gateway-selector-continue.paypal:hover, #gateway-selector-continue.paypal { display: inline-block; - background: url(https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png) center center no-repeat transparent; + background: url(https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png) center center no-repeat transparent !important; width: 170px; height: 32px; text-indent: -10000000em; @@ -21,6 +22,10 @@ padding: 0; } +#gateway-selector-continue.paypal:hover { + border: 1px solid red; +} + .gateway-error { background: #ff5959; color: white; diff --git a/gateway_selector/public/js/base.js b/gateway_selector/public/js/base.js index 27364e3..b1d91cb 100644 --- a/gateway_selector/public/js/base.js +++ b/gateway_selector/public/js/base.js @@ -44,15 +44,15 @@ frappe.gateway_selector.AddressFormProvider = Class.extend({ this.data.pincode = $form.find('input[name="pincode"]').val(); this.data.country = $form.find('select[name="country"] option:checked').attr('value'); } else { - this.data.billing_address = $('#billing-addrs div.selected').attr('data-name'); - this.data.title = $('#billing-addrs .selected span#title strong').text(); - this.data.phone = $('#billing-addrs .selected span#phone').text(); - this.data.address_1 = $('#billing-addrs .selected span#line1').text(); - this.data.address_2 = $('#billing-addrs .selected span#line2').text(); - this.data.city = $('#billing-addrs .selected span#city').text(); - this.data.state = $('#billing-addrs .selected span#state').text(); - this.data.pincode = $('#billing-addrs .selected span#postal_code').text(); - this.data.country = $('#billing-addrs .selected span#country').text(); + this.data.billing_address = $('#awc-billing-addrs div.awc-selected').attr('data-name'); + this.data.title = $('#awc-billing-addrs .awc-selected span#title strong').text(); + this.data.phone = $('#awc-billing-addrs .awc-selected span#phone').text(); + this.data.address_1 = $('#awc-billing-addrs .awc-selected span#line1').text(); + this.data.address_2 = $('#awc-billing-addrs .awc-selected span#line2').text(); + this.data.city = $('#awc-billing-addrs .awc-selected span#city').text(); + this.data.state = $('#awc-billing-addrs .awc-selected span#state').text(); + this.data.pincode = $('#awc-billing-addrs .awc-selected span#postal_code').text(); + this.data.country = $('#awc-billing-addrs .awc-selected span#country').text(); } $form.trigger('address_change', this.data); @@ -255,6 +255,7 @@ frappe.integration_service.gateway_selector_gateway = Class.extend({ $('#gateway-selector-continue').click(function() { + $('html, body').animate({ scrollTop: $('#awc-forms, #gateway-selector-forms').first().offset().top - 60 }, 'slow'); if ( !base._is_enabled ) { return; } diff --git a/gateway_selector/templates/includes/integrations/gateway_selector/billing_address_select.html b/gateway_selector/templates/includes/integrations/gateway_selector/billing_address_select.html index e9de53a..153cb69 100644 --- a/gateway_selector/templates/includes/integrations/gateway_selector/billing_address_select.html +++ b/gateway_selector/templates/includes/integrations/gateway_selector/billing_address_select.html @@ -1,17 +1,17 @@ -
- - + + {{ address.address_line1 }}, {% if address.address_line2 %} {{ address.address_line2 }}, {% endif %} {{ address.city }}, diff --git a/gateway_selector/templates/includes/integrations/gateway_selector/embed.html b/gateway_selector/templates/includes/integrations/gateway_selector/embed.html index 9c8f81f..425343d 100644 --- a/gateway_selector/templates/includes/integrations/gateway_selector/embed.html +++ b/gateway_selector/templates/includes/integrations/gateway_selector/embed.html @@ -21,7 +21,7 @@