{ "info": { "author": "Sam Tregar", "author_email": "sam@wawd.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Office/Business :: Financial", "Topic :: Software Development :: Libraries" ], "description": "onlinepayment - a generic Python API for making online payments\n===============================================================\n\nThis module provides an API wrapper around a variety of payment\nproviders. Using this module you can write code that will work the\nsame regardless of the payment provider in use.\n\nExamples::\n\n from onlinepayment import OnlinePayment\n \n # connect to authorize.net, setup auth with login and key\n auth= { 'login': 'YOUR LOGIN HERE',\n 'key': 'YOUR KEY HERE' }\n \n op = OnlinePayment('authnet', test_mode=True, auth=auth)\n \n # or for paypal, setup auth with user, pass, vendor and product:\n auth= { 'username': 'YOUR USERNAME HERE',\n 'password': 'YOUR PASSWORD HERE',\n 'vendor': 'YOUR VENDOR HERE',\n 'product': 'YOUR PRODUCT HERE' } \n \n # connect to PayPal\n op = OnlinePayment('paypal', test_mode=True, auth=auth)\n \n # charge a card\n try:\n result = op.sale(first_name = 'Joe',\n last_name = 'Example',\n address = '100 Example Ln.',\n city = 'Exampleville',\n state = 'NY',\n zip = '10001',\n amount = '2.00',\n card_num = '4007000000027',\n exp_date = '0530',\n card_code = '1234')\n \n except conn.TransactionDeclined:\n # do something when the transaction fails\n \n except conn.CardExpired:\n # tell the user their card is expired\n \n except conn.ProcessorException:\n # handle all other possible processor-generated exceptions generically\n \n # examine result, the values returned here are processor-specific\n success = result.success\n code = result.code\n message = result.message\n trans_id = result.trans_id\n \n # you can get the raw data returned by the underlying processor too\n orig = result.orig\n\nInstallation\n============\n\nBefore you can use this module you must install one or more payment\nprocessors. To install the PayPal payflowpro package::\n\n # easy_install pytz\n # easy_install python-payflowpro\n\nTo install the zc.authorizedotnet package and the authorize package\n(for recurring support)::\n\n # easy_install zc.authorizedotnet\n # easy_install authorize\n\nIf you want authorize.net support you'll need to install a patched\nversion of zc.ssl. Hopefully someday this will be released by the\nZope devs, but so far I haven't heard anything back. Download the\nzc.ssl source package from here::\n\n # http://pypi.python.org/pypi/zc.ssl/\n # tar zxvf zc.ssl-1.1.tar.gz\n # cd zc.ssl-1.1\n\nNow download and apply my zc-ssl-timeout.patch::\n\n # wget http://python-onlinepayment.googlecode.com/svn/trunk/zc-ssl-timeout.patch\n # patch -p1 < /zc-ssl-timeout.patch\n\nAnd install the patched module::\n\n # python setup.py install\n\n(You may also need to edit setup.py and remove the\n'ssl-for-setuptools' dependecy. I did, although it may be a quirk of\nmy Python install rather than a general problem.)\n\nOnce you have a payment processor you can install this module:\n\n # easy_install onlinepayment\n\nConnection Parameters\n=====================\n\nWhen creating a new connection the following named parameters are available::\n\n auth - required parameter containing connection-specific login info.\n\n debug - causes the connection classes to emit debugging info via\n logging calls.\n\n test_mode - sets the connection to test-mode. The actual meaning is\n processor-specific but in all cases it should mean that\n no charges will actually happen.\n\nTransaction Methods\n===================\n\nThe following methods are available to initiate transactions:\n\nsale([params]) \n--------------\n\nProcess a charge on a card immediately.\n\nauthorize([params])\n-------------------\n\nRequests authorization for a charge but does not process\nit. The result object will contain the trans_id needed to complete\nthe charge with capture.\n\ncapture(trans_id=XXXX, [params])\n--------------------------------\n\nProcesses a previously authorized transaction.\n\nvoid(trans_id=XXXX, [params])\n-----------------------------\n\nVoids a previous transaction. In most cases this must be a recent\ntransaction which has not yet actually resulted in funds transfered.\n\ncredit(trans_id=XXXX, amount=XXXX, [params])\n--------------------------------------------\n\nCredits a previously charged amount of money back to the payer.\n\nsubscription_create(period=XXX, length=XXX, start=XXX, [params])\n----------------------------------------------------------------\n\nCreates a subscription that will charge the provided card on an ongoing basis.\n\n\nsubscription_update(subscription_id=XXX, [params])\n---------------------------------------------------\n\nUpdates the settings for an existing subscription.\n\nsubscription_cancel(subscription_id=XXX)\n-----------------------------------------\n\nCancels a subscription.\n\nTransaction Parameters\n======================\n\nAll transaction methods accept the same parameters, although not all\nparameters may be applicable to every transaction type. The actual\nrules vary according to the processor, unfortunately. The list of\nparameters accepted is::\n\n address\n amount\n card_code\n card_num\n city\n company\n country\n description\n email\n exp_date\n extra\n first_name\n invoice_num\n last_name\n phone\n ship_to_address\n ship_to_company\n ship_to_country\n ship_to_city\n ship_to_first_name\n ship_to_last_name\n ship_to_state\n ship_to_zip\n state\n tax\n trans_id\n zip\n\nIn cases where these names do not match the names expected by the\nprocessor a mapping is employed. If you need to pass parameters that\nhave no equivalent above, you can pass them via the 'extra' parameter,\nwhich accepts a dictionary of key-value pairs. For example, to pass\nin the special 'duplicate_window' parameter to authorize.net::\n\n op.sale(..., extra={'duplicate_window':0})\n\nYou can also set extra parameters when you create your OnlinePayment\nobject and they will be applied to all transaction methods called::\n\n op = OnlinePayment('authnet', auth=..., extra={'duplicate_window':0})\n\nResults\n=======\n\nSuccessful transactions return an OnlinePaymentResults object. This\nobject has the following attributes::\n\n success - true if the transaction succeeded\n\n code - the result code returned by the processor.\n\n message - the message returned by the processor.\n\n trans_id - the transaction ID returned by the processor (aka pnref\n for payflowpro). This is the value you need to keep to be able to\n call capture(), void() or credit() later.\n\n orig - the raw data returned by the underlying connection library.\n You might need this for debugging purposes.\n\nUnsuccessful transactions result in...\n\nExceptions\n==========\n\nWhen a transaction fails an exception will be raised. The exception\nclasses are all attributes of the connection object, so you don't need\nto import anything to reference them.\n\nAll exceptions raised during transaction processing are sub-classes of\nProcessorException, so if you want to just catch all possible errors\nand handle them the same you can write::\n\n # authorize a charge\n try:\n result = op.authorize(amount='2.00',\n cc_num='4007000000027',\n cc_exp='0530')\n except op.ProcessorException:\n print(\"It didn't work and I don't care why. Cry some more!\")\n\nThe exception object contains information about why it failed, aside\nfrom its type. The attributes available are::\n\n code - the result code returned by the processor.\n\n msg - the message returned by the processor.\n\n result - the OnlinePaymentResult object which would have been\n returned if the request had succeed\n\nYou might use them to log the processor's code and message::\n\n # authorize a charge\n try:\n result = conn.authorize(amount='2.00',\n cc_num='4007000000027',\n cc_exp='0530')\n except conn.ProcessorException as e:\n log.warning(\"Processor returned code %d, message %s\" % (e.code, e.msg))\n\nIn addition a method is available called description() which contains\nsomething reasonable to display to an end user. For example::\n\n except op.ProcessorException, e:\n print(\"Sorry, that didn't work. %s\" % e.description())\n\nIn the case of a CardExpired exception that would print::\n\n Sorry, that didn't work. The credit card you entered is expired.\n\nYou can also catch and handle specific error conditions. The\navailable classes are::\n\n AVSFailure \n AcceptedForReview \n AmountInvalid \n AmountTooHigh \n AuthError \n CCVInvalid \n CardExpirationInvalid\n CardExpired \n CardNumberInvalid \n DuplicateTransaction \n FraudCheckFailed \n InvalidCardType \n TransactionDeclined \n TryAgainLater \n\nOf course this isn't a complete list of all the errors any processor\ncould return. I've taken the approach that it's most useful to\nidentify the errors that a user might reasonable be able to fix. The\nrest just end up as generic ProcessorException errors and you can\nexamine their code and message if you wish to differentiate.\n\nAuthorize.net\n=============\n\nThe authorize.net connection class uses the zc.authorizedotnet\nlibrary. You can learn more about it here:\n\n http://pypi.python.org/pypi/zc.authorizedotnet/1.3\n\nSince this module started with auth.net you'll find that the parameter\nnames are mostly the same.\n\nThis module performs the following mapping to express parameters in\nAuthorize.net language::\n\n 'term' : 'length',\n 'payperiod' : 'unit',\n\nAuth parameters should look like::\n\n auth= { 'login': 'YOUR LOGIN HERE',\n 'key': 'YOUR KEY HERE' }\n\nPayPal - aka PayFlowPro\n=======================\n\nThe paypal connection class uses the payflowpro library. The project is here:\n\n http://code.google.com/p/python-payflowpro/\n\nThis module performs the following mapping to express parameters in\npayflowpro language::\n\n 'card_num' : 'acct',\n 'card_code' : 'cvv2',\n 'exp_date' : 'expdate',\n 'amount' : 'amt',\n 'address' : 'street',\n 'company' : 'companyname',\n 'description' : 'comment1',\n 'ship_to_address' : 'shiptostreet',\n 'ship_to_first_name' : 'shiptofirstname',\n 'ship_to_last_name' : 'shiptolastname',\n 'ship_to_country' : 'shiptocountry',\n 'ship_to_city' : 'shiptocity',\n 'ship_to_state' : 'shiptostate',\n 'ship_to_zip' : 'shiptozip',\n 'first_name' : 'firstname',\n 'last_name' : 'lastname',\n 'phone' : 'phonenum',\n 'invoice_num' : 'ponum',\n\nIf you need to set any parameters not in this set just use the 'extra'\nparameter described above.\n\nNote that the payflowpro API only uses trans_id for credit(), void()\nand capture(). You can pass other values but they are ignored.\n\nAuth parameter setup should look like::\n\n auth= { 'username': 'YOUR USERNAME HERE',\n 'password': 'YOUR PASSWORD HERE',\n 'vendor': 'YOUR VENDOR HERE',\n 'product': 'YOUR PRODUCT HERE' } \n\nCredits\n=======\n\n- Sam Tregar - framework, one-time processing\n\n- Aaron Ross - recurring billing\n\n- We Also Walk Dogs - maintainance, bug fixes, morale boost\n\n- Jason Kohles - created Business::OnlinePayment, the model for this module\n\nCopyright and License\n=====================\n\nCopyright (c) 2009, 2010, We Also Walk Dogs\nAll rights reserved.\n\nOnlinepayment is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or (at\nyour option) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\nGeneral Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see .", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.google.com/p/python-onlinepayment/", "keywords": "credit card authorize.net CC AIM paypal payflow payment", "license": "GPL 3", "maintainer": null, "maintainer_email": null, "name": "onlinepayment", "package_url": "https://pypi.org/project/onlinepayment/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/onlinepayment/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://code.google.com/p/python-onlinepayment/" }, "release_url": "https://pypi.org/project/onlinepayment/1.0.0/", "requires_dist": null, "requires_python": null, "summary": "a generic Python API for making online payments", "version": "1.0.0" }, "last_serial": 795719, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "fee89e5948c846e1ae442baf8d820d4a", "sha256": "48086016bb6538fb9c201867eac7c1e2af837dc9eb86f87c71d4be5cf967d470" }, "downloads": -1, "filename": "onlinepayment-1.0.0.tar.gz", "has_sig": false, "md5_digest": "fee89e5948c846e1ae442baf8d820d4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31037, "upload_time": "2010-03-21T23:55:57", "url": "https://files.pythonhosted.org/packages/32/25/8b0731207959d5c3c7f79948e0a025502216d511e82c9f71eb5580d69217/onlinepayment-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fee89e5948c846e1ae442baf8d820d4a", "sha256": "48086016bb6538fb9c201867eac7c1e2af837dc9eb86f87c71d4be5cf967d470" }, "downloads": -1, "filename": "onlinepayment-1.0.0.tar.gz", "has_sig": false, "md5_digest": "fee89e5948c846e1ae442baf8d820d4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31037, "upload_time": "2010-03-21T23:55:57", "url": "https://files.pythonhosted.org/packages/32/25/8b0731207959d5c3c7f79948e0a025502216d511e82c9f71eb5580d69217/onlinepayment-1.0.0.tar.gz" } ] }