Giter VIP home page Giter VIP logo

paypal-python's Introduction

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.

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.

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 [email protected]. 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 <[email protected]>
Copyright 2012 DUO Interactive, LLC <[email protected]>
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.

paypal-python's People

Contributors

brimcfadden avatar brutasse avatar cbsmith avatar davidfooks avatar floatplane avatar gtaylor avatar hlainchb avatar ibrahimsag avatar jlev avatar loop0 avatar maniksurtani avatar oczkers avatar patcoll avatar refik avatar ronnix avatar terencehonles avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-python's Issues

Document as working on Python 2.5

I've checked this on python 2.5 (for App Engine). I grepped for "".format(), with, etc., and it had no new features; and the tests run fine on 2.5. Please change the "Requires Python 2.6 or 2.7" to "2.5 - 2.7"

Logging outputs username/password/signature for non DEBUG level logging

I don't like the idea of filling my logs with the password for API access to my PayPal account:

https://github.com/duointeractive/paypal-python/blob/b5a3e4afb89f6e5404643b6113c030380ecb0bcc/paypal/interface.py#L133

This is particularly important given that PayPal supports a "Pay" API (https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-payments/Pay_API_Operation/). This means any user who can view the logs can transfer funds from the account into their own PayPal accounts.

response_list.py imports not working in python3.5

The imports in response_list.py are missing the "paypal." package name prefix. Causes

ImportError: No module named 'response'

when using paypal-python with Python3.5

9,10c9,10
< from response import PayPalResponse
< from exceptions import PayPalAPIResponseError
---
> from paypal.response import PayPalResponse
> from paypal.exceptions import PayPalAPIResponseError

Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

Hi

Since today I can no longer import paypal in Python

LinuxMint 18
Python 2.7.12
paypal 1.2.5 (from pip)

>>> import paypal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/paypal/__init__.py", line 3, in <module>
    from paypal.interface import PayPalInterface
  File "/usr/local/lib/python2.7/dist-packages/paypal/interface.py", line 13, in <module>
    import requests
  File "/usr/local/lib/python2.7/dist-packages/requests/__init__.py", line 61, in <module>
    raise RuntimeError('Requests dependency \'urllib3\' must be version >= 1.21.1, < 1.22!')
RuntimeError: Requests dependency 'urllib3' must be version >= 1.21.1, < 1.22!

Maybe I made an update yesterday, so I tried now to downgrade to 1.2.4 and 1.2.3 but the same error.
Also I was wonder why pip is version 1.2.5 and git 1.2.4

$ sudo -H pip search urllib3
urllib3 (1.21.1)             - HTTP library with thread-safe connection pooling, file post, and more.
  INSTALLED: 1.13.1

It runs now but only ich i change directory to /usr/local/lib/python2.7/dist-packages/paypal and:

#linuxmint=1.13.1 #new=urllib3-1.21.1
$ sudo pip install urllib3 -t /usr/local/lib/python2.7/dist-packages/paypal 
#linuxmint=2.3.0 #new=chardet-3.0.4
$ sudo pip install chardet -t /usr/local/lib/python2.7/dist-packages/paypal  

regards

Express Checkout Tests

I noticed the Express Checkout tests were... limited, and I understand why. ;-)

I was thinking of experimenting with Windmill (http://www.getwindmill.com/). Do you think if I wrote tests using it they'd be suitable for inclusion in the project?

'amt' deprecated in paypal api

I've been working on implementing a thin utility for the plone CMS (and possibly for the larger zope community) wrapping your lovely package here. The work in progress is here:

https://github.com/cewing/eastofeaton.paypal

Anywho, in working on this, I've done a lot of reading of the current (4/2011) api docs for paypal NVP, and the 'amt' parameter is now deprecated. This is only a problem when trying to be as clean as possible in making api calls, since the 'set_express_checkout' method and others check to ensure that the 'amt' keyword is included.

Any chance we can get that cleaned up?

Don't allow None configs

Currently, creating instantiating either PayPalConfig or PayPalInterface is allowed with None values for configs. These results in a rather obnoxious traceback:

In [1]: from paypal import PayPalConfig, PayPalInterface

In [2]: config = {'API_USERNAME': None, 'API_PASSWORD': None, 'API_SIGNATURE': None}

In [3]: paypal_config = PayPalConfig(**config)

In [4]: paypal_interface = PayPalInterface(paypal_config)

In [5]: paypal_interface.set_express_checkout()
No handlers could be found for logger "paypal.interface"
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-ec8c65f528eb> in <module>()
----> 1 paypal_interface.set_express_checkout()

/Users/max/.virtualenvs/paypal/lib/python2.7/site-packages/paypal/interface.py in set_express_checkout(self, **kwargs)
    363         * CANCELURL
    364         """
--> 365         return self._call('SetExpressCheckout', **kwargs)
    366
    367     def refund_transaction(self, transactionid=None, payerid=None, **kwargs):

/Users/max/.virtualenvs/paypal/lib/python2.7/site-packages/paypal/interface.py in _call(self, method, **kwargs)
    146             logger.error('A PayPal API error was encountered.')
    147             url_values_no_credentials = dict((p, 'X' * len(v) if p in \
--> 148                 self.__credentials else v) for (p, v) in url_values.items())
    149             logger.error('PayPal NVP Query Key/Vals (credentials removed):' \
    150                 '\n%s' % pformat(url_values_no_credentials))

/Users/max/.virtualenvs/paypal/lib/python2.7/site-packages/paypal/interface.py in <genexpr>((p, v))
    146             logger.error('A PayPal API error was encountered.')
    147             url_values_no_credentials = dict((p, 'X' * len(v) if p in \
--> 148                 self.__credentials else v) for (p, v) in url_values.items())
    149             logger.error('PayPal NVP Query Key/Vals (credentials removed):' \
    150                 '\n%s' % pformat(url_values_no_credentials))

TypeError: object of type 'NoneType' has no len()

To reproduce run:

curl https://gist.githubusercontent.com/mamachanko/dcff9f436bebcb95c891/raw/44da5621f4d92181a65d99256a5cbedcb1e40876/none-config-traceback.py | python

My suggestion is to raise a PayPalConfigError instead. Question remains whether it should be raised upon a call or upon instantiation of either PayPalConfig. You can make a case for either.

Express Checkout Tests

I noticed the Express Checkout tests were... limited, and I understand why. ;-)

I was thinking of experimenting with Windmill (http://www.getwindmill.com/). Do you think if I wrote tests using it they'd be suitable for inclusion in the project?

1.2.1 on PyPi

Hi, could you update PyPi to have 1.2.1 available?

Excuse my misuse of an Issue, yet I couldn't think of a better way to contact you.

Can't launch to production

Hello, I've been using your lib with sandbox and it'f working fine, but when I'm passing this:

        if sett.pay_pal_production is False:
            env_value = 'SANDBOX'
        elif sett.pay_pal_production is True:
            env_value = 'PRODUCTION'
        print env_value
        # env_value = 'SANDBOX'
        config = PayPalConfig(API_USERNAME=sett.get_pay_pal_username(),
                              API_PASSWORD=sett.get_pay_pal_password(),
                              API_SIGNATURE=sett.get_pay_pal_signature(),
                              API_ENVIRONMENT=env_value,
                              )

So, I've tried use this parametr API_ENVIRONMENT to use real paypal instead of sandbox.
I printed object contents - URLs seems to be fine and looking to real API ( not Sandbox ).
But it's not working for some reason.
Please help me :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.