Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iframe's generation for fraudCheck #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions maxipago/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@

class Maxipago(object):

def __init__(self, maxid, api_key, api_version='3.1.1.15', sandbox=False):
def __init__(self, maxid, api_key, api_version='3.1.1.15', sandbox=False, secret_key=''):
self.maxid = maxid
self.api_key = api_key
self.api_version = api_version
self.sandbox = sandbox
self.secret_key = secret_key

def __getattr__(self, name):
try:
class_name = ''.join([n.title() for n in name.split('_') + ['manager']])
module = __import__('maxipago.managers.{0}'.format(name), fromlist=[''])
klass = getattr(module, class_name)
return klass(self.maxid, self.api_key, self.api_version, self.sandbox)
return klass(self.maxid, self.api_key, self.api_version, self.sandbox, self.secret_key)
except ImportError, AttributeError:
if name in self.__dict__:
return self.__dict__.get('name')
Expand Down
5 changes: 3 additions & 2 deletions maxipago/managers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
class Manager(object):
api_type = None

def __init__(self, maxid, api_key, api_version, sandbox):
def __init__(self, maxid, api_key, api_version, sandbox, secret_key):
self.maxid = maxid
self.api_key = api_key
self.api_version = api_version
self.sandbox = sandbox
self.secret_key = secret_key

if sandbox:
self.uri_transaction = 'https://testapi.maxipago.net/UniversalAPI/postXML'
Expand All @@ -24,7 +25,7 @@ def __init__(self, maxid, api_key, api_version, sandbox):

def request(self, xml_data, api_type=None):
uri = self.get_uri(api_type)
response = requests.post(url=uri, data=xml_data, headers={'content-type': 'text/xml'})
response = requests.post(url=uri, data=xml_data, headers={'content-type': 'text/xml'}, verify=False)

if not str(response.status_code).startswith('2'):
raise HttpErrorException(u'Error %s: %s' % (response.status_code, response.reason))
Expand Down
4 changes: 2 additions & 2 deletions maxipago/managers/payment/payment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8
from urllib import urlencode
from hashlib import md5
import hmac
from maxipago.managers.base import ManagerTransaction
from maxipago.requesters.payment import PaymentRequester
from maxipago.resources.payment import PaymentResource
Expand Down Expand Up @@ -170,7 +170,7 @@ def get_fraud_check_iframe(self, **kwargs):
params = {
'm': self.maxid,
's': requester.cleaned_data.get('order_id'),
'h': md5('{0}*{1}'.format(self.maxid, requester.cleaned_data.get('order_id'))).hexdigest()
'h': hmac.new(self.secret_key, '{0}*{1}'.format(self.maxid, requester.cleaned_data.get('order_id'))).hexdigest()
}

url = 'https://testauthentication.maxipago.net/redirection_service/logo?{0}'.format(urlencode(params))
Expand Down