[Python-modules-commits] [python-paypal] 01/04: Imported Upstream version 1.2.5
Raphaël Hertzog
hertzog at moszumanska.debian.org
Tue Jun 28 12:18:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
hertzog pushed a commit to branch master
in repository python-paypal.
commit 2331a2718fa76a1720cbf95a1867c664dba174ee
Author: Sophie Brun <sophie at freexian.com>
Date: Tue Jun 28 09:03:06 2016 +0200
Imported Upstream version 1.2.5
---
AUTHORS | 9 +
LICENSE | 169 +++++++++++
MANIFEST.in | 6 +
PKG-INFO | 23 ++
README.rst | 137 +++++++++
paypal.egg-info/PKG-INFO | 23 ++
paypal.egg-info/SOURCES.txt | 27 ++
paypal.egg-info/dependency_links.txt | 1 +
paypal.egg-info/requires.txt | 1 +
paypal.egg-info/top_level.txt | 1 +
paypal/__init__.py | 11 +
paypal/compat.py | 128 +++++++++
paypal/countries.py | 292 +++++++++++++++++++
paypal/exceptions.py | 47 ++++
paypal/interface.py | 528 +++++++++++++++++++++++++++++++++++
paypal/response.py | 119 ++++++++
paypal/response_list.py | 70 +++++
paypal/settings.py | 145 ++++++++++
setup.cfg | 8 +
setup.py | 50 ++++
tests/README | 15 +
tests/__init__.py | 0
tests/api_details_blank.py | 29 ++
tests/interface_factory.py | 43 +++
tests/test_buttons.py | 31 ++
tests/test_countries.py | 20 ++
tests/test_direct_payment.py | 87 ++++++
tests/test_express_checkout.py | 216 ++++++++++++++
28 files changed, 2236 insertions(+)
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..95e64ab
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,9 @@
+The following people have contributed their valuable time to the paypal-python
+project. If you submit a patch, feel free to add your name to the list.
+
+ Pat Collins <pat at burned.com> - Original author
+ Greg Taylor <gtaylor at duointeractive.com> - Current maintainer
+ Manik Surtani <manik at jboss.org> - Python 2.5 compatibility
+ Christopher Smith <cbsmith at gmail.com> - API updates
+ Piotr Staroszczyk <oczkers> - Various cleanup
+ Max Brauer <mamachanko> - minor improvements
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a412d78
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,169 @@
+Apache License
+Version 2.0, January 2004
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and
+distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright
+owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities
+that control, are controlled by, or are under common control with that entity.
+For the purposes of this definition, "control" means (i) the power, direct or
+indirect, to cause the direction or management of such entity, whether by
+contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
+outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising
+permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including
+but not limited to software source code, documentation source, and
+configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or
+translation of a Source form, including but not limited to compiled object
+code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form,
+made available under the License, as indicated by a copyright notice that is
+included in or attached to the work (an example is provided in the
+Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that
+is based on (or derived from) the Work and for which the editorial revisions,
+annotations, elaborations, or other modifications represent, as a whole, an
+original work of authorship. For the purposes of this License, Derivative Works
+shall not include works that remain separable from, or merely link (or bind by
+name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original
+version of the Work and any modifications or additions to that Work or
+Derivative Works thereof, that is intentionally submitted to Licensor for
+inclusion in the Work by the copyright owner or by an individual or Legal
+Entity authorized to submit on behalf of the copyright owner. For the purposes
+of this definition, "submitted" means any form of electronic, verbal, or
+written communication sent to the Licensor or its representatives, including
+but not limited to communication on electronic mailing lists, source code
+control systems, and issue tracking systems that are managed by, or on behalf
+of, the Licensor for the purpose of discussing and improving the Work, but
+excluding communication that is conspicuously marked or otherwise designated
+in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
+of whom a Contribution has been received by Licensor and subsequently
+incorporated within the Work.
+
+2. Grant of Copyright License.
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable copyright license to reproduce, prepare Derivative Works of,
+publicly display, publicly perform, sublicense, and distribute the Work and
+such Derivative Works in Source or Object form.
+
+3. Grant of Patent License.
+
+Subject to the terms and conditions of this License, each Contributor hereby
+grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+irrevocable (except as stated in this section) patent license to make, have
+made, use, offer to sell, sell, import, and otherwise transfer the Work, where
+such license applies only to those patent claims licensable by such Contributor
+that are necessarily infringed by their Contribution(s) alone or by combination
+of their Contribution(s) with the Work to which such Contribution(s) was
+submitted. If You institute patent litigation against any entity (including a
+cross-claim or counterclaim in a lawsuit) alleging that the Work or a
+Contribution incorporated within the Work constitutes direct or contributory
+patent infringement, then any patent licenses granted to You under this License
+for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution.
+
+You may reproduce and distribute copies of the Work or Derivative Works
+thereof in any medium, with or without modifications, and in Source or Object
+form, provided that You meet the following conditions:
+
+* You must give any other recipients of the Work or Derivative Works a copy of
+ this License; and
+* You must cause any modified files to carry prominent notices stating that You
+ changed the files; and
+* You must retain, in the Source form of any Derivative Works that You
+ distribute, all copyright, patent, trademark, and attribution notices from
+ the Source form of the Work, excluding those notices that do not pertain to
+ any part of the Derivative Works; and
+* If the Work includes a "NOTICE" text file as part of its distribution, then
+ any Derivative Works that You distribute must include a readable copy of the
+ attribution notices contained within such NOTICE file, excluding those notices
+ that do not pertain to any part of the Derivative Works, in at least one of
+ the following places: within a NOTICE text file distributed as part of the
+ Derivative Works; within the Source form or documentation, if provided along
+ with the Derivative Works; or, within a display generated by the Derivative
+ Works, if and wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and do not modify the
+ License. You may add Your own attribution notices within Derivative Works
+ that You distribute, alongside or as an addendum to the NOTICE text from the
+ Work, provided that such additional attribution notices cannot be construed
+ as modifying the License.
+
+You may add Your own copyright statement to Your modifications and may provide
+additional or different license terms and conditions for use, reproduction,
+or distribution of Your modifications, or for any such Derivative Works as a
+whole, provided Your use, reproduction, and distribution of the Work otherwise
+complies with the conditions stated in this License.
+
+5. Submission of Contributions.
+
+Unless You explicitly state otherwise, any Contribution intentionally submitted
+for inclusion in the Work by You to the Licensor shall be under the terms and
+conditions of this License, without any additional terms or conditions.
+Notwithstanding the above, nothing herein shall supersede or modify the terms
+of any separate license agreement you may have executed with Licensor regarding
+such Contributions.
+
+6. Trademarks.
+
+This License does not grant permission to use the trade names, trademarks,
+service marks, or product names of the Licensor, except as required for
+reasonable and customary use in describing the origin of the Work and
+reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty.
+
+Unless required by applicable law or agreed to in writing, Licensor provides
+the Work (and each Contributor provides its Contributions) on an "AS IS"
+BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
+including, without limitation, any warranties or conditions of TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
+solely responsible for determining the appropriateness of using or
+redistributing the Work and assume any risks associated with Your exercise of
+permissions under this License.
+
+8. Limitation of Liability.
+
+In no event and under no legal theory, whether in tort (including negligence),
+contract, or otherwise, unless required by applicable law (such as deliberate
+and grossly negligent acts) or agreed to in writing, shall any Contributor be
+liable to You for damages, including any direct, indirect, special, incidental,
+or consequential damages of any character arising as a result of this License
+or out of the use or inability to use the Work (including but not limited to
+damages for loss of goodwill, work stoppage, computer failure or malfunction,
+or any and all other commercial damages or losses), even if such Contributor
+has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability.
+
+While redistributing the Work or Derivative Works thereof, You may choose to
+offer, and charge a fee for, acceptance of support, warranty, indemnity, or
+other liability obligations and/or rights consistent with this License.
+However, in accepting such obligations, You may act only on Your own behalf and
+on Your sole responsibility, not on behalf of any other Contributor, and only
+if You agree to indemnify, defend, and hold each Contributor harmless for any
+liability incurred by, or claims asserted against, such Contributor by reason
+of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
\ No newline at end of file
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..54b5548
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,6 @@
+include README.rst
+include LICENSE
+include AUTHORS
+recursive-include paypal *.py
+recursive-include tests *.py README
+exclude tests/api_details.py
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..d5891f3
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,23 @@
+Metadata-Version: 1.1
+Name: paypal
+Version: 1.2.5
+Summary: PayPal API implementation in Python.
+Home-page: https://github.com/gtaylor/paypal-python
+Author: Gregory Taylor
+Author-email: gtaylor at gc-taylor.com
+License: Apache Software License
+Download-URL: http://pypi.python.org/pypi/paypal/
+Description: An implementation of PayPal's API in Python.
+ Currently features Direct Payment (Guest), and PayPal Express checkouts.
+
+Keywords: paypal nvp
+Platform: Platform Independent
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..e38e9e4
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,137 @@
+PayPal-Python
+=============
+
+
+:Author: Pat Collins
+:Maintainer: Greg Taylor
+:License: Apache v2
+:Status: Stable
+:Maintained: Quasi-maintained, looking for new maintainer (file issue if interested)
+
+This package implements Paypal's Website Payments Pro NVP API in Python.
+This currently includes Direct Payments (Credit card payments without a PayPal
+Account) and PayPal Express Checkout (Payment via a PayPal account).
+
+This module is best used in conjunction with the
+official PayPal `documentation`_. The stuff under
+"Website Payments Pro and Express Checkout API Operations". in particular.
+
+paypal-python does no real validation, doesn't hold hands, and is generally
+only going to handle authentication, http-level stuff, and serializing
+a list of keyword arguments passed to the API methods. You'll need to
+read the official PayPal documentation for what key/values to pass.
+
+.. _documentation: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_reference
+
+*NOTE: This module is not created by, endorsed by, or in any way affiliated
+with PayPal.*
+
+Requirements
+------------
+
+* Python 2.6 or 2.7
+
+Installation
+------------
+
+Through pip::
+
+ pip install paypal
+
+or easy_install::
+
+ easy_install paypal
+
+or download the source, un-tar/un-zip it, cd into paypal-python, and::
+
+ python setup.py install
+
+Quick Start
+-----------
+
+To run test suite, do from within the paypal-python directory::
+
+ pip install nose
+ nosetests tests/
+
+The meat is in paypal.interface. The docs are in the docstrings and tests.
+
+* Create a paypal.interface.PayPalInterface object
+* Pass it configuration kwargs (See tests.interface_factory.get_interface_obj
+ for a good example of how this works).
+* That interface is how you access PayPal. Take a look at the currently
+ implemented methods in paypal.interface.
+
+Support/Help
+------------
+
+If you have any problems, questions, or ideas, feel free to post on our
+`issue tracker`_.
+
+.. _issue tracker: http://github.com/gtaylor/paypal-python/issues
+
+Addendum A
+----------
+
+Instructions for setting up a Sandbox Website Payments Pro account. More
+detailed instructions can be found at [x.com](http://x.com) but this is what
+worked for me.
+
+1. Create Sandbox account. Don't use your live PayPal account email address.
+2. Login to Sandbox
+3. Test Accounts -> "Preconfigured" -- the manual process sucks.
+4. Make a "Seller" account
+5. Don't change "login email" at all -- it seems to truncate to 6 characters.
+6. I took the numeric password they gave as default and copy/pasted it into a
+ plain text document so I could use it later to make all my test account
+ passwords the same.
+7. I chose Visa as the credit card.
+8. Bank Account = "Yes" -- This is needed for a Verified account, which is
+ needed for Website Payments Pro.
+9. Put $1,000 of fake $$ into the account. At one point I tried $5,000 but
+ the test account I created wasn't Verified automatically? Not sure if the
+ two are related.
+10. No notes.
+11. "Create Account"
+12. When it takes you back to the "Test Accounts" screen, it should say
+ "Business" and "Verified"
+13. When you click on "API Credentials" you should see API credentials for the
+ corresponding test account you just created. I copy/pasted them into the
+ same text file used above.
+
+The next step was the tricky part, at least for me. I was getting `10501`
+errors which means the billing agreement wasn't agreed to. Apparently you need
+to accept the fake billing agreement that comes along with the fake account you
+just created, which semi-conveniently has come packaged with an automatically
+created and verified fake bank account and business account "verified" status.
+Why couldn't the billing agreement be automatically "agreed to" as well?
+
+Back on the "Test Accounts" page, choose the account you just created and click
+"Enter Sandbox Test Site." It should populate the fake email address, which
+should be `userna_XXXXXXXXXX_biz at domain.com`. Use the copy/pasted password from
+step #6 and paste it into the password field and login.
+
+Now go under Merchant Services -> Website Payments Pro. In the right column
+there should be a link to "agree" to the billing agreement. Click this link and
+agree to the agreement. Now your API calls will work as expected.
+
+LICENSE
+-------
+
+::
+
+ Copyright 2009 Pat Collins <pat at burned.com>
+ Copyright 2012 DUO Interactive, LLC <gtaylor at duointeractive.com>
+ Copyright 2014 Greg Taylor
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/paypal.egg-info/PKG-INFO b/paypal.egg-info/PKG-INFO
new file mode 100644
index 0000000..d5891f3
--- /dev/null
+++ b/paypal.egg-info/PKG-INFO
@@ -0,0 +1,23 @@
+Metadata-Version: 1.1
+Name: paypal
+Version: 1.2.5
+Summary: PayPal API implementation in Python.
+Home-page: https://github.com/gtaylor/paypal-python
+Author: Gregory Taylor
+Author-email: gtaylor at gc-taylor.com
+License: Apache Software License
+Download-URL: http://pypi.python.org/pypi/paypal/
+Description: An implementation of PayPal's API in Python.
+ Currently features Direct Payment (Guest), and PayPal Express checkouts.
+
+Keywords: paypal nvp
+Platform: Platform Independent
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: Apache Software License
+Classifier: Natural Language :: English
+Classifier: Operating System :: OS Independent
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff --git a/paypal.egg-info/SOURCES.txt b/paypal.egg-info/SOURCES.txt
new file mode 100644
index 0000000..3d559a7
--- /dev/null
+++ b/paypal.egg-info/SOURCES.txt
@@ -0,0 +1,27 @@
+AUTHORS
+LICENSE
+MANIFEST.in
+README.rst
+setup.cfg
+setup.py
+paypal/__init__.py
+paypal/compat.py
+paypal/countries.py
+paypal/exceptions.py
+paypal/interface.py
+paypal/response.py
+paypal/response_list.py
+paypal/settings.py
+paypal.egg-info/PKG-INFO
+paypal.egg-info/SOURCES.txt
+paypal.egg-info/dependency_links.txt
+paypal.egg-info/requires.txt
+paypal.egg-info/top_level.txt
+tests/README
+tests/__init__.py
+tests/api_details_blank.py
+tests/interface_factory.py
+tests/test_buttons.py
+tests/test_countries.py
+tests/test_direct_payment.py
+tests/test_express_checkout.py
\ No newline at end of file
diff --git a/paypal.egg-info/dependency_links.txt b/paypal.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/paypal.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/paypal.egg-info/requires.txt b/paypal.egg-info/requires.txt
new file mode 100644
index 0000000..f229360
--- /dev/null
+++ b/paypal.egg-info/requires.txt
@@ -0,0 +1 @@
+requests
diff --git a/paypal.egg-info/top_level.txt b/paypal.egg-info/top_level.txt
new file mode 100644
index 0000000..f9e5d44
--- /dev/null
+++ b/paypal.egg-info/top_level.txt
@@ -0,0 +1 @@
+paypal
diff --git a/paypal/__init__.py b/paypal/__init__.py
new file mode 100644
index 0000000..650d9bc
--- /dev/null
+++ b/paypal/__init__.py
@@ -0,0 +1,11 @@
+# coding=utf-8
+#noinspection PyUnresolvedReferences
+from paypal.interface import PayPalInterface
+#noinspection PyUnresolvedReferences
+from paypal.settings import PayPalConfig
+#noinspection PyUnresolvedReferences
+from paypal.exceptions import PayPalError, PayPalConfigError, PayPalAPIResponseError
+#noinspection PyUnresolvedReferences
+import paypal.countries
+
+VERSION = '1.2.5'
diff --git a/paypal/compat.py b/paypal/compat.py
new file mode 100644
index 0000000..6de97b5
--- /dev/null
+++ b/paypal/compat.py
@@ -0,0 +1,128 @@
+# -*- coding: utf-8 -*-
+
+"""
+pythoncompat, from python-requests.
+
+Copyright (c) 2012 Kenneth Reitz.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+"""
+
+
+import sys
+
+# -------
+# Pythons
+# -------
+
+# Syntax sugar.
+_ver = sys.version_info
+
+#: Python 2.x?
+is_py2 = (_ver[0] == 2)
+
+#: Python 3.x?
+is_py3 = (_ver[0] == 3)
+
+#: Python 3.0.x
+is_py30 = (is_py3 and _ver[1] == 0)
+
+#: Python 3.1.x
+is_py31 = (is_py3 and _ver[1] == 1)
+
+#: Python 3.2.x
+is_py32 = (is_py3 and _ver[1] == 2)
+
+#: Python 3.3.x
+is_py33 = (is_py3 and _ver[1] == 3)
+
+#: Python 3.4.x
+is_py34 = (is_py3 and _ver[1] == 4)
+
+#: Python 2.7.x
+is_py27 = (is_py2 and _ver[1] == 7)
+
+#: Python 2.6.x
+is_py26 = (is_py2 and _ver[1] == 6)
+
+#: Python 2.5.x
+is_py25 = (is_py2 and _ver[1] == 5)
+
+#: Python 2.4.x
+is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.
+
+
+# ---------
+# Platforms
+# ---------
+
+
+# Syntax sugar.
+_ver = sys.version.lower()
+
+is_pypy = ('pypy' in _ver)
+is_jython = ('jython' in _ver)
+is_ironpython = ('iron' in _ver)
+
+# Assume CPython, if nothing else.
+is_cpython = not any((is_pypy, is_jython, is_ironpython))
+
+# Windows-based system.
+is_windows = 'win32' in str(sys.platform).lower()
+
+# Standard Linux 2+ system.
+is_linux = ('linux' in str(sys.platform).lower())
+is_osx = ('darwin' in str(sys.platform).lower())
+is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.
+is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.
+
+
+# ---------
+# Specifics
+# ---------
+
+
+if is_py2:
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from urllib import quote, unquote, urlencode
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from urlparse import urlparse, urlunparse, urljoin, urlsplit
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from urllib2 import parse_http_list
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ import cookielib
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from Cookie import Morsel
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from StringIO import StringIO
+
+ bytes = str
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ str = unicode
+ #noinspection PyUnresolvedReferences,PyCompatibility,PyUnboundLocalVariable
+ basestring = basestring
+elif is_py3:
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from urllib.request import parse_http_list
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from http import cookiejar as cookielib
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from http.cookies import Morsel
+ #noinspection PyUnresolvedReferences,PyCompatibility
+ from io import StringIO
+
+ str = str
+ bytes = bytes
+ basestring = (str, bytes)
diff --git a/paypal/countries.py b/paypal/countries.py
new file mode 100644
index 0000000..3d019d8
--- /dev/null
+++ b/paypal/countries.py
@@ -0,0 +1,292 @@
+"""
+Country Code List: ISO 3166-1993 (E)
+
+http://xml.coverpages.org/country3166.html
+
+A tuple of tuples of country codes and their full names. There are a few helper
+functions provided if you'd rather not use the dict directly. Examples provided
+in the test_countries.py unit tests.
+"""
+
+COUNTRY_TUPLES = (
+ ('US', 'United States of America'),
+ ('CA', 'Canada'),
+ ('AD', 'Andorra'),
+ ('AE', 'United Arab Emirates'),
+ ('AF', 'Afghanistan'),
+ ('AG', 'Antigua & Barbuda'),
+ ('AI', 'Anguilla'),
+ ('AL', 'Albania'),
+ ('AM', 'Armenia'),
+ ('AN', 'Netherlands Antilles'),
+ ('AO', 'Angola'),
+ ('AQ', 'Antarctica'),
+ ('AR', 'Argentina'),
+ ('AS', 'American Samoa'),
+ ('AT', 'Austria'),
+ ('AU', 'Australia'),
+ ('AW', 'Aruba'),
+ ('AZ', 'Azerbaijan'),
+ ('BA', 'Bosnia and Herzegovina'),
+ ('BB', 'Barbados'),
+ ('BD', 'Bangladesh'),
+ ('BE', 'Belgium'),
+ ('BF', 'Burkina Faso'),
+ ('BG', 'Bulgaria'),
+ ('BH', 'Bahrain'),
+ ('BI', 'Burundi'),
+ ('BJ', 'Benin'),
+ ('BM', 'Bermuda'),
+ ('BN', 'Brunei Darussalam'),
+ ('BO', 'Bolivia'),
+ ('BR', 'Brazil'),
+ ('BS', 'Bahama'),
+ ('BT', 'Bhutan'),
+ ('BV', 'Bouvet Island'),
+ ('BW', 'Botswana'),
+ ('BY', 'Belarus'),
+ ('BZ', 'Belize'),
+ ('CC', 'Cocos (Keeling) Islands'),
+ ('CF', 'Central African Republic'),
+ ('CG', 'Congo'),
+ ('CH', 'Switzerland'),
+ ('CI', 'Ivory Coast'),
+ ('CK', 'Cook Iislands'),
+ ('CL', 'Chile'),
+ ('CM', 'Cameroon'),
+ ('CN', 'China'),
+ ('CO', 'Colombia'),
+ ('CR', 'Costa Rica'),
+ ('CU', 'Cuba'),
+ ('CV', 'Cape Verde'),
+ ('CX', 'Christmas Island'),
+ ('CY', 'Cyprus'),
+ ('CZ', 'Czech Republic'),
+ ('DE', 'Germany'),
+ ('DJ', 'Djibouti'),
+ ('DK', 'Denmark'),
+ ('DM', 'Dominica'),
+ ('DO', 'Dominican Republic'),
+ ('DZ', 'Algeria'),
+ ('EC', 'Ecuador'),
+ ('EE', 'Estonia'),
+ ('EG', 'Egypt'),
+ ('EH', 'Western Sahara'),
+ ('ER', 'Eritrea'),
+ ('ES', 'Spain'),
+ ('ET', 'Ethiopia'),
+ ('FI', 'Finland'),
+ ('FJ', 'Fiji'),
+ ('FK', 'Falkland Islands (Malvinas)'),
+ ('FM', 'Micronesia'),
+ ('FO', 'Faroe Islands'),
+ ('FR', 'France'),
+ ('FX', 'France, Metropolitan'),
+ ('GA', 'Gabon'),
+ ('GB', 'United Kingdom (Great Britain)'),
+ ('GD', 'Grenada'),
+ ('GE', 'Georgia'),
+ ('GF', 'French Guiana'),
+ ('GH', 'Ghana'),
+ ('GI', 'Gibraltar'),
+ ('GL', 'Greenland'),
+ ('GM', 'Gambia'),
+ ('GN', 'Guinea'),
+ ('GP', 'Guadeloupe'),
+ ('GQ', 'Equatorial Guinea'),
+ ('GR', 'Greece'),
+ ('GS', 'South Georgia and the South Sandwich Islands'),
+ ('GT', 'Guatemala'),
+ ('GU', 'Guam'),
+ ('GW', 'Guinea-Bissau'),
+ ('GY', 'Guyana'),
+ ('HK', 'Hong Kong'),
+ ('HM', 'Heard & McDonald Islands'),
+ ('HN', 'Honduras'),
+ ('HR', 'Croatia'),
+ ('HT', 'Haiti'),
+ ('HU', 'Hungary'),
+ ('ID', 'Indonesia'),
+ ('IE', 'Ireland'),
+ ('IL', 'Israel'),
+ ('IN', 'India'),
+ ('IO', 'British Indian Ocean Territory'),
+ ('IQ', 'Iraq'),
+ ('IR', 'Islamic Republic of Iran'),
+ ('IS', 'Iceland'),
+ ('IT', 'Italy'),
+ ('JM', 'Jamaica'),
+ ('JO', 'Jordan'),
+ ('JP', 'Japan'),
+ ('KE', 'Kenya'),
+ ('KG', 'Kyrgyzstan'),
+ ('KH', 'Cambodia'),
+ ('KI', 'Kiribati'),
+ ('KM', 'Comoros'),
+ ('KN', 'St. Kitts and Nevis'),
+ ('KP', 'Korea, Democratic People\'s Republic of'),
+ ('KR', 'Korea, Republic of'),
+ ('KW', 'Kuwait'),
+ ('KY', 'Cayman Islands'),
+ ('KZ', 'Kazakhstan'),
+ ('LA', 'Lao People\'s Democratic Republic'),
+ ('LB', 'Lebanon'),
+ ('LC', 'Saint Lucia'),
+ ('LI', 'Liechtenstein'),
+ ('LK', 'Sri Lanka'),
+ ('LR', 'Liberia'),
+ ('LS', 'Lesotho'),
+ ('LT', 'Lithuania'),
+ ('LU', 'Luxembourg'),
+ ('LV', 'Latvia'),
+ ('LY', 'Libyan Arab Jamahiriya'),
+ ('MA', 'Morocco'),
+ ('MC', 'Monaco'),
+ ('MD', 'Moldova, Republic of'),
+ ('MG', 'Madagascar'),
+ ('MH', 'Marshall Islands'),
+ ('ML', 'Mali'),
+ ('MN', 'Mongolia'),
+ ('MM', 'Myanmar'),
+ ('MO', 'Macau'),
+ ('MP', 'Northern Mariana Islands'),
+ ('MQ', 'Martinique'),
+ ('MR', 'Mauritania'),
+ ('MS', 'Monserrat'),
+ ('MT', 'Malta'),
+ ('MU', 'Mauritius'),
+ ('MV', 'Maldives'),
+ ('MW', 'Malawi'),
+ ('MX', 'Mexico'),
+ ('MY', 'Malaysia'),
+ ('MZ', 'Mozambique'),
+ ('NA', 'Namibia'),
+ ('NC', 'New Caledonia'),
+ ('NE', 'Niger'),
+ ('NF', 'Norfolk Island'),
+ ('NG', 'Nigeria'),
+ ('NI', 'Nicaragua'),
+ ('NL', 'Netherlands'),
+ ('NO', 'Norway'),
+ ('NP', 'Nepal'),
+ ('NR', 'Nauru'),
+ ('NU', 'Niue'),
+ ('NZ', 'New Zealand'),
+ ('OM', 'Oman'),
+ ('PA', 'Panama'),
+ ('PE', 'Peru'),
+ ('PF', 'French Polynesia'),
+ ('PG', 'Papua New Guinea'),
+ ('PH', 'Philippines'),
+ ('PK', 'Pakistan'),
+ ('PL', 'Poland'),
+ ('PM', 'St. Pierre & Miquelon'),
+ ('PN', 'Pitcairn'),
+ ('PR', 'Puerto Rico'),
+ ('PT', 'Portugal'),
+ ('PW', 'Palau'),
+ ('PY', 'Paraguay'),
+ ('QA', 'Qatar'),
+ ('RE', 'Reunion'),
+ ('RO', 'Romania'),
+ ('RU', 'Russian Federation'),
+ ('RW', 'Rwanda'),
+ ('SA', 'Saudi Arabia'),
+ ('SB', 'Solomon Islands'),
+ ('SC', 'Seychelles'),
+ ('SD', 'Sudan'),
+ ('SE', 'Sweden'),
+ ('SG', 'Singapore'),
+ ('SH', 'St. Helena'),
+ ('SI', 'Slovenia'),
+ ('SJ', 'Svalbard & Jan Mayen Islands'),
+ ('SK', 'Slovakia'),
+ ('SL', 'Sierra Leone'),
+ ('SM', 'San Marino'),
+ ('SN', 'Senegal'),
+ ('SO', 'Somalia'),
+ ('SR', 'Suriname'),
+ ('ST', 'Sao Tome & Principe'),
+ ('SV', 'El Salvador'),
+ ('SY', 'Syrian Arab Republic'),
+ ('SZ', 'Swaziland'),
+ ('TC', 'Turks & Caicos Islands'),
+ ('TD', 'Chad'),
+ ('TF', 'French Southern Territories'),
+ ('TG', 'Togo'),
+ ('TH', 'Thailand'),
+ ('TJ', 'Tajikistan'),
+ ('TK', 'Tokelau'),
+ ('TM', 'Turkmenistan'),
+ ('TN', 'Tunisia'),
+ ('TO', 'Tonga'),
+ ('TP', 'East Timor'),
+ ('TR', 'Turkey'),
+ ('TT', 'Trinidad & Tobago'),
+ ('TV', 'Tuvalu'),
+ ('TW', 'Taiwan, Province of China'),
+ ('TZ', 'Tanzania, United Republic of'),
+ ('UA', 'Ukraine'),
+ ('UG', 'Uganda'),
+ ('UM', 'United States Minor Outlying Islands'),
+ ('UY', 'Uruguay'),
+ ('UZ', 'Uzbekistan'),
+ ('VA', 'Vatican City State (Holy See)'),
+ ('VC', 'St. Vincent & the Grenadines'),
+ ('VE', 'Venezuela'),
+ ('VG', 'British Virgin Islands'),
+ ('VI', 'United States Virgin Islands'),
+ ('VN', 'Viet Nam'),
+ ('VU', 'Vanuatu'),
+ ('WF', 'Wallis & Futuna Islands'),
+ ('WS', 'Samoa'),
+ ('YE', 'Yemen'),
+ ('YT', 'Mayotte'),
+ ('YU', 'Yugoslavia'),
+ ('ZA', 'South Africa'),
+ ('ZM', 'Zambia'),
+ ('ZR', 'Zaire'),
+ ('ZW', 'Zimbabwe'),
+ ('ZZ', 'Unknown or unspecified country'),
+)
+
+
+def is_valid_country_abbrev(abbrev, case_sensitive=False):
+ """
+ Given a country code abbreviation, check to see if it matches the
+ country table.
+
+ abbrev: (str) Country code to evaluate.
+ case_sensitive: (bool) When True, enforce case sensitivity.
+
+ Returns True if valid, False if not.
+ """
+ if case_sensitive:
+ country_code = abbrev
+ else:
+ country_code = abbrev.upper()
+
+ for code, full_name in COUNTRY_TUPLES:
+ if country_code == code:
+ return True
+
+ return False
+
+
+def get_name_from_abbrev(abbrev, case_sensitive=False):
+ """
+ Given a country code abbreviation, get the full name from the table.
+
+ abbrev: (str) Country code to retrieve the full name of.
+ case_sensitive: (bool) When True, enforce case sensitivity.
+ """
+ if case_sensitive:
+ country_code = abbrev
+ else:
+ country_code = abbrev.upper()
+
+ for code, full_name in COUNTRY_TUPLES:
+ if country_code == code:
+ return full_name
+
+ raise KeyError('No country with that country code.')
diff --git a/paypal/exceptions.py b/paypal/exceptions.py
new file mode 100644
index 0000000..d5edc44
--- /dev/null
+++ b/paypal/exceptions.py
@@ -0,0 +1,47 @@
+# coding=utf-8
+"""
+Various PayPal API related exceptions.
+"""
+
+
+class PayPalError(Exception):
+ """
+ Used to denote some kind of generic error. This does not include errors
+ returned from PayPal API responses. Those are handled by the more
+ specific exception classes below.
+ """
+ def __init__(self, message, error_code=None):
+ Exception.__init__(self, message, error_code)
+ self.message = message
+ self.error_code = error_code
+
+ def __str__(self):
+ if self.error_code:
+ return "%s (Error Code: %s)" % (repr(self.message), self.error_code)
+ else:
+ return repr(self.message)
+
+
+class PayPalConfigError(PayPalError):
+ """
+ Raised when a configuration problem arises.
+ """
+ pass
+
+
+class PayPalAPIResponseError(PayPalError):
+ """
+ Raised when there is an error coming back with a PayPal NVP API response.
+
+ Pipe the error message from the API to the exception, along with
+ the error code.
+ """
+ def __init__(self, response):
+ self.response = response
+ self.error_code = int(getattr(response, 'L_ERRORCODE0', -1))
+ self.message = getattr(response, 'L_LONGMESSAGE0', None)
+ self.short_message = getattr(response, 'L_SHORTMESSAGE0', None)
+ self.correlation_id = getattr(response, 'CORRELATIONID', None)
+
+ super(PayPalAPIResponseError, self).__init__(
+ self.message, self.error_code)
diff --git a/paypal/interface.py b/paypal/interface.py
new file mode 100644
index 0000000..b1a429c
... 1439 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-paypal.git
More information about the Python-modules-commits
mailing list