Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Parses a set of Payflow Pro response parameter name and value pairs into 
a list of PayflowProObjects, and returns a tuple containing the object
list and a dictionary containing any unconsumed data. 

The first item in the object list will always be the Response object, and
the RecurringPayments object (if any) will be last.

The presence of any unconsumed data in the resulting dictionary probably
indicates an error or oversight in the PayflowProObject definitions.

        def parse_parameters(payflowpro_response_data):
    """
    Parses a set of Payflow Pro response parameter name and value pairs into 
    a list of PayflowProObjects, and returns a tuple containing the object
    list and a dictionary containing any unconsumed data. 
    
    The first item in the object list will always be the Response object, and
    the RecurringPayments object (if any) will be last.

    The presence of any unconsumed data in the resulting dictionary probably
    indicates an error or oversight in the PayflowProObject definitions.
    """
    def build_class(klass, unconsumed_data):
        known_att_names_set = set(klass.base_fields.keys())
        available_atts_set = known_att_names_set.intersection(unconsumed_data)
        if available_atts_set:
            available_atts = dict()
            for name in available_atts_set:
                available_atts[name] = unconsumed_data[name]
                del unconsumed_data[name]                    
            return klass(**available_atts)
        return None

    unconsumed_data = payflowpro_response_data.copy()

    # Parse the response data first
    response = build_class(Response, unconsumed_data)
    result_objects = [response]

    if int(response.result) != 0:
        # Error response
        return (result_objects, unconsumed_data,)
    
    # Parse the remaining data
    for klass in object.__class__.__subclasses__(PayflowProObject):
        obj = build_class(klass, unconsumed_data)
        if obj:
            result_objects.append(obj)
    
    # Special handling of RecurringPayments
    recurpaycount = 1
    payments = []
    while ("p_result%d" % recurpaycount) in unconsumed_data:
        payments.append(RecurringPayment(
            p_result = unconsumed_data.pop("p_result%d" % recurpaycount),
            p_pnref = unconsumed_data.pop("p_pnref%d" % recurpaycount),
            p_transtate = unconsumed_data.pop("p_transtate%d" % recurpaycount),
            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)))
        recurpaycount += 1
    if payments:
        result_objects.append(RecurringPayments(payments=payments))
        
    return (result_objects, unconsumed_data,)
        


src/p/y/python_payflowpro-0-0.2-final/payflowpro/client.py   python-payflowpro(Download)
from urllib2 import Request, urlopen, urlparse
 
from classes import (CreditCard, Amount, Profile, 
                     Address, Tracking, Response, parse_parameters)
 
 
        # Parse results dictionary into a set of PayflowProObjects
        result_objects, unconsumed_data = parse_parameters(results)
        self.log.debug(u"Result parsed objects: %s" % result_objects)
        self.log.debug(u"Unconsumed Data: %s" % unconsumed_data)

src/p/y/python-payflowpro-HEAD/payflowpro/client.py   python-payflowpro(Download)
from urllib2 import Request, urlopen, urlparse
 
from classes import (CreditCard, Amount, Profile, 
                     Address, Tracking, Response, parse_parameters)
 
 
        # Parse results dictionary into a set of PayflowProObjects
        result_objects, unconsumed_data = parse_parameters(results)
        self.log.debug(u"Result parsed objects: %s" % result_objects)
        self.log.debug(u"Unconsumed Data: %s" % unconsumed_data)