Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Gift certificate redemption

Gift certificate redemption

This feature allows customers to redeem gift certificates during the checkout process. If multiple gift certificates are used for the same order, the gift certificate with the least balance will be consumed first.

Key classes, files and methods

  • GiftCertificatePaymentGatewayImpl.java - Payment gateway for Gift Certificate.
  • GiftCertificatePaymentGatewayImplTest.java - Unit test class.
  • GiftCertificateCurrencyMismatchException.java - Extending EpDomainException. This is thrown when Gift Certificate Currency and shopping cart currency does not match.
  • GiftCertificateZeroBalanceException.java - Extending EpDomainException. This is thrown when Gift Certificate balance is zero.

Changes to accommodate gift certificate redemption

  • Added textbox to apply GC or promo code in viewCart.vm
  • onSubmit method of ShoppingCartControllerImpl has been changed to checks condition action.equals(APPLY_CODE) and use applyGiftCertificateRedeem method
  • BillingAndReview.vm has been changed to check for amount more than GC value - if so, only then show Credit Card to be used for payment
  • displayOrderSummary and displayCartSummary macros in VM_global_library.vm has been changed to show GC redeem if applicable

How it works

  1. User enters GC code in textbox in viewCart.vm
  2. The GC code entered is passed to ShoppingCartControllerImpl.java, where it is verified for GC Code existence in database then pass GC Code to applyGiftCertificateRedeem
  3. applyGiftCertificateRedeem adds GC to giftCertificateRedeem TreeSet
  4. Or in case GC balance is zero or currency mismatch throw Exception
  5. The Exception is caught in ShoppingCartControllerImpl.java and set the session attributes WebConstants.GC_ZERO_BALANCE or WebConstants.GC_CURRENCY_MISMATCH
  6. viewCart.vm session attributes and if true then display message otherwise GC discount and Total less the GC discount
  7. In checkout process GiftCertificatePaymentGatewayImpl method preAuthorize check balance, set reserve amount and change balance to new balance. Captures the funds in capture method.