{ "info": { "author": "Yves Serrano", "author_email": "ys@taywa.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-saferpay\n\n*Saferpay integration for django*\n\nThis packages uses the saferpay json api and the saferpay payment page interface.\nThis is NOT an offical package from SIX Payment Services.\n\nSee the official [saferpay json api](http://saferpay.github.io/jsonapi/#ChapterPaymentPage) for more information.\nTake also a look at [test.saferpay.com](https://test.saferpay.com/).\n\n## django setup\n\nThis django package in used in cunjunction with django-oscar. It can work with other django shop systems,\nnothing is tied to django-oscar.\n\nIt's used with dango 1.11 but should/could work with django 2.0, 2.1.\n\nfirst update `settings.py`:\n\n```python\nfrom django.urls import reverse_lazy\nfrom django.utils.translation import ugettext_lazy as _\n\nINSTALLED_APPS = [\n ...\n 'saferpay',\n]\n\n...\nSAFERPAY_APIURL = 'https://test.saferpay.com/api'\nSAFERPAY_USERNAME = 'API_XXX'\nSAFERPAY_PASSWORD = 'XXX'\nSAFERPAY_CUSTOMERID = 'xxxxxx' # a number\nSAFERPAY_TERMINALID = 'xxxxxx' # a number\nSAFERPAY_SUCCESS_CAPTURE_URL = reverse_lazy('yourshop:payment-capture') # your callback after getting the money\nSAFERPAY_SUCCESS_URL = reverse_lazy('yourshop:thank-you') # your callback after a successfull order\nSAFERPAY_FAIL_URL = reverse_lazy('yourshop:payment-failed') # your callback after a failed payment\nSAFERPAY_ORDER_TEXT_NR = _('Payment for the company XXX, Order nr. %s.')\nSAFERPAY_FORCE_LIABILITYSHIFT_ACTIVE = False # default: False\nSAFERPAY_DO_NOTIFY = True # default: False\n...\n```\n\nYou need to provide three URLs from your shop app for providing callbacks for the saferpay gateway. \n\n- `SAFERPAY_SUCCESS_CAPTURE_URL` - saferpay callback for a successfull capture of the amount\n after PAYMENTPAGE_INIT and PAYMENTPAGE_ASSERT\n- `SAFERPAY_SUCCESS_URL` - everything went fine, saferpay callback to shop success url\n- `SAFERPAY_FAIL_URL` - something went wrong, saferpay callback to shop failure url\n\nin your project `urls.py`:\n\n```python\n...\n url(r'', include('saferpay.urls')),\n...\n```\n\ncreate the db models\n\n```python\n./manage.py migrate\n```\n\n### django oscar setup\n\nIf you use django oscar got to [django-oscar-saferpay](https://github.com/taywa/django-oscar-saferpay)\nto procced with the setup process and see an sample usage implementation.\n\n### sample usage\n\nYou can use this code as example. You need to integrate it into \nyour own views in the shop system.\n\n1. Intizialize the service\n\n```python\nfrom saferpay.gateway import SaferpayService\nfrom saferpay import execptions as sp_execptions\n\n\ndef billing_address_for_saferpay(billing_address):\n \"\"\"Transform you shop billing address to \n a format that saferpay uses.\n Your billing_address object can be totaly differnt, \n adjust it to your needs.\n \"\"\"\n data = {}\n data['FirstName'] = billing_address.first_name\n data['LastName'] = billing_address.last_name\n data['Street'] = billing_address.line1\n if billing_address.line2:\n data['Street2'] = billing_address.line2\n data['Zip'] = billing_address.postcode\n data['City'] = billing_address.city\n return data\n\n\ndef payment_init(request, order):\n \"\"\"\n Intizialize a new SaferpayService instance, with your\n order data. Adjust the the order calls for your shop.\n\n\n The init payload is created and after success you get\n redirected to the saferpay PayementPage.\n \"\"\"\n saferpay_service = SaferpayService(\n order_id=order.number, amount=order.total.incl_tax,\n currency=order.total.currency, language_code=language_code\n )\n\n payload = saferpay_service.payload_init(billing_address=billing_address_data)\n\n try:\n token = saferpay_service.paymentpage_init(payload)\n request.session['saferpay_token'] = token\n raise RedirectRequired(saferpay_service.paymentpage_redirect().url)\n except sp_execptions.GatewayError as e:\n # do your rollback in case of payment failure \n return redirect(reverse_lazy('yourshop:payment-failed'))\n```\n\n2. Assert and Capture the money and place the order\n\n```python\nfrom saferpay.gateway import SaferpayService\nfrom saferpay import execptions as sp_execptions\n\n\ndef payment_capture(request):\n token = request.session['saferpay_token']\n saferpay_service = SaferpayService.init_from_transaction(token=token)\n try:\n status = saferpay_service.paymentpage_assert()\n except (\n sp_execptions.GatewayError, sp_execptions.TransactionDeclined,\n sp_execptions.UnableToTakePayment, sp_execptions.PaymentError\n ) as e:\n # do your rollback in case of payment failure \n return redirect(reverse_lazy('yourshop:payment-failed'))\n if status == 'CAPTURED':\n # register the payment in you shop\n logger.info(\"Order #%s: payment successful, placing order\", saferpay_service.order_id)\n\n try:\n # place the order\n except UnableToPlaceOrder as e:\n # go back to preview\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/taywa/django-saferpay", "keywords": "saferpay,payment", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-saferpay", "package_url": "https://pypi.org/project/django-saferpay/", "platform": "", "project_url": "https://pypi.org/project/django-saferpay/", "project_urls": { "Homepage": "https://github.com/taywa/django-saferpay" }, "release_url": "https://pypi.org/project/django-saferpay/0.1.1/", "requires_dist": null, "requires_python": "", "summary": "Saferpay payment integration for django.", "version": "0.1.1" }, "last_serial": 4802914, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e14ec94f48d9c5eb128ff1dd552c6d6b", "sha256": "f394b7027756e02502ee90df15de5792a6c160ba3b5ec9f040c4a70b24fe9f22" }, "downloads": -1, "filename": "django-saferpay-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e14ec94f48d9c5eb128ff1dd552c6d6b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9660, "upload_time": "2019-02-10T17:40:14", "url": "https://files.pythonhosted.org/packages/03/31/7bed4c9a65985740c7660bbf149b745d1dfb6e3f7caa756572e5766b8e93/django-saferpay-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "a5b80a25497c89afe994a5ccc8c3341d", "sha256": "c5bc3e427e946d7339cbe161fd64a35ef81ccbad6297299bfc103dda26ebf9da" }, "downloads": -1, "filename": "django-saferpay-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a5b80a25497c89afe994a5ccc8c3341d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9629, "upload_time": "2019-02-10T18:17:54", "url": "https://files.pythonhosted.org/packages/dc/34/351523cabed300a6647d337bc1e154bf365c212cc73f5caf8a23479866b7/django-saferpay-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a5b80a25497c89afe994a5ccc8c3341d", "sha256": "c5bc3e427e946d7339cbe161fd64a35ef81ccbad6297299bfc103dda26ebf9da" }, "downloads": -1, "filename": "django-saferpay-0.1.1.tar.gz", "has_sig": false, "md5_digest": "a5b80a25497c89afe994a5ccc8c3341d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9629, "upload_time": "2019-02-10T18:17:54", "url": "https://files.pythonhosted.org/packages/dc/34/351523cabed300a6647d337bc1e154bf365c212cc73f5caf8a23479866b7/django-saferpay-0.1.1.tar.gz" } ] }