Skip to content

Commit 4d3a848

Browse files
committed
add payu-rest backend
1 parent e8c981b commit 4d3a848

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

payments/models.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,68 @@ def get_success_url(self):
133133
def get_process_url(self):
134134
return reverse('process_payment', kwargs={'token': self.token})
135135

136+
def get_payment_url(self):
137+
"""
138+
Get the url the view that handles the payment (payment_details() in documentation)
139+
For now used only by PayU provider to redirect users back to CVV2 form
140+
"""
141+
raise NotImplementedError()
142+
143+
def get_user(self):
144+
""" Get the user asociated with this payment """
145+
raise NotImplementedError()
146+
147+
def get_user_email(self):
148+
""" Get user email """
149+
try:
150+
return self.get_user().email
151+
except AttributeError:
152+
return None
153+
154+
def get_user_first_name(self):
155+
"""
156+
Get user first name
157+
Used only by PayU provider for now
158+
"""
159+
try:
160+
return self.get_user().first_name
161+
except AttributeError:
162+
return None
163+
164+
def get_user_last_name(self):
165+
"""
166+
Get user last name
167+
Used only by PayU provider for now
168+
"""
169+
try:
170+
return self.get_user().last_name
171+
except AttributeError:
172+
return None
173+
174+
def get_renew_token(self):
175+
"""
176+
Get the recurring payments renew token for user of this payment
177+
Used only by PayU provider for now
178+
"""
179+
raise NotImplementedError()
180+
181+
def set_renew_token(self, token, card_expire_year=None, card_expire_month=None):
182+
"""
183+
Store the recurring payments renew token for user of this payment
184+
The renew token is string defined by the provider
185+
Used only by PayU provider for now
186+
"""
187+
raise NotImplementedError()
188+
189+
def auto_complete_recurring(self):
190+
"""
191+
Complete the payment by automatically recurring token.
192+
Used only by PayU provider for now
193+
Can throw UserActionRequired exception if there is need of user action.
194+
"""
195+
provider = provider_factory(self.variant)
196+
return provider.auto_complete_recurring(self)
197+
136198
def capture(self, amount=None):
137199
if self.status != PaymentStatus.PREAUTH:
138200
raise ValueError(

0 commit comments

Comments
 (0)