GithubHelp home page GithubHelp logo

bkeating / python-payflowpro Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 22.0 51 KB

A simple Python client for PayPal's Payflow Pro API (HTTPS Interface).

Home Page: https://www.paypal.com/us/webapps/mpp/payflow-payment-gateway

License: Apache License 2.0

Python 100.00%

python-payflowpro's Introduction

I'd like to use this space to encourage you to keep a repo of your dwelling(s). Keep diagrams, project quotes, garden plans, home repairs, and other related items that you and future owners can use, learn and measure from. File issues. Use Project kanbans to manage projects. Encourage Your family to join in.

Buildings do indeed learn.

It feels dumb at first. You wont feel encouraged whatsoever, but as the years pass it becomes precious. You gain a stronger understanding of how time plays out in a way I have yet to experience elsewhere.

python-payflowpro's People

Contributors

ataylor32 avatar bkeating avatar jmurty avatar sorter avatar tcarobruce avatar waterimp avatar wbtuomela 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-payflowpro's Issues

Cannot perform $0 Authorization (aka; ZDA, AVS-only)

NOTE: Please note that your merchant bank may not support $0 Authorizations (such as Paypal). In this case you would need to perform a void transaction type against the authorizations PNREF.

As the title says. I believe this is due to Python t reating 0 as Null but upon further inspection of the code, it doesn't appear to cite the proper

>>> responses, unconsumed_data = client.authorization(credit_card, Amount(amt=0.1, currency="USD"))
>>> print responses[0]
Response: {'authcode': '111111', 'respmsg': 'Approved', 'pnref': 'E34P0BCA60CE', 'result': '0', 'correlationid': '2c9706997458s'}
>>> responses, unconsumed_data = client.authorization(credit_card, Amount(amt=0, currency="USD"))
>>> print responses[0]
Response: {'respmsg': 'Invalid amount', 'pnref': 'E35P0BCA60D4', 'result': '4'}

When I give a value of "0" and print the Amount variable I get:

>>> responses, unconsumed_data = client.authorization(credit_card, Amount(amt=0, currency="USD"))
Amount: {'currency': 'USD'}

So the amount "0" isn't even reaching the authorization class(is it a class or function?)

This has some helpful info https://www.x.com/docs/DOC-1561
Also helpful: Starting on Page 32 of https://cms.paypal.com/cms_content/US/en_US/files/developer/PP_PayflowPro_Guide.pdf

KeyError: 'p_transtate1' on client.profile_inquiry() w/ Payment History

FIXED: look at replies below. This issue is not related to live vs test servers.

It seems payment_history_only=True will work when pointing to https://pilot-payflowpro.paypal.com but when using the live server (https://payflowpro.paypal.com) I get a much different response. Look at my interactive Python session below to see what I mean.

bkeating@bristle:~$ python
>>> from payflowpro.classes import CreditCard, Amount, Profile, Address, \
...                                 ShippingAddress, Tracking, Response, \
...                                 CustomerInfo
>>> from payflowpro.client import PayflowProClient, find_classes_in_list, \
...                                 find_class_in_list
>>> client = PayflowProClient(
...     partner="paypal",
...     vendor="*********",
...     username="*********",
...     password="*********",
...     url_base="https://payflowpro.paypal.com")

