Skip to content

Commit

Permalink
Add payment status in comeback url params
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Hivert committed Aug 22, 2018
1 parent 09d0459 commit 8ed1ba0
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions payzen/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import hashlib
from decimal import Decimal, ROUND_HALF_UP
import operator
from datetime import datetime
from decimal import ROUND_HALF_UP, Decimal
from urllib.parse import urlparse


class SEPAMandateFormData:
Expand Down Expand Up @@ -30,11 +31,18 @@ def __init__(self, user, payzen_id, comeback_url, payzen_certificate,
self.vads_version = payzen_version
self.vads_payment_cards = ''

self.vads_url_cancel = comeback_url
self.vads_url_error = comeback_url
self.vads_url_refused = comeback_url
self.vads_url_return = comeback_url
self.vads_url_success = comeback_url
query_param_name = 'payment'
if urlparse(comeback_url)[4]:
# already have query params
join_char = '&'
else:
join_char = '?'

self.vads_url_cancel = join_char.join([comeback_url, '%s=cancel' % query_param_name])
self.vads_url_error = join_char.join([comeback_url, '%s=error' % query_param_name])
self.vads_url_refused = join_char.join([comeback_url, '%s=refused' % query_param_name])
self.vads_url_return = join_char.join([comeback_url, '%s=return' % query_param_name])
self.vads_url_success = join_char.join([comeback_url, '%s=success' % query_param_name])
if redirect_timeout is not None:
self.vads_redirect_success_timeout = str(redirect_timeout)

Expand Down

0 comments on commit 8ed1ba0

Please sign in to comment.