{ "info": { "author": "Ing. R.J. van Dongen", "author_email": "rogier@sebsoft.nl", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# python-sdk\n\n- [Installation](#installation)\n- [Requirements](#internal-api-implementation)\n- [Internal API implementation](#requirements)\n- [Quick start and examples](#quick-start-and-examples)\n- [Error handling](#error-handling)\n- [Advanced usage](#advanced-usage)\n\n---\n\n### Installation\n\nThis SDK can be installed through pip.\n\nPip is the package manager for Python.\n\nFor more information on how to use/install pip, please visit: [https://pypi.org/project/pip/](https://pypi.org/project/pip/)\n\nTo install the Pay.nl Python sdk into your project, simply\n\n\t$ pip install paynlsdk\n\n### Requirements\n\nThe Pay.nl Python SDK works on Python 3.7 and is dependent on the requests package and the marshmallow package (v2.x only)\nWhen installing through pip these dependencies will automatically be detected and installed\n\n### Internal API implementation\nNot all function arguments will be completely described for every case.\nWhen using the utility/quick start classes all parameters are available, so take a look at the method arguments there for more options.\nThey are basically self explanatory\n\nEvery API implementation has it's own Request and Response class, which can be found in the various *paynlsdk.api.xxx.yyy* modules.\nEvery one of the modules contain at least a Request and a Response class.\nFor example, the Transaction.info API can be located in the *paynlsdk.api.transation.info* module and will contain both a\n*paynlsdk.api.transaction.info.Request* and a *paynlsdk.api.transaction.info.Response* class \nUsually these modules will also contain a specific (marshmallow) Schema implementation that defines the response mapping from JSON. \n\nFor every call, a response object will be returned.\nUsing the *print(result)* statement, or by investigating the *paynlsdk.objects* module, you can find out what attributes are available.\nEvery result will contain a *request* object, which essentially gives insight on the success or failure of the request.\nThis object is also used to throw a *paynlsk.exceptions.ErrorException* in case the request failed.\nThe rest of the *response* object will contain the information as returned by the PAYL API\n\nAgain, refer to the *paynlsdk.objects* module to investigate the various objects contained in the response.\nThe exact contents of the response objects itself are defined in all the *paynlsdk.api.xxx.yyy.Response* classes\n\n\n\n### Quick start and examples\nDo note this quick start only makes use of the quick-call utility methods.\nIf you're more familiar with Python, you *could* use the full API request/response implementations in the paynlsdk.api namespace\n\nSet configuration (this is a MUST and should always be done before doing anything with the SDK)\n```\nfrom paynlsdk.api.client import APIAuthentication\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n```\n\nTurn on debugging output for the API Client\nNote: this uses \"print\" and will cause a dump of relevant information to the console such as the endpoint, \nHTTP method, request parameters, http headers and the raw response as a result from the API call\n```\nfrom paynlsdk.api.client import APIClient\nAPIClient.print_debug = True\n```\n\nGet banks (ideal banks only)\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.transaction import Transaction\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Transaction.get_banks()\n for bank in result:\n print('{id}: {name}'.format(id=bank.id, name=bank.name))\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nGet list of payment methods\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.paymentmethods import PaymentMethods\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = PaymentMethods.get_list()\n for payment_method in result.values():\n print('{id}: {name} ({visible_name})'.format(id=payment_method.id, name=payment_method.name,\n visible_name=payment_method.visible_name))\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nRetrieving transaction info\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.transaction import Transaction\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Transaction.info(transaction_id='1234567890X1a2b3')\n print(result)\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nRetrieving transaction status \n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.transaction import Transaction\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Transaction.status(transaction_id='1234567890X1a2b3')\n print(result)\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\n\nRefunding (part of) a transaction\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.transaction import Transaction\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Transaction.refund(transaction_id='1234567890X1a2b3')\n # Whenever you want to partially refund use e.g. (note: amounts are in cents)\n # result = Refund.transaction(transaction_id='1234567890X1a2b3', amount=500, description='partial refund')\n # PLEASE NOTE the refund_id is NOT guaranteed, it will only be returned when the refund is done through IBAN.\n # This is a known flaw, so please do not rely on the refund ID to be part of the response by default\n print('Refund ID: {refund_id}'.format(refund_id=result.refund_id))\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nRefunding (part of) a transaction (alternative method: more request options are available in this API).\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.refund import Refund\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Refund.transaction(transaction_id='1234567890X1a2b3')\n # Whenever you want to partially refund use e.g. (note: amounts are in cents)\n # result = Refund.transaction(transaction_id='1234567890X1a2b3', amount=500, description='partial refund')\n # PLEASE NOTE the refund_id is NOT guaranteed, it will only be returned when the refund is done through IBAN.\n # This is a known flaw, so please do not rely on the refund ID to be part of the response by default\n print('Refund ID: {refund_id}'.format(refund_id=result.refund_id))\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nRetrieving refund info\nNote: refund ids come in the form of 'RF-xxxx-xxxx'\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.refund import Refund\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n result = Refund.info(refund_id='RF-1234-1234')\n print(result)\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n```\n\nStarting a transaction\n```python\n# Import needed modules\nfrom paynlsdk.api.client import APIAuthentication\nfrom paynlsdk.client.transaction import Transaction\nfrom paynlsdk.objects import OrderData, Address, Company, datetime, TransactionEndUser,\\\n TransactionStartStatsData, TransactionData, SalesData\nfrom paynlsdk.exceptions import *\n# Set mandatory basics\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n# Perform request\ntry:\n saledata = SalesData()\n saledata.invoice_date = datetime(2018,10,30)\n saledata.delivery_date = datetime(2018,11,1)\n order_data = OrderData(product_id='XYZ', product_type='ARTICLE', description='XYZ description',\n price=900, quantity=1, vat_code='H', vat_percentage=21)\n saledata.order_data.append(order_data)\n\n enduser = TransactionEndUser(language='nl', initials='A', last_name='Jansen', gender='m', dob=datetime(1970,1,2),\n phone_number='0612345678', email_address='someone@somewhere.com', iban='',\n address=Address(initials='A', last_name='Jansen', gender='m', \n street_name='Street', street_number='1', street_number_extension='A', \n zip_code='1234AB', city='Rotterdam', region_code='ZH', \n country_code='NL', country_name='Nederland'),\n invoice_address=Address(initials='A', last_name='Jansen', gender='m', \n street_name='Street', street_number='1', street_number_extension='A', \n zip_code='1234AB', city='Rotterdam', region_code='ZH', \n country_code='NL', country_name='Nederland'),\n company=Company(name='Wizard Inc', coc_number='12345678',\n vat_number='NL123456789B01', country_code='NL')\n )\n\n sinfo1 = {'amount': 250, 'ip_address': '192.168.0.1', 'finish_url': 'https://somedomain.com', 'payment_option_id': 436,\n 'transaction': TransactionData(description='order 9999 at Wizard Inc', order_number='9999', \n order_exchange_url='https://somedomain.nl/exchange.php'),\n 'stats_data': TransactionStartStatsData(extra1='IDX 9999'),\n 'end_user': enduser,\n 'sale_data': saledata,\n 'test_mode': True\n }\n\n result = Transaction.start(**sinfo1)\n # print(result)\n print('Transaction ID: {id}\\nPayment reference: {ref}\\nPayment URL: {url}'.format(\n id=result.transaction.transaction_id, ref=result.get_payment_reference(), url=result.get_redirect_url()))\nexcept SchemaException as se:\n print('SCHEMA ERROR:\\n\\t' + str(se))\n print('\\nSCHEMA ERRORS:\\n\\t' + str(se.errors))\nexcept ErrorException as ee:\n print('API ERROR:\\n' + str(ee))\nexcept Exception as e:\n print('GENERIC EXCEPTION:\\n' + str(e))\n\n```\n\n### Error handling\nYou should always wrap your calls in an exception handler.\nThe SDK only contains four internal exceptions:\n- paynlsdk.exceptions.ErrorException\n\n If, for any reason, an error arises in the communication or internally in the API, this exception will be thrown\n- paynlsdk.exceptions.SchemaException\n\n If, for any reason, the schema mapping (using marshmallow), shall fail , this exception is thrown\n\n- paynlsdk.exceptions.TransactionNotAuthorizedException\n\n This exception is only thrown whenever you try to _void_ or _capture_ a transaction using the Response instance as a\n result of a call to Transaction.info()\n\n- paynlsdk.exceptions.TransactionStatusException\n\n This exception is only thrown whenever you try to _approve_ or _decline_ a transaction using the Response instance as a\n result of a call to Transaction.info()\n\nNote: it can always happen that any other standard exceptions are thrown.\nThese are most likely to happen outside of the SDK but should also be handled.\n\n### Advanced usage\nWhenever you want to make use of the Request and Response objects yourself for any purpose, you always have the option\nof creating the request object for any API call. These can be found in any of the paynlsdk.api.xxx.yyy modules.\nThis gives you the advantage of being able to get to the raw requests parameters as well as the raw responses as \nreturned by Pay.nl.\nAlthough you shouldn't normally need to, below is a complete example of this\n```\nfrom paynlsdk.api.transaction.info import Request\nfrom paynlsdk.api.client import APIAuthentication, APIClient\n\nAPIAuthentication.service_id = 'SL-xxxx-xxxx'\nAPIAuthentication.api_token = ''\nAPIAuthentication.token_code = 'AT-xxxx-xxxx'\n\n# Create request.\nrequest = Request(transaction_id='1234567890X1a2b3')\n# Send request.\nresponse = APIClient.perform_request(request)\n# We now basically have all information\n# Display raw request parameters:\nparameters = request.get_parameters()\nprint('Request parameters:\\n')\nprint(format(json.dumps(parameters)))\n# Display raw response:\nprint('Raw response:\\n')\nprint(request.raw_response)\nprint('Response class: ' + type(request.response))\n\n\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/paynl/python-sdk", "keywords": "PAYNL,SDK,Python", "license": "", "maintainer": "", "maintainer_email": "", "name": "paynlsdk", "package_url": "https://pypi.org/project/paynlsdk/", "platform": "", "project_url": "https://pypi.org/project/paynlsdk/", "project_urls": { "Bug Reports": "https://github.com/paynl/python-sdk/issues", "Homepage": "https://github.com/paynl/python-sdk", "Source": "https://github.com/paynl/python-sdk/" }, "release_url": "https://pypi.org/project/paynlsdk/1.0.1/", "requires_dist": [ "marshmallow (<3,>=2)", "requests" ], "requires_python": "", "summary": "PayNL SDK", "version": "1.0.1" }, "last_serial": 5948462, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "f3251a83290fe3d937ba872d1d7d8903", "sha256": "ba5147dd4b683064d3f8b18fc45fd2248f16e4ef54d17762941361b00808f64d" }, "downloads": -1, "filename": "paynlsdk-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "f3251a83290fe3d937ba872d1d7d8903", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 30764, "upload_time": "2018-11-01T14:27:33", "url": "https://files.pythonhosted.org/packages/f2/be/8167d08a3f2eb8b9097ab62ee9076b07133d77e804d996adf9035457a36f/paynlsdk-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e56a33750b5116fee54452f694d13386", "sha256": "757aac5f205d5c69dc0ce6ef806c23649c6f945d14f08da82ba7731f5db257cb" }, "downloads": -1, "filename": "paynlsdk-0.0.2.tar.gz", "has_sig": false, "md5_digest": "e56a33750b5116fee54452f694d13386", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 21334, "upload_time": "2018-11-01T14:27:34", "url": "https://files.pythonhosted.org/packages/4c/61/8502f398558096f5a5b48b3df057901cecb59c7ffbe782b68ab6a2aed1bc/paynlsdk-0.0.2.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "a92a684ef4c921a2f8c51eb318962b3b", "sha256": "35e188951ef8b8355f0a249b57df34034ea51bde833f94ca9e33216db27ca780" }, "downloads": -1, "filename": "paynlsdk-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a92a684ef4c921a2f8c51eb318962b3b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 49800, "upload_time": "2018-11-09T14:53:08", "url": "https://files.pythonhosted.org/packages/cc/95/e0df14d7172d7d83ca66e6655ec5383a06817871b6404053d442984bdfe1/paynlsdk-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d2e229e74e43070e108664ce11752bc1", "sha256": "23854f37a10c29b5f994139423795a5dc4dfb18376677628d07bfe4348b0430d" }, "downloads": -1, "filename": "paynlsdk-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d2e229e74e43070e108664ce11752bc1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35615, "upload_time": "2018-11-09T14:53:10", "url": "https://files.pythonhosted.org/packages/4d/3e/8772fcaf173f944c38894da066f196f8fcbd308bfaba2c66ce6e5d5268fa/paynlsdk-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "8c3205ed69af37f8b2f3ff865f7a2289", "sha256": "5f893cbf26361f63dcfe631ad18528554208af3ad98cefd10000d7105850510e" }, "downloads": -1, "filename": "paynlsdk-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8c3205ed69af37f8b2f3ff865f7a2289", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 49875, "upload_time": "2019-10-09T08:25:15", "url": "https://files.pythonhosted.org/packages/2b/c1/ab08d2e56ad8d05f36aa794fcc471baba310e4931b6982f9ac594cad768c/paynlsdk-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9951aff3c60039f9527d67eaa79c3854", "sha256": "940794602b81cf0c11f8f7ad8d40a6bf24001be6f133037254b41eb3bdd11677" }, "downloads": -1, "filename": "paynlsdk-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9951aff3c60039f9527d67eaa79c3854", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35749, "upload_time": "2019-10-09T08:25:16", "url": "https://files.pythonhosted.org/packages/68/49/4ede1dbdc491c8d896321c7143a4c02d90a9e0bf31937f7cf2c8902ff089/paynlsdk-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8c3205ed69af37f8b2f3ff865f7a2289", "sha256": "5f893cbf26361f63dcfe631ad18528554208af3ad98cefd10000d7105850510e" }, "downloads": -1, "filename": "paynlsdk-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "8c3205ed69af37f8b2f3ff865f7a2289", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 49875, "upload_time": "2019-10-09T08:25:15", "url": "https://files.pythonhosted.org/packages/2b/c1/ab08d2e56ad8d05f36aa794fcc471baba310e4931b6982f9ac594cad768c/paynlsdk-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9951aff3c60039f9527d67eaa79c3854", "sha256": "940794602b81cf0c11f8f7ad8d40a6bf24001be6f133037254b41eb3bdd11677" }, "downloads": -1, "filename": "paynlsdk-1.0.1.tar.gz", "has_sig": false, "md5_digest": "9951aff3c60039f9527d67eaa79c3854", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 35749, "upload_time": "2019-10-09T08:25:16", "url": "https://files.pythonhosted.org/packages/68/49/4ede1dbdc491c8d896321c7143a4c02d90a9e0bf31937f7cf2c8902ff089/paynlsdk-1.0.1.tar.gz" } ] }