>>> # RP0000000600 is a "Active" Recuring Profile.
>>> results, unconsumed_data = client.profile_inquiry(profile_id='RP0000000600', payment_history_only=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/django/projects/******/payflowpro/client.py", line 297, in profile_inquiry
    return self._do_request(request_id, params)        
  File "/data/django/projects/******/payflowpro/client.py", line 193, in _do_request
    result_objects, unconsumed_data = parse_parameters(results)
  File "/data/django/projects/******/payflowpro/classes.py", line 349, in parse_parameters
    p_transtate = unconsumed_data.pop("p_transtate%d" % recurpaycount),
KeyError: 'p_transtate1'

>>> client = PayflowProClient(
...     partner="paypal",
...     vendor="*********",
...     username="*********",
...     password="*********",
...     url_base="https://pilot-payflowpro.paypal.com")
>>> results, unconsumed_data = client.profile_inquiry(profile_id='RT0000000002', payment_history_only=True)
>>> recurring_payments = results[-1]
>>> print recurring_payments
RecurringPayments: [RecurringPayment: {'p_pnref': 'E78P0BD0911E', 'p_amt': '8.00', 'p_transtime': '06-Sep-07  04:30 AM', 'p_transtate': '8', 'p_tender': 'C', 'p_result': '0'}, ... ]

The (directly) related code in python-payflowpro as far as I can tell is: https://github.com/bkeating/python-payflowpro/blob/master/payflowpro/classes.py#L329

Ideas as to whats going on here? Is there some testing that can happen before doing a history_only inquiry?

Please update the pypi release of this!

The version of this on pypi is old as the hills; it would be nice if it could get updated!

The guide for doing so is here: http://docs.python.org/2/distutils/packageindex.html#package-index

But you may require access to be granted for that project from the old maintainer -- I'm not sure how pypi does this. The current pypi entry is https://pypi.python.org/pypi/python-payflowpro/0.2-final

I can ask a friend for more info about updating packages (I know very little about this), but it looks like it's mostly just setup.py stuff, let me know if there's anything I can do or ask to help :-)

Thanks,
Chris

API behind current specification

Hi,
I noticed that the classes.py reflects a much older state of the payflowgateway specs. When I look at the current revision(25 April 2013):
https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/payflowgateway_guide.pdf

I noticed among other things:

  • CustomerInfo uses deprecated values instead of the BILLTO*
  • Same for the Address information, maybe better to have a new BillToAddress class
  • CUSTIP and CUSTBROWSER are missing

I plan to submit a pull request, once I am through most of my implementation. I will try to keep things backwards compatible as not to break things for other users.

Great library other than that (and the fact that I need to use it async).

best regards,
Florian

KeyError for Old Transactions in Recurring Profiles

When querying recurring profiles that have old transactions the parse_parameters def (line 354) throws a KeyError, as not all data is returned. Below is an example of unconsumed data returned while providing "payment_history_only=True" to the PayPal client. p_transtate and p_amt are missing from transactions prior to 2013.

I can patch this if necessary, let me know.

Mark

unconsumed_data: {
'p_transtate4': '8',
'p_transtime4': '25-Jan-13 06:13 AM',
'p_result4': '0',
'p_tender4': 'C',
'p_amt4': '39.00'
'p_pnref4': 'VU...',

'p_result1': '0',
'p_transtime1': '25-Jan-10 05:44 AM',
'p_tender1': 'C',
'p_pnref1': 'VU...',

'p_transtime2': '25-Jan-11 06:06 AM',
'p_result2': '0',
'p_tender2': 'C',
'p_pnref2': 'VP...',

'p_transtime3': '25-Jan-12 06:39 AM',
'p_result3': '0',
'p_tender3': 'C',
'p_pnref3': 'VD...',
}

Payflow Gateway / Credit Referenced Transaction Amount wrong...

When i do:
responses, unconsumed_data = client.credit_referenced(transid)

From my Paypal manager / test mode, I can see a successful credit .. But unfortunately the amount is 1$ for some reason not the full amount which in this case was 45$...

Is this something paypal does in test mode? or something is funky with the created response by the Python PayflowPro?

Payflow Gateway Reports "Invalid tender" on Reference Transaction

Thank you for all the hard work on this API.

I noticed a slight issue when using the reference_transaction() method. The Payflow gateway would report back to me that I had submitted "Invalid Tender" and the transaction fails.

The payflow docs describe:
"Invalid tender type. Your merchant bank account does not support the following credit card type that
was submitted."

When I looked at the query parameters that python-payflow-pro was sending to the gateway, I noticed that what it was sending was different from what the docs suggested.

What python-payflow-pro sent to the gateway:

AMT[1]=4&CURRENCY[3]=USD&ORIGID[12]=*******&PARTNER[6]=PayPal&PWD[13]=********&TRXTYPE[1]=S&USER[12]=******&VENDOR[12]=*****

