@@ -58,7 +58,7 @@ from __future__ import unicode_literals | |||||
import frappe | import frappe | ||||
import json | import json | ||||
from frappe import _ | from frappe import _ | ||||
from frappe.utils import get_url, call_hook_method | |||||
from frappe.utils import get_url, call_hook_method, cint | |||||
from urllib import urlencode | from urllib import urlencode | ||||
from frappe.integration_broker.doctype.integration_service.integration_service import IntegrationService | from frappe.integration_broker.doctype.integration_service.integration_service import IntegrationService | ||||
import urllib | import urllib | ||||
@@ -74,7 +74,7 @@ class PayPalSettings(IntegrationService): | |||||
def setup_sandbox_env(self, token): | def setup_sandbox_env(self, token): | ||||
data = json.loads(frappe.db.get_value("Integration Request", token, "data")) | data = json.loads(frappe.db.get_value("Integration Request", token, "data")) | ||||
setattr(self, "use_sandbox", frappe._dict(data).use_sandbox or 0) | |||||
setattr(self, "use_sandbox", cint(frappe._dict(data).use_sandbox) or 0) | |||||
def validate(self): | def validate(self): | ||||
if not self.flags.ignore_mandatory: | if not self.flags.ignore_mandatory: | ||||
@@ -126,7 +126,7 @@ class PayPalSettings(IntegrationService): | |||||
frappe.throw(_("Invalid payment gateway credentials")) | frappe.throw(_("Invalid payment gateway credentials")) | ||||
def get_payment_url(self, **kwargs): | def get_payment_url(self, **kwargs): | ||||
setattr(self, "use_sandbox", kwargs.get("use_sandbox", 0)) | |||||
setattr(self, "use_sandbox", cint(kwargs.get("use_sandbox", 0))) | |||||
response = self.execute_set_express_checkout(kwargs["amount"], kwargs["currency"]) | response = self.execute_set_express_checkout(kwargs["amount"], kwargs["currency"]) | ||||
@@ -53,7 +53,7 @@ For razorpay payment status is Authorized | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import frappe | import frappe | ||||
from frappe.utils import get_url, call_hook_method | |||||
from frappe.utils import get_url, call_hook_method, cint | |||||
from frappe import _ | from frappe import _ | ||||
import urllib, json | import urllib, json | ||||
from frappe.integration_broker.doctype.integration_service.integration_service import IntegrationService | from frappe.integration_broker.doctype.integration_service.integration_service import IntegrationService | ||||
@@ -174,7 +174,7 @@ class RazorpaySettings(IntegrationService): | |||||
"api_secret": self.get_password(fieldname="api_secret", raise_exception=False) | "api_secret": self.get_password(fieldname="api_secret", raise_exception=False) | ||||
}) | }) | ||||
if data.get('notes', {}).get('use_sandbox'): | |||||
if cint(data.get('notes', {}).get('use_sandbox')): | |||||
settings.update({ | settings.update({ | ||||
"api_key": frappe.conf.sandbox_api_key, | "api_key": frappe.conf.sandbox_api_key, | ||||
"api_secret": frappe.conf.sandbox_api_secret, | "api_secret": frappe.conf.sandbox_api_secret, | ||||
@@ -3,7 +3,7 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import frappe | import frappe | ||||
from frappe import _ | from frappe import _ | ||||
from frappe.utils import flt | |||||
from frappe.utils import flt, cint | |||||
import json | import json | ||||
no_cache = 1 | no_cache = 1 | ||||
@@ -30,8 +30,7 @@ def get_context(context): | |||||
def get_api_key(): | def get_api_key(): | ||||
api_key = frappe.db.get_value("Razorpay Settings", None, "api_key") | api_key = frappe.db.get_value("Razorpay Settings", None, "api_key") | ||||
if frappe.form_dict.get("use_sandbox"): | |||||
if cint(frappe.form_dict.get("use_sandbox")): | |||||
api_key = frappe.conf.sandbox_api_key | api_key = frappe.conf.sandbox_api_key | ||||
return api_key | return api_key | ||||