This is the code we use on bandtastic.me to build a html that sends users to dineromail to pay with. This code builds a form thats ready to send multiple items.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | ## in the view that renders the form
import urllib
user = request.user
payment = Payment.objects.create(who=user,payment_system='Dineromail')
return_url = urllib.quote('http://domain.com/return_url') #this where the user will return after finishing on Dineromail
cancel_url = urllib.quote('http://domain.com/cancel_url') #if something go wrong
dineromail_dict = {}
i = 1
for payment in mypaymentmodel: #we add our items
dineromail_dict['item_currency_'+str(i)] = 'mxn' #mexican pesos
dineromail_dict['item_quantity_'+str(i)] = '1' #one of this type
dineromail_dict['item_name_'+str(i)] = payment.thingtopay
dineromail_dict['item_ammount_'+str(i)] = payment.price
dineromail_dict['item_code_'+str(i)] = payment.id
i += 1
#all these fields you can check in this pdf https://mx.dineromail.com/content/Integración-MX.pdf
dineromail_dict['merchant'] = 1234578
dineromail_dict['NroItem'] = 'a unique string, unique per form 1323234wd'
dineromail_dict['ok_url'] = return_url+'?dineromail=True&total=23' #Pass any parameters(not sensitive) so your site can use them to display a relevant page'
dineromail_dict['error_url'] = cancel_url+'?dineromail=True&total=23'
dineromail_dict['pending_url'] = return_url+'?dineromail=True&total=23'
dineromail_dict['Mensaje'] = '0' #if you want the user to send us a message from dineromail
dineromail_dict['header_image'] = 'http://domain.com/static/images/logo.png' #your logo
dineromail_dict['payment_method_available'] = 'mx_oxxo;mx_7eleven' #see the pdf above
dineromail_dict['country_id'] = '4' #reference in the pdf
dineromail_dict['buyer_name'] = user.get_profile().first_name #your user data
dineromail_dict['buyer_lastname'] = user.get_profile().last_name
dineromail_dict['buyer_email'] = user.email
dineromail_dict['buyer_phone'] = '555555555'
dineromail_dict['change_quantity'] = '0'
dineromail_dict['display_shipping'] = '0'
dineromail_dict['button_color'] = 'ff8f1f' #hex values
dineromail_dict['links_color'] = '000000'
dineromail_dict['font_color'] = '000000'
dineromail_dict['border_color'] = '000000'
dineromail_dict['display_additional_charge'] = '0'
context['dineromail'] = dineromail_dict
return render_to_response(template_name,context,context_instance=RequestContext(request))
#### In your template
<form.checkout action='https://checkout.dineromail.com/CheckOut' method='post' />
{% for name,value in dineromail.items %}
<input type='hidden' value='{{value}}' name='{{name}}'>
{% endfor %}
<input.pay type='submit' name='dineromail_submit' value='Paga en OXXO ó 7-Eleven'>
</form>
|
More like this
- Template tag - list punctuation for a list of items by shapiromatron 11 months, 2 weeks ago
- JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 11 months, 3 weeks ago
- Serializer factory with Django Rest Framework by julio 1 year, 6 months ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 7 months ago
- Help text hyperlinks by sa2812 1 year, 7 months ago
Comments
Please login first before commenting.