{ "info": { "author": "Miguel Ferrer", "author_email": "ingferrermiguel@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# payu-python\n\npayu-python is an API wrapper for Payu written in Python. Currently only works for supported credit cards in the supported countries in Latam.\n\nSupported countries:\n* Argentina\n* Brazil\n* Chile\n* Colombia\n* Mexico\n* Panama\n* Peru\n* Chile\n\nRead [Utils](https://github.com/GearPlug/payu-python#utils) section to find out how to get the supported credit cards for a country.\n\nRead [TODO](https://github.com/GearPlug/payu-python#todo) section to find out what's missing in this library.\n\n\n## Installing\n```\npip install payu-python\n```\n\n## Django implementation\n\nIf you are going to use this with your Django application, we recommend you to use our django implementation:\n\n[django-payu-latam](https://github.com/GearPlug/django-payu-latam)\n\n## Usage\n\n### Client instantiation in sandbox mode (test)\n```\nTEST_API_LOGIN = 'pRRXKOl8ikMmt9u'\nTEST_API_KEY = '4Vj8eK4rloUd272L48hsrarnUA'\nTEST_MERCHANT_ID = 508029\nTEST_ACCOUNT_ID = 512321\n\nclient = Client(TEST_API_LOGIN, TEST_API_KEY, TEST_MERCHANT_ID, TEST_ACCOUNT_ID, test=True, language='en', debug=True)\n```\n\n### Example data for sandbox mode\n```\nBUYER_EXAMPLE = {\n \"merchantBuyerId\": \"1\",\n \"fullName\": \"First name and second buyer name\",\n \"emailAddress\": \"buyer_test@test.com\",\n \"contactPhone\": \"7563126\",\n \"dniNumber\": \"5415668464654\",\n \"shippingAddress\": {\n \"street1\": \"calle 100\",\n \"street2\": \"5555487\",\n \"city\": \"Medellin\",\n \"state\": \"Antioquia\",\n \"country\": \"CO\",\n \"postalCode\": \"000000\",\n \"phone\": \"7563126\"\n }\n}\n\nPAYER_EXAMPLE = {\n \"merchantPayerId\": \"1\",\n \"fullName\": \"First name and second payer name\",\n \"emailAddress\": \"payer_test@test.com\",\n \"contactPhone\": \"7563126\",\n \"dniNumber\": \"5415668464654\",\n \"billingAddress\": {\n \"street1\": \"calle 93\",\n \"street2\": \"125544\",\n \"city\": \"Bogota\",\n \"state\": \"Bogota DC\",\n \"country\": \"CO\",\n \"postalCode\": \"000000\",\n \"phone\": \"7563126\"\n }\n}\n\nCREDIT_CARD_EXAMPLE = {\n \"number\": \"4097440000000004\",\n \"securityCode\": \"321\",\n \"expirationDate\": \"2022/12\",\n \"name\": \"APPROVED\"\n}\n\nEXTRA_EXAMPLE = {\n \"INSTALLMENTS_NUMBER\": 1\n}\n```\n\n### Payments Module\n\n#### Ping service\n```\nr = client.payments.ping()\n```\n\n#### Get payments method\n```\nr = client.payments.get_payments_methods()\n```\n\n#### Make a payment (AUTHORIZATION AND CAPTURE)\n```\nr = client.payments.make_payment(reference_code='TestPayU01', description='Test Payment', tx_value=1000, tx_tax=0, \n tx_tax_return_base=0, currency='COP', buyer=BUYER_EXAMPLE, payer=PAYER_EXAMPLE, \n credit_card=CREDIT_CARD_EXAMPLE, payment_method='VISA', payment_country='CO', \n device_session_id='vghs6tvkcle931686k1900o6e1', \n ip_address='127.0.0.1', cookie='pt1t38347bs6jc9ruv2ecpv7o2', \n user_agent='Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', \n extra_parameters=EXTRA_EXAMPLE,\n notify_url='https://ed60769e.ngrok.io/payu/notification/')\n```\n\n#### Make authorization (ONLY AUTHORIZATION)\n```\nr = client.payments.make_authorization(reference_code='TestPayU02', description='Test Payment', tx_value=1000, tx_tax=0, \n tx_tax_return_base=0, currency='COP', buyer=BUYER_EXAMPLE, payer=PAYER_EXAMPLE, \n credit_card=CREDIT_CARD_EXAMPLE, payment_method='VISA', payment_country='CO', \n device_session_id='vghs6tvkcle931686k1900o6e1', \n ip_address='127.0.0.1', cookie='pt1t38347bs6jc9ruv2ecpv7o2', \n user_agent='Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0', \n extra_parameters=EXTRA_EXAMPLE,\n notify_url='https://ed60769e.ngrok.io/payu/notification/')\n```\n\n#### Make capture (ONLY CAPTURE)\n```\nr = client.payments.make_capture(order_id='844928300', parent_transaction_id='4d7f240d-084a-426f-aa27-42c3b2a2b265')\n```\n\n#### Refund a payment\n```\nr = client.payments.refund_payment(order_id='844928300', parent_transaction_id='4d7f240d-084a-426f-aa27-42c3b2a2b265',\n reason='Client asked for refund.')\n```\n\n### Tokenization Module\n\n#### Create a single token\n```\nr = client.tokenization.create_single_token(payer_id='1', name='Full name', identification_number='32144457', \n payment_method='VISA', number='4111111111111111', expiration_date='2022/01')\n```\n\n#### Make a payment\n```\nr = client.tokenization.make_payment(reference_code='TestPayU03', description='Test Payment', tx_value=1000, \n currency='COP', buyer=BUYER_EXAMPLE, payer=PAYER_EXAMPLE, payment_method='VISA', \n payment_country='CO', device_session_id='vghs6tvkcle931686k1900o6e1', \n ip_address='127.0.0.1', cookie='pt1t38347bs6jc9ruv2ecpv7o2',\n user_agent='Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0',\n credit_card_token_id='b01877c3-b044-455a-99f5-82aed33795e9')\n```\n\n#### Make authorization (ONLY AUTHORIZATION)\n```\nr = client.tokenization.make_authorization(reference_code='TestPayU03', description='Test Payment', tx_value=1000, \n currency='COP', buyer=BUYER_EXAMPLE, payer=PAYER_EXAMPLE, payment_method='VISA', \n payment_country='CO', device_session_id='vghs6tvkcle931686k1900o6e1', \n ip_address='127.0.0.1', cookie='pt1t38347bs6jc9ruv2ecpv7o2',\n user_agent='Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0',\n credit_card_token_id='b01877c3-b044-455a-99f5-82aed33795e9')\n```\n\n#### Make capture (ONLY CAPTURE)\n```\nr = client.tokenization.make_capture(order_id='844928300', parent_transaction_id='4d7f240d-084a-426f-aa27-42c3b2a2b265')\n```\n\n#### Get tokens for a payer (for the last year)\n```\nimport datetime\n\nr = client.tokenization.get_tokens(payer_id='1', credit_card_token_id='b65c63e9-ec0c-49ac-a67d-1414c3dc3ccc', \n start_date=datetime.datetime.now().replace(year=2017), \n end_date=datetime.datetime.now()))\n```\n\n#### Remove a token\n```\nr = client.tokenization.remove_token(payer_id='1', credit_card_token_id='d70889d2-0f82-482d-a2ed-3c0a2813d57c')\n```\n\n### Recurring Payments Module\n\n#### Create a plan\n```\nr = client.recurring.create_plan(plan_code='PLAN_CODE', description='Test Plan', interval='MONTH', interval_count=1,\n max_payments_allowed=12, payment_attempts_delay=1, plan_value=1000, plan_tax=0,\n plan_tax_return_base=0, currency='COP')\n```\n\n#### Get a plan\n```\nr = client.recurring.get_plan('PLAN_CODE')\n```\n\n#### Remove a plan\n```\nr = client.recurring.delete_plan('PLAN_CODE')\n```\n\n#### Create a customer\n```\nr = client.recurring.create_customer(full_name='Full name', email='customer_test@test.com')\n```\n\n#### Get a customer\n```\nr = client.recurring.get_customer('CUSTOMER_ID')\n```\n\n#### Delete a customer\n```\nr = client.recurring.delete_customer('CUSTOMER_ID')\n```\n\n#### Create a credit card\n```\nr = client.recurring.create_credit_card(customer_id='CUSTOMER_ID', name'Full name', document='32144457', \n number='4111111111111111', exp_month='01', exp_year='2022', type='VISA', \n address='calle 93 125544 Bogota')\n```\n\n#### Get a credit card\n```\nr = client.recurring.get_credit_card('CREDIT_CARD_ID')\n```\n\n#### Delete a credit card\n```\nr = client.recurring.delete_credit_card(customer_id='CUSTOMER_ID', credit_card_id='CREDIT_CARD_ID')\n```\n\n#### Create a subscription\n```\nr = client.recurring.create_subscription(customer_id='CUSTOMER_ID', credit_card_token='CREDIT_CARD_ID', \n plan_code='PLAN_CODE')\n```\n\n#### Get a subscription\n```\nr = client.recurring.get_subscription('SUBSCRIPTION_ID')\n```\n\n#### Update a subscription\n```\nr = client.recurring.update_subscription(subscription_id='SUBSCRIPTION_ID', credit_card_token='CREDIT_CARD_TOKEN')\n```\n\n#### Delete a subscription\n```\nr = client.recurring.delete_subscription('SUBSCRIPTION_ID')\n```\n\n#### Create an additional charge\n```\nr = client.recurring.create_additional_charge(subscription_id='SUBSCRIPTION_ID', description='TEST CHARGE', \n plan_value=1000, plan_tax=0, plan_tax_return_base=0,\n currency='COP')\n```\n\n#### Get an additional charge by identifier\n```\nr = client.recurring.get_additional_charge_by_identifier('RECURRING_BILLING_ID')\n```\n\n#### Get an additional charge by description\n```\nr = client.recurring.get_additional_charge_by_description('DESCRIPTION')\n```\n\n#### Get an additional charge by subscription\n```\nr = client.recurring.get_additional_charge_by_subscription('SUBSCRIPTION_ID')\n```\n\n#### Update an additional charge\n```\nr = client.recurring.update_additional_charge(recurring_billing_id='RECURRING_BILLING_ID', description='TEST CHARGE', \n plan_value=1000, plan_tax=0, plan_tax_return_base=0, currency='COP')\n```\n\n#### Delete an additional charge\n```\nr = client.recurring.delete_additional_charge('RECURRING_BILLING_ID')\n```\n\n#### Get recurring bill by client\n```\nimport datetime\n\nr = client.recurring.get_recurring_bill_by_client(customer_id='CUSTOMER_ID', \n date_begin=datetime.datetime.now().replace(year=2017), \n date_final=datetime.datetime.now())\n```\n\n#### Get recurring bill by subscription\n```\nr = client.recurring.get_recurring_bill_by_subscription('SUBSCRIPTION_ID')\n```\n\n### Queries Module\n\n#### Get order by identifier\n```\nr = client.queries.get_order_by_identifier('ORDER_ID')\n```\n\n#### Get order by reference code\n```\nr = client.queries.get_order_by_reference('REFERENCE_CODE')\n```\n\n#### Get order by transaction\n```\nr = client.queries.get_transaction_response('TRANSACTION_ID')\n```\n\n## Utils\n\n#### Get supported credit cards for payments in a country\n```\nfrom payu.utils import get_available_franchise_for_payment\nfrom payu.enumerators import Country, TransactionType\n\nr = get_available_franchise_for_payment(Country.COLOMBIA, TransactionType.AUTHORIZATION)\nr = get_available_franchise_for_payment(Country.COLOMBIA, TransactionType.AUTHORIZATION_AND_CAPTURE)\n```\n\n#### Get supported credit cards for tokenization in a country\n```\nfrom payu.utils import get_available_franchise_for_tokenization\nfrom payu.enumerators import Country, TransactionType\n\nr = get_available_franchise_for_tokenization(Country.COLOMBIA, TransactionType.AUTHORIZATION)\nr = get_available_franchise_for_tokenization(Country.COLOMBIA, TransactionType.AUTHORIZATION_AND_CAPTURE)\n```\n\n#### Check if tokenized payment needs credit card CVV\n```\nfrom payu.utils import has_franchise_cvv_tokenization\nfrom payu.enumerators import Country, Franchise, TransactionType\n\nr = get_available_franchise_for_tokenization(Franchise.VISA, Country.COLOMBIA, TransactionType.AUTHORIZATION_AND_CAPTURE)\n```\n\n## TODO\n\n### Payments\n* cancel_payment()\n* Support for cash / bank payment methods\n* Support for bank transfer methods\n\n### Tokenization\n* create_multiple_tokens()\n* make_multiple_payments()\n\n### Recurring Payments\n* update_plan()\n* update_customer()\n* update_credit_card()\n\n## Requirements\n* [requests](https://github.com/requests/requests)\n\n## Contributing\nWe are always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.\n\n#### You can report any bug you find or suggest new functionality with a new [issue](https://github.com/GearPlug/payu-python/issues).\n\n#### If you want to add yourself some functionality to the wrapper:\n1. Fork it ( https://github.com/GearPlug/payu-python )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Adds my new feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/GearPlug/payu-python", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "payu-python", "package_url": "https://pypi.org/project/payu-python/", "platform": "", "project_url": "https://pypi.org/project/payu-python/", "project_urls": { "Homepage": "https://github.com/GearPlug/payu-python" }, "release_url": "https://pypi.org/project/payu-python/0.1.5/", "requires_dist": null, "requires_python": "", "summary": "API wrapper for Payu written in Python", "version": "0.1.5" }, "last_serial": 4557271, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "a6793f2b26e54d4e892ee67cb696aa71", "sha256": "2e9abff44e770a3d9ac6d7c4489b7cb242673a418d77586739e9cfa108e3496e" }, "downloads": -1, "filename": "payu-python-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a6793f2b26e54d4e892ee67cb696aa71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14627, "upload_time": "2018-11-13T20:19:42", "url": "https://files.pythonhosted.org/packages/53/a5/7df9a2fd0fdf3f48811f89aaec6842bc13c776db692cc085d46fe85eaab6/payu-python-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "80fa2ecb2621c39f4dd2b4e6ba690c3a", "sha256": "1b8de28cca69a9995e308e38e66af64bb2b31abfac86b89817f9942ca3652b14" }, "downloads": -1, "filename": "payu-python-0.1.1.tar.gz", "has_sig": false, "md5_digest": "80fa2ecb2621c39f4dd2b4e6ba690c3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14875, "upload_time": "2018-11-14T14:09:57", "url": "https://files.pythonhosted.org/packages/91/3d/b61a7b59243d802b45db7afdfc37c3b958503d03822236a2a674eb632141/payu-python-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "db57a30c82fb58716bb00e00c48572af", "sha256": "e9d03a6636f3a16aa9a27081216746943d46ea269351fa76bd5e0348aaa19ae4" }, "downloads": -1, "filename": "payu-python-0.1.2.tar.gz", "has_sig": false, "md5_digest": "db57a30c82fb58716bb00e00c48572af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15036, "upload_time": "2018-11-20T13:42:44", "url": "https://files.pythonhosted.org/packages/9f/0b/068d8bee14431072bf429fb1ea1b8553cdd3f7496dd618817633c1b3fd44/payu-python-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "69e54532c04aa3d19d61579ec0554aae", "sha256": "c13142003650c687f7717ed0160e11f25e54d5a4d4ea17989cefa7579817e999" }, "downloads": -1, "filename": "payu-python-0.1.3.tar.gz", "has_sig": false, "md5_digest": "69e54532c04aa3d19d61579ec0554aae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15625, "upload_time": "2018-11-20T16:25:09", "url": "https://files.pythonhosted.org/packages/a1/97/fe4f3184269cbeb601befb09a94c00e223c6c78411264507f9f3196e2b3e/payu-python-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "632c4481fac5d761af1f737de59a0d90", "sha256": "92f83739f943b8bae6ed2d6b2bc1922801b49fb438172afe7057d229ae56a1f9" }, "downloads": -1, "filename": "payu-python-0.1.4.tar.gz", "has_sig": false, "md5_digest": "632c4481fac5d761af1f737de59a0d90", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15874, "upload_time": "2018-11-20T21:24:45", "url": "https://files.pythonhosted.org/packages/91/37/6411e20081ebc8989c47ede49e02f025ed374c4298cc07208303222d211e/payu-python-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "7465e3d21bdd8647f6df70072e1b2399", "sha256": "2d68c17f55dbafa51d20705de76760c103c8342e1b440938d3f0145d6948e946" }, "downloads": -1, "filename": "payu-python-0.1.5.tar.gz", "has_sig": false, "md5_digest": "7465e3d21bdd8647f6df70072e1b2399", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14540, "upload_time": "2018-11-21T20:19:46", "url": "https://files.pythonhosted.org/packages/06/a6/4f480862d5a29f6458c836a72c79260aedee72bc8b25b2bfedf579a4e420/payu-python-0.1.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7465e3d21bdd8647f6df70072e1b2399", "sha256": "2d68c17f55dbafa51d20705de76760c103c8342e1b440938d3f0145d6948e946" }, "downloads": -1, "filename": "payu-python-0.1.5.tar.gz", "has_sig": false, "md5_digest": "7465e3d21bdd8647f6df70072e1b2399", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14540, "upload_time": "2018-11-21T20:19:46", "url": "https://files.pythonhosted.org/packages/06/a6/4f480862d5a29f6458c836a72c79260aedee72bc8b25b2bfedf579a4e420/payu-python-0.1.5.tar.gz" } ] }