{"id":22056017,"url":"https://github.com/intelligenia/django-virtual-pos","last_synced_at":"2025-11-04T03:30:33.464Z","repository":{"id":54678741,"uuid":"76122028","full_name":"intelligenia/django-virtual-pos","owner":"intelligenia","description":"Django module that abstracts the flow of several virtual points of sale including PayPal","archived":false,"fork":false,"pushed_at":"2024-08-13T10:12:50.000Z","size":152,"stargazers_count":23,"open_issues_count":4,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-02-08T04:04:32.065Z","etag":null,"topics":["bank","ceca","django","payment","payment-methods","paypal","redsys","sales","tpv"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/intelligenia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-10T15:48:57.000Z","updated_at":"2024-07-23T13:33:57.000Z","dependencies_parsed_at":"2025-01-16T12:15:46.816Z","dependency_job_id":"97756f48-7ffb-45bb-a823-5c189d3d81e9","html_url":"https://github.com/intelligenia/django-virtual-pos","commit_stats":{"total_commits":85,"total_committers":7,"mean_commits":"12.142857142857142","dds":0.611764705882353,"last_synced_commit":"583abd4ed988738bcf6bd6a024478048160fe3d4"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intelligenia%2Fdjango-virtual-pos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intelligenia%2Fdjango-virtual-pos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intelligenia%2Fdjango-virtual-pos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intelligenia%2Fdjango-virtual-pos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intelligenia","download_url":"https://codeload.github.com/intelligenia/django-virtual-pos/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239425416,"owners_count":19636346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bank","ceca","django","payment","payment-methods","paypal","redsys","sales","tpv"],"created_at":"2024-11-30T16:12:17.543Z","updated_at":"2025-11-04T03:30:33.211Z","avatar_url":"https://github.com/intelligenia.png","language":"Python","funding_links":["https://www.paypal.com/"],"categories":["Pasarelas de Pago"],"sub_categories":["Wallapop"],"readme":"# django-virtual-pos\nDjango module that abstracts the flow of several virtual points of sale including PayPal\n\n\n# What's this?\n\nThis module abstracts the use of the most used virtual points of sale in Spain.\n\n# License\n\n[MIT LICENSE](LICENSE).\n\n# Implemented payment methods\n\n### Paypal\n[Paypal](https://www.paypal.com/) paypal payment available.\n\n### Bitpay\n[Bitpay](http://bitpay.com) bitcoin payments, from wallet to checkout\n\n## Spanish Virtual Points of Sale\n\n\n### Ceca\n[CECA](http://www.cajasdeahorros.es/) is the Spanish confederation of savings banks.\n\n### RedSyS\n[RedSyS](http://www.redsys.es/) gives payment services to several Spanish banks like CaixaBank or Caja Rural.\n\n### Santander Elavon\n[Santander Elavon](https://www.santanderelavon.com/) is one of the payment methods of the Spanish bank Santander. \n\n\n# Requirements and Installation\n\n## Requirements\n\n- Python 2.7 (Python 3 not tested, contributors wanted!)\n- [Django](https://pypi.python.org/pypi/django)\n- [BeautifulSoup4](https://pypi.python.org/pypi/beautifulsoup4)\n- [lxml](https://pypi.python.org/pypi/lxml)\n- [pycrypto](https://pypi.python.org/pypi/pycrypto)\n- [Pytz](https://pypi.python.org/pypi/pytz)\n- [Requests](https://pypi.python.org/pypi/requests)\n\n\nType:\n````sh\n$ pip install django beautifulsoup4 lxml pycrypto pytz\n````\n\n## Installation\n\n\n### From PyPi\n\n````sh\n$ pip install django-virtual-pos\n````\n\n### From master branch\n\nMaster branch will allways contain a working version of this module. \n\n````sh\n$ pip install git+git://github.com/intelligenia/django-virtual-pos.git\n````\n\n\n### settings.py\n\nAdd the application djangovirtualpos to your settings.py:\n\n````python\nINSTALLED_APPS = (\n\t# ...\n\t\"djangovirtualpos\",\n)\n````\n\n# Use\n\nSee this [manual](manual/COMMON.md) (currently only in Spanish).\n\n## Needed models\n\nYou will need to implement this skeleton view using your own **Payment** model.\n\nThis model has must have at least the following attributes:\n - **code**: sale code given by our system.\n - **operation_number**: bank operation number.\n - **status**: status of the payment: \"paid\", \"pending\" (**pending** is mandatory) or \"canceled\".\n - **amount**: amount to be charged.\n\nAnd the following methods:\n - **online_confirm**: mark the payment as paid.\n\n## Integration examples\n- [djshop](https://github.com/diegojromerolopez/djshop)\n\n\n## Needed views\n### Sale summary view\n\n````python\ndef payment_summary(request, payment_id):\n\t\"\"\"\n\tLoad a Payment object and show a summary of its contents to the user.\n\t\"\"\"\n\n\tpayment = get_object_or_404(Payment, id=payment_id, status=\"pending\")\n\treplacements = {\n\t\t\"payment\": payment,\n\t\t# ...\n\t}\n\treturn render(request, '\u003csale summary template path\u003e', replacements)\n\n````\n\nNote that this payment summary view should load a JS file called **set_payment_attributes.js**.\n\nThis file is needed to set initial payment attributes according to which bank have the user selected.\n\n\n### Payment_confirm view\n\n````python\n@csrf_exempt\ndef payment_confirmation(request, virtualpos_type):\n\t\"\"\"\n\tThis view will be called by the bank.\n\t\"\"\"\n\t# Directly call to confirm_payment view\n\n\t# Or implement the following actions\n\n\t# Checking if the Point of Sale exists\n\tvirtual_pos = VirtualPointOfSale.receiveConfirmation(request, virtualpos_type=virtualpos_type)\n\n\tif not virtual_pos:\n\t\t# The VPOS does not exist, inform the bank with a cancel\n\t\t# response if needed\n\t\treturn VirtualPointOfSale.staticResponseNok(virtualpos_type)\n\n\t# Verify if bank confirmation is indeed from the bank\n\tverified = virtual_pos.verifyConfirmation()\n\toperation_number = virtual_pos.operation.operation_number\n\n\twith transaction.atomic():\n\t\ttry:\n\t\t\t# Getting your payment object from operation number\n\t\t\tpayment = Payment.objects.get(operation_number=operation_number, status=\"pending\")\n\t\texcept Payment.DoesNotExist:\n\t\t\treturn virtual_pos.responseNok(\"not_exists\")\n\n\t\tif verified:\n\t\t\t# Charge the money and answer the bank confirmation\n\t\t\ttry:\n\t\t\t\tresponse = virtual_pos.charge()\n\t\t\t\t# Implement the online_confirm method in your payment\n\t\t\t\t# this method will mark this payment as paid and will\n\t\t\t\t# store the payment date and time.\n\t\t\t\tpayment.online_confirm()\n\t\t\texcept VPOSCantCharge as e:\n\t\t\t\treturn virtual_pos.responseNok(extended_status=e)\n\t\t\texcept Exception as e:\n\t\t\t\treturn virtual_pos.responseNok(\"cant_charge\")\n\n\t\telse:\n\t\t\t# Payment could not be verified\n\t\t\t# signature is not right\n\t\t\tresponse = virtual_pos.responseNok(\"verification_error\")\n\n\t\treturn response\n````\n\n### Payment ok view\n\n````python\ndef payment_ok(request, sale_code):\n\t\"\"\"\n\tInforms the user that the payment has been made successfully\n\t:param payment_code: Payment code.\n\t:param request: request.\n\t\"\"\"\n\n\t# Load your Payment model given its code\n\tpayment =  get_object_or_404(Payment, code=sale_code, status=\"paid\")\n\n\tcontext = {'pay_status': \"Done\", \"request\": request}\n\treturn render(request, '\u003cpayment_ok template\u003e', {'context': context, 'payment': payment})\n````\n\n### Payment cancel view\n\n````python\ndef payment_cancel(request, sale_code):\n\t\"\"\"\n\tInforms the user that the payment has been canceled\n\t:param payment_code: Payment code.\n\t:param request: request.\n\t\"\"\"\n\n\t# Load your Payment model given its code\n\tpayment =  get_object_or_404(Payment, code=sale_code, status=\"pending\")\n\t# Mark this payment as canceled\n\tpayment.cancel()\n\n\tcontext = {'pay_status': \"Done\", \"request\": request}\n\treturn render(request, '\u003cpayment_canceled template\u003e', {'context': context, 'payment': payment})\n````\n\n### Refund view\n\n````python\ndef refund(request, tpv, payment_code, amount, description):\n\t\"\"\"\n\t:param request:\n\t:param tpv: TPV Id\n\t:param payment_code: Payment code\n\t:param amount: Refund Amount (Example 10.89).\n\t:param description: Description of refund cause.\n\t:return:\n\t\"\"\"\n\t\n\tamount = Decimal(amount)\n\t\n\ttry:\n\t\t# Checking if the Point of Sale exists\n\t\ttpv = VirtualPointOfSale.get(id=tpv)\n\t\t# Checking if the Payment exists\n\t\tpayment = Payment.objects.get(code=payment_code, state=\"paid\")\n\t\t\n\texcept Payment.DoesNotExist as e:\n\t\treturn http_bad_request_response_json_error(message=u\"Does not exist payment with code {0}\".format(payment_code))\n\t\n\trefund_status = tpv.refund(payment_code, amount, description)\n\t\n\tif refund_status:\n\t\tmessage = u\"Refund successful\"\n\telse:\n\t\tmessage = u\"Refund with erros\"\n\n\treturn http_response_json_ok(message)\n````\n\n\n# Authors\n- Mario Barchéin marioREMOVETHIS@REMOVETHISintelligenia.com\n- Diego J. Romero diegoREMOVETHIS@REMOVETHISintelligenia.com\n\nRemove REMOVETHIS to contact the authors.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintelligenia%2Fdjango-virtual-pos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintelligenia%2Fdjango-virtual-pos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintelligenia%2Fdjango-virtual-pos/lists"}