diff --git a/addons/payment_asiapay/const.py b/addons/payment_asiapay/const.py index b04c955b6e1..e91bb4ee0c8 100644 --- a/addons/payment_asiapay/const.py +++ b/addons/payment_asiapay/const.py @@ -1,5 +1,19 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. +API_URLS = { + 'production': { + 'pesopay': 'https://www.pesopay.com/b2c2/eng/payment/payForm.jsp', + 'siampay': 'https://www.siampay.com/b2c2/eng/payment/payForm.jsp', + 'bimopay': 'https://www.bimopay.com/b2c2/eng/payment/payForm.jsp', + 'paydollar': 'https://www.paydollar.com/b2c2/eng/payment/payForm.jsp', + }, + 'test': { + 'pesopay': 'https://test.pesopay.com/b2cDemo/eng/payment/payForm.jsp', + 'siampay': 'https://test.siampay.com/b2cDemo/eng/payment/payForm.jsp', + 'paydollar': 'https://test.paydollar.com/b2cDemo/eng/payment/payForm.jsp', + } +} + # Mapping of currency ISO 4217 codes AsiaPay's currency codes. # See https://www.paydollar.com/pdf/op/enpdintguide.pdf for the list of currency codes. CURRENCY_MAPPING = { diff --git a/addons/payment_asiapay/models/payment_provider.py b/addons/payment_asiapay/models/payment_provider.py index a4373be2584..934bbf7c2f2 100644 --- a/addons/payment_asiapay/models/payment_provider.py +++ b/addons/payment_asiapay/models/payment_provider.py @@ -14,6 +14,14 @@ class PaymentProvider(models.Model): code = fields.Selection( selection_add=[('asiapay', "AsiaPay")], ondelete={'asiapay': 'set default'} ) + asiapay_brand = fields.Selection( + string="Asiapay Brand", + help="The brand associated to your AsiaPay account.", + selection=[("paydollar", "PayDollar"), ("pesopay", "PesoPay"), + ("siampay", "SiamPay"), ("bimopay", "BimoPay")], + default='paydollar', + required_if_provider='asiapay', + ) asiapay_merchant_id = fields.Char( string="AsiaPay Merchant ID", help="The Merchant ID solely used to identify your AsiaPay account.", @@ -50,10 +58,9 @@ class PaymentProvider(models.Model): """ self.ensure_one() - if self.state == 'enabled': - return 'https://www.paydollar.com/b2c2/eng/payment/payForm.jsp' - else: # 'test' - return 'https://test.paydollar.com/b2cDemo/eng/payment/payForm.jsp' + environment = 'production' if self.state == 'enabled' else 'test' + api_urls = const.API_URLS[environment] + return api_urls.get(self.asiapay_brand, api_urls['paydollar']) def _asiapay_calculate_signature(self, data, incoming=True): """ Compute the signature for the provided data according to the AsiaPay documentation. diff --git a/addons/payment_asiapay/views/payment_provider_views.xml b/addons/payment_asiapay/views/payment_provider_views.xml index be784509ab0..06e04d15204 100644 --- a/addons/payment_asiapay/views/payment_provider_views.xml +++ b/addons/payment_asiapay/views/payment_provider_views.xml @@ -8,6 +8,9 @@ +