Controller for the billing logic. It is used by both the single shipping and the multishipping functionality and is responsible for payment method selection and entering a billing address.
Members
(static) Billing
Form handler for the billing form.
- Source:
- See:
(static) EditAddress
Renders a form dialog to edit an address.
- Source:
- See:
(static) EditBillingAddress
Form handler for the returnToForm form.
- Source:
- See:
(static) GetGiftCertificateBalance
Returns information of a gift certificate including its balance as JSON response.
- Source:
- See:
(static) HandlePaymentSelection
Handles the selection of the payment method and performs payment method specific validation and verification upon the entered form fields.
- Source:
- See:
(static) RedeemGiftCertificateJson
Redeems gift certificates.
- Source:
- See:
(static) RemoveGiftCertificate
Removes gift certificate from the basket payment instruments.
- Source:
- See:
(static) SaveCreditCard
Saves the credit card used in the billing form in the customer payment instruments.
- Source:
- See:
(static) SelectCreditCard
Selects a customer credit card and returns the details of the credit card as JSON response.
- Source:
- See:
(static) Start
Starting point for billing.
- Source:
- See:
(static) UpdateAddressDetails
Gets the customer address and saves it to the customer address book.
- Source:
- See:
(static) UpdateCreditCardSelection
Adds the currently selected credit card to the billing form and initializes the credit card selection list.
- Source:
- See:
(static) UpdateSummary
Updates the order totals and recalculates the basket after a coupon code is applied.
- Source:
- See:
(static) ValidatePayment
Revalidates existing payment instruments in later checkout steps.
- Source:
- See:
Methods
(inner) adjustGiftCertificates()
Adjusts gift certificate redemptions after applying coupon(s), because this changes the order total. Removes and then adds currently added gift certificates to reflect order total changes.
(inner) billing()
Form handler for the billing form. Handles the following actions:
- applyCoupon - gets the coupon to add from the httpParameterMap couponCode property and calls handleCoupon
- creditCardSelect - calls the updateCreditCardSelection function.
- paymentSelect - calls the publicStart function.
- redeemGiftCert - redeems the gift certificate entered into the billing form and returns to the cart.
- save - validates payment and address information and handles any errors. If the billing form is valid, saves the billing address to the customer profile, sets a flag to indicate the billing step is successful, and calls the COSummary controller Start function.
- selectAddress - calls the updateAddressDetails function.
(inner) editAddress()
Renders a form dialog to edit an address. The dialog is supposed to be opened by an Ajax request and ends in templates, which trigger a certain JavaScript event. The calling page of this dialog is responsible for handling these events.
(inner) editBillingAddress()
Form handler for the returnToForm form.
- apply - attempts to save billing address information to the platform. If there is an error, renders the components/dialog/dialogapply template. If it is successful, sets the ContinueURL to EditBillingAddress and renders the checkout/billing/billingaddressdetails template.
- remove - Checks if the customer owns any product lists. If they do not, removes the address from the customer address book and renders the components/dialog/dialogdelete template. If they do own product lists, sets the ContinueURL to EditBillingAddress and renders the checkout/billing/billingaddressdetails template.
(inner) getGiftCertificateBalance()
Returns information of a gift certificate including its balance as JSON response. Required to check the remaining balance.
(inner) handleBillingAddress(cart) → {boolean}
Gets or creates a billing address and copies it to the billingaddress form. Also sets the customer email address to the value in the billingAddress form.
Parameters:
Name | Type | Description |
---|---|---|
cart |
module:models/CartModel~CartModel |
A CartModel wrapping the current Basket. |
Returns:
true
- Type
- boolean
(inner) handleCoupon()
Used to adjust gift certificate totals, update page metadata, and render the billing page. This function is called whenever a billing form action is handled.
- Source:
- See:
(inner) handlePaymentSelection()
Handles the selection of the payment method and performs payment method-specific validation and verification on the entered form fields. If the order total is 0 (if the user has product promotions) then we do not need a valid payment method.
(inner) initAddressForm()
Initializes the address form. If the customer chose "use as billing address" option on the single shipping page the form is prepopulated with the shipping address, otherwise it prepopulates with the billing address that was already set. If neither address is available, it prepopulates with the default address of the authenticated customer.
(inner) initCreditCardList(cart) → {object}
Initializes the credit card list by determining the saved customer payment methods for the current locale.
Parameters:
Name | Type | Description |
---|---|---|
cart |
module:models/CartModel~CartModel |
A CartModel wrapping the current Basket. |
Returns:
JSON object with members ApplicablePaymentMethods and ApplicableCreditCards.
- Type
- object
(inner) initEmailAddress()
Initializes the email address form field. If there is already a customer email set at the basket, that email address is used. If the current customer is authenticated the email address of the customer's profile is used.
(inner) publicStart()
Starting point for billing. After a successful shipping setup, both COShipping and COShippingMultiple call this function.
(inner) redeemGiftCertificate(giftCertCode) → {object}
Redeems a gift certificate. If the gift certificate was not successfully redeemed, the form field is invalidated with the appropriate error message. If the gift certificate was redeemed, the form gets cleared. This function is called by an Ajax request and generates a JSON response.
Parameters:
Name | Type | Description |
---|---|---|
giftCertCode |
String |
Gift certificate code entered into the giftCertCode field in the billing form. |
Returns:
JSON object containing the status of the gift certificate.
- Type
- object
(inner) redeemGiftCertificateJson()
Gets the gift certificate code from the httpParameterMap and redeems it. For an ajax call, renders an empty JSON object. Otherwise, renders a JSON object with information about the gift certificate code and the success and status of the redemption.
(inner) removeGiftCertificate()
Removes gift certificate from the basket payment instruments and generates a JSON response with a status. This function is called by an Ajax request.
(inner) resetPaymentForms() → {Boolean}
Clears the form element for the currently selected payment method and removes the other payment methods.
Returns:
Returns true if payment is successfully reset. Returns false if the currently selected payment method is bml and the ssn cannot be validated.
- Type
- Boolean
(inner) returnToForm(cart, params)
Updates data for the billing page and renders it. If payment method is set to gift certificate, gets the gift certificate code from the form. Updates the page metadata. Gets a view and adds any passed parameters to it. Sets the Basket and ContinueURL properties. Renders the checkout/billing/billing template.
Parameters:
Name | Type | Description |
---|---|---|
cart |
module:models/CartModel~CartModel |
A CartModel wrapping the current Basket. |
params |
object |
(optional) if passed, added to view properties so they can be accessed in the template. |
(inner) saveCreditCard() → {Boolean}T
Attempts to save the used credit card in the customer payment instruments. The logic replaces an old saved credit card with the same masked credit card number of the same card type with the new credit card. This ensures creating only unique cards as well as replacing expired cards.
Returns:
true if credit card is successfully saved.
- Type
- Boolean
(inner) selectCreditCard()
Selects a customer credit card and returns the details of the credit card as JSON response. Required to fill credit card form with details of selected credit card.
(inner) start(cart, params)T
Updates cart calculation and page information and renders the billing page.
Parameters:
Name | Type | Description |
---|---|---|
cart |
module:models/CartModel~CartModel |
A CartModel wrapping the current Basket. |
params |
object |
(optional) if passed, added to view properties so they can be accessed in the template. |
(inner) updateAddressDetails()
Checks if there is currently a cart and if one exists, gets the customer address from the httpParameterMap and saves it to the customer address book. Initializes the list of credit cards and calls the start function. If a cart does not already exist, calls the Cart controller Show function.
(inner) updateCreditCardSelection()
Updates credit card information from the httpParameterMap and determines if there is a currently selected credit card. If a credit card is selected, it adds the the credit card number to the billing form. Otherwise, the publicStart method is called. In either case, it will initialize the credit card list in the billing form and call the start function.
(inner) updateSummary()
Updates the order totals and recalculates the basket after a coupon code is applied. Renders the checkout/minisummary template, which includes the mini cart order totals and shipment summary.
(inner) validateBilling() → {boolean}
Validates the billing form.
Returns:
Returns true if the billing address is valid or no payment is needed. Returns false if the billing form is invalid.
- Type
- boolean
(inner) validatePayment(cart) → {Boolean}
Revalidates existing payment instruments in later checkout steps.
Parameters:
Name | Type | Description |
---|---|---|
cart |
module:models/CartModel~CartModel |
A CartModel wrapping the current Basket. |
Returns:
true if existing payment instruments are valid, false if not.
- Type
- Boolean