def add_profile( customer_id, payment_form_data, billing_form_data, shipping_form_data=None, customer_email=None, customer_description=None, validation_mode=None, ): """ Add a customer profile with a single payment profile and return a tuple of the CIMResponse, profile ID, and single-element list of payment profile IDs. Arguments: customer_id -- unique merchant-assigned customer identifier payment_form_data -- dictionary with keys in CREDIT_CARD_FIELDS billing_form_data -- dictionary with keys in BILLING_FIELDS shipping_form_data -- dictionary with keys in SHIPPING_FIELDS customer_email -- customer email customer_description -- customer decription validation_mode -- 'testMode' or 'liveMode' """ kwargs = { "customer_id": customer_id, "customer_email": customer_email, "customer_description": customer_description, "credit_card_data": extract_payment_form_data(payment_form_data), "billing_data": extract_form_data(billing_form_data), } if shipping_form_data: kwargs["shipping_data"] = extract_form_data(shipping_form_data) if validation_mode: kwargs["validation_mode"] = validation_mode helper = CreateProfileRequest(**kwargs) response = helper.get_response() info = helper.customer_info if response.success: profile_id = helper.profile_id payment_profile_ids = helper.payment_profile_ids shipping_profile_ids = helper.shipping_profile_ids customer_was_created.send( sender=response, customer_id=info.get("merchantCustomerId"), customer_description=info.get("description"), customer_email=info.get("email"), profile_id=helper.profile_id, payment_profile_ids=helper.payment_profile_ids, ) else: profile_id = None payment_profile_ids = None shipping_profile_ids = None customer_was_flagged.send(sender=response, customer_id=customer_id) return { "response": response, "profile_id": profile_id, "payment_profile_ids": payment_profile_ids, "shipping_profile_ids": shipping_profile_ids, }
def add_profile(customer_id, payment_form_data, billing_form_data): """ Add a customer profile with a single payment profile and return a tuple of the CIMResponse, profile ID, and single-element list of payment profile IDs. Arguments: customer_id -- unique merchant-assigned customer identifier payment_form_data -- dictionary with keys in CREDIT_CARD_FIELDS billing_form_data -- dictionary with keys in BILLING_FIELDS """ payment_data = extract_form_data(payment_form_data) billing_data = extract_form_data(billing_form_data) payment_data['expirationDate'] = \ payment_data['expirationDate'].strftime('%Y-%m') helper = CreateProfileRequest(customer_id, billing_data, payment_data) response = helper.get_response() if response.success: profile_id = helper.profile_id payment_profile_ids = helper.payment_profile_ids customer_was_created.send(sender=response, customer_id=helper.customer_id, profile_id=helper.profile_id, payment_profile_id=helper.payment_profile_id) else: profile_id = None payment_profile_ids = None customer_was_flagged.send(sender=response, customer_id=helper.customer_id) return response, profile_id, payment_profile_ids
def add_profile(customer_id, payment_form_data, billing_form_data, shipping_form_data=None, customer_email=None, customer_description=None): """ Add a customer profile with a single payment profile and return a tuple of the CIMResponse, profile ID, and single-element list of payment profile IDs. Arguments (required): customer_id -- unique merchant-assigned customer identifier payment_form_data -- dictionary with keys in CREDIT_CARD_FIELDS billing_form_data -- dictionary with keys in BILLING_FIELDS shipping_form_data -- dictionary with keys in SHIPPING_FIELDS Keyword Arguments (optional): customer_email -- customer email customer_description -- customer description """ kwargs = {'customer_id': customer_id, 'credit_card_data': extract_payment_form_data(payment_form_data), 'billing_data': extract_form_data(billing_form_data), 'customer_email': customer_email, 'customer_description': customer_description} if shipping_form_data: kwargs['shipping_data'] = extract_form_data(shipping_form_data) helper = CreateProfileRequest(**kwargs) response = helper.get_response() info = helper.customer_info if response.success: profile_id = helper.profile_id payment_profile_ids = helper.payment_profile_ids shipping_profile_ids = helper.shipping_profile_ids customer_was_created.send(sender=response, customer_id=info.get("merchantCustomerId"), customer_description=info.get("description"), customer_email=info.get("email"), profile_id=helper.profile_id, payment_profile_ids=helper.payment_profile_ids) else: profile_id = None payment_profile_ids = None shipping_profile_ids = None customer_was_flagged.send(sender=response, customer_id=customer_id) return {'response': response, 'profile_id': profile_id, 'payment_profile_ids': payment_profile_ids, 'shipping_profile_ids': shipping_profile_ids}