Giter Site home page Giter Site logo

Comments (2)

jmurty avatar jmurty commented on July 21, 2024

The code you refer to builds a list of recurring payment objects with the assumption that for every p_resultN key value in the response data (where N is 1 or greater) there will be always be five other corresponding keys: p_pnrefN, p_tenderN, p_transtimeN, p_amtN and p_transtateN.

At least the last of these keys (p_transtateN) is missing in the response, and maybe others are too.

It's years since I've worked with PayflowPro (happily) but my best guess is that they've either changed the key names returned for recurring payments, or the code should not assume that all the other keys are present in all cases.

To fix this, first make sure that the p_WHATEVER values the code is looking for are correct for the latest version of the PayflowPro API. The problem might be as simple as a renamed key, since the code isn't necessarily up-to-date.

If the key name is right but it isn't always present in responses, you will need to check for the key name in the unconsumed_data dictionary rather than always pop-ing it. Something like this should do:

while ("p_result%d" % recurpaycount) in unconsumed_data:
my_transtate = None
if ("p_transtate%d" % recurpaycount) in unconsumed_data:
my_transate = unconsumed_data.pop("p_transtate%d" % recurpaycount)
payments.append(RecurringPayment(
p_result = unconsumed_data.pop("p_result%d" % recurpaycount),
p_pnref = unconsumed_data.pop("p_pnref%d" % recurpaycount),
p_transtate = my_transtate,
p_tender = unconsumed_data.pop("p_tender%d" % recurpaycount),
p_transtime = unconsumed_data.pop("p_transtime%d" % recurpaycount),
p_amt = unconsumed_data.pop("p_amt%d" % recurpaycount)))

from python-payflowpro.

bkeating avatar bkeating commented on July 21, 2024

Hey James,

Thank you for your reply. It was exactly what I needed. The live RecurringProfile I was testing against did not have the p_transtate and p_amt values on record on some of it's first charges while the test profile i was using did. PayPal_ToddS's reply in this thread (https://www.x.com/message/180630#180630) makes me think these fields may not have existed when the first few charges went through on the profile. The test profile, created around the same time however, worked before this fix. So im not sure this was my case.

I found that .pop() allows a default value. Here is the change: 1fe5806

Thanks again!

from python-payflowpro.

Related Issues (12)

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.