Package: django-moneybookers
Moneyboookersgateway forDjangowith two payment forms: common and secure.Moneyboookers gateway allows you to accept payments on your website. It contains two payment paths:Form genaration with POST to MoneybookersSecure redirect with prepared SESSION_IDIn both cases additional security checks are implemented.Full API documentation: “Moneybookers Payment Gateway”How to installDownload the source and place in your apps folderEdit “settings.py”add “moneybookers” to your “INSTALLED_APPS”add following settings (example):MONEYBOOKERS_MERCHANT_ID="123456"MONEYBOOKERS_SECRET_WORD="YourSecretWord"MONEYBOOKERS_PAY_TO_EMAIL="billing@mycompany.com"MONEYBOOKERS_STATUS_URL="https://www.mycompany.com/moneybookers/status_url/"MONEYBOOKERS_CURRENCY_CODE="EUR"not required, but recommended:MONEYBOOKERS_CANCEL_URL="https://www.mycompany.com/moneybookers/cancel/"MONEYBOOKERS_RETURN_URL="https://www.mycompany.com/moneybookers/ok/"MONEYBOOKERS_STATUS_URL2="mailto: billing@mycompany.com"MONEYBOOKERS_RECEPIENT_DESCRIPTION="My Company Limited"For more optional settings please see “conf.py”Add to “urls.py” pathsurlpatterns=patterns('',(r'^moneybookers/status_url/',include('moneybookers.urls')),(r'^moneybookers/cancel/','MoneybookersCancel'),(r'^moneybookers/ok/','MoneybookersOk'),(r'^order/$','View_With_Order'),)Create table in your databasemanage.pysyncdbCreate/render formCommon way:Create an instance of the form in your “views.py” and make render in your templatefrommoneybookers.formsimportMoneybookersStandardFormdefView_With_Order(request):mb_dict={"amount":"25.00","invoice":"4567","user_id":request.user.id,"detail1_description":"Product ID:","detail1_text":"4509334","merchant_field":"new_client","merchant_field_value":"1","user_ipaddress":request.META.get("REMOTE_ADDR","0.0.0.0")}f=MoneybookersStandardForm(initial=mb_dict)context={"form":f}returnrender_to_response("order.html",context)In “order.html”:<h1>Pay with Moneybookers now!</h1>{{ form.render }}After payment Moneybookers sends a signal to your server (status_url). The transaction will be saved in the database, then will be send a signal MoneybookersSignal. You can use it to process your own actions (add amount to users account, etc..). An example to use in “models.py”:
from moneybookers.signals import moneybookers_signal
from django.db import transaction
from django.core.mail import mail_admins@transaction.commit_manuallydefMoneybookersSignal(sender,**kwargs):ifsender.error:mail_admins("Moneybookers: bad transaction%s"%sender.transaction_id,sender.error_text)returnsid=transaction.savepoint()try:user=User.objects.get(id=sender.user_id)profile=user.get_profile()profile.money=profile.money+sender.amountprofile.save()mail_admins("Moneybookers: good transaction%s"%sender.transaction_id,"%sadded to user%s"%(sender.amount,sender.user_id))transaction.savepoint_commit(sid)exceptException,e:transaction.savepoint_rollback(sid)mail_admins("Moneybookers: database rollback: transaction%s"%sender.transaction_id,e)transaction.commit()moneybookers_signal.connect(MoneybookersSignal,dispatch_uid="yourapp.models.MoneybookersSignal")Secure way:Add to “urls.py” another pathurlpatterns=patterns('',(r'^moneybookers_redirect/$','payment_moneybookers_redirect'),)Create an form in your template yourself with POST-Url to “moneybookers_redirect”<formaction="https://www.mycompany.com/moneybookers_redirect/"method="post"><inputname="invoice"value="777"type="hidden"><inputtype="submit"value="Pay with Moneybookers"/></form>In your “views.py” you must check the invoice numberfromdjango.contrib.auth.decoratorsimportlogin_requiredfromdjango.views.decorators.httpimportrequire_POSTfromdjango.httpimportHttpResponseRedirect,HttpResponseServerError@login_required@require_POSTdefpayment_moneybookers_redirect(request):invoice=request.POST.get("invoice",None)mb_dict={"language":"EN","country":...,"amount":...,"prepare_only":True,"detail1_description":"Invoice #","detail1_text":invoice,"invoice":invoice,"user_id":request.user.id,"user_ipaddress":request.META.get("REMOTE_ADDR","0.0.0.0")}# If you want accept only credit cards without user to register on moneybookers:mb_dict["hide_login"]="1"mb_dict["payment_methods"]="ACC"f=MoneybookersSecureForm(initial=mb_dict)url=f.redirect_url()ifurl:returnHttpResponseRedirect(url)returnHttpResponseServerError()Patchyour"models.py"withsignalMoneybookersSignallikein"common way"Based on “Moneybookers Payment Gateway Merchant Integration Manual” v6.10 / 8 Nov. 2010Alex Aster, www.alrond.com, 2010
FreeBSD License