What the PayFlow Pro docs say should be sent:

TRXTYPE=A&TENDER=C&PWD=x1y2z3&PARTNER=PayPal&VENDOR=SuperMerchant&USER=SuperMerchant&ACCT=5555555555554444&EXPDATE=0308&AMT=100.00&INVNUM=123456789&STREET=5199 MAPLE&ZIP=94588

If you notice, the TENDER="C" parameter is missing from the python payflow-pro generated request.

I was able to force this parameter into the request using a Tender class with a "data" property. However, this feels a bit kludgy. Maybe I'm doing something wrong or using reference transactions incorrectly?

....

class Tender(): 
        """
        Force the tender into the parmas list sent to paypal
        """
        def __init__(self, *args, **kwargs):
            self.data =  {'TENDER':"C"}

        def __len__(self):
            return len(self.data)


 client.reference_transaction(
            transaction_type=transaction_type, original_pnref=original_pnref,
            amount=Amount(amt=amount, currency="USD"), extras=[Tender()])

Anyway, just bringing this up here in case it is an API issue.
Thanks for reading,
Joe

BAID Not Supported

There seems to be no way to create a recurring billing profile to charge a PayPal account. For this we would need to provide a BAID parameter.

Moreover, would it make sense to include support in this library for obtaining such a BAID?

Support for Secure Token, Transparent Redirect

It appears this library provides no support for Secure Token and Transparent Redirect (i.e., parameters SECURETOKENID, CREATESECURETOKEN, and SILENTTRAN).

Classes/Fields for these can easily be added and passed as 'extras', but routines like PayflowProClient.authorization require credit_card, which must not be sent for Secure Token calls -- the whole idea is that the server code never sees the credit_card.

invoice submitting not possible

Hello. Thanks for all the work on this library, you saved me a bunch of trouble, and came up with a pretty well designed solution, where I would've done a quick and dirty fix.

I notice none of the PayflowProObject subclasses provide an invnum parameter that paypal accepts for providing the store's internal invoice for the sell.

I don't think it's a required parameter for any transaction, but I thought maybe it'd be a nice thing to have. Do you have a reason for not adding it?

UnicodeDecodeError when querying Recurring Profiles.

When you are querying RecurringProfiles, if any of the field names (FIRSTNAME, SHIPTOCITY, etc.) have accented characters (example: Andrés), python-payflowpro will come back with a UnicodeDecodeError:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 347: ordinal not in range(128)

If you modified the field (via Paypal Manager) and replace the accented characters, the symptom goes away but the correct way to solve the problem is to kindly support Unicode decoding. I found this thread over at Stack Overflow to help shed light on the issue: http://stackoverflow.com/questions/3669436/converting-unicode-objects-with-non-ascii-symbols-in-them-into-strings-objects-i

In particular, the code errors out at/around:

python-payflowpro/payflowpro/client.py", line 189, in _do_request
raise e

new_acct is undefined in tests

**********************************************************************
File "client.py", line 70, in __main__
Failed example:
    responses, unconsumed_data = client.profile_modify(
        profile_id='RT0000000002', extras=[
            Profile(profilename="Joe Bloggs", start=052413,),
            CreditCard(acct=new_acct,expdate=new_expdate,cvv2=new_cvc,),
            ShippingAddress(shiptostreet="123 Main St.", shiptocity="Oakland",
                shiptofirstname="Joe", shiptolastname="Bloggs",
                shiptostate="CA", shiptocountry="US", shiptozip="94123"),
            CustomerInfo(email='[email protected]',
                firstname='Joe', lastname='Bloggs'),
            Tracking(comment1="Order #44",comment2="Submitted by doctest.",)])
Exception raised:
    Traceback (most recent call last):
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/doctest.py", line 1254, in __run
        compileflags, 1) in test.globs
      File "<doctest __main__[17]>", line 4, in <module>
        CreditCard(acct=new_acct,expdate=new_expdate,cvv2=new_cvc,),
    NameError: name 'new_acct' is not defined
**********************************************************************

It looks like new_expdate and new_cvc is undefined, too.

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.