Solution Design for Auto-Ship: Credit Card missing from new Auto-Ship

Preferred Solution

For Web

  1. Upon line record creation, save a JSON string value of the user’s selected card into a custom field
  2. Card info needed:
    1. Card Brand
    2. Last Four Digits
    3. Expiration Date
  3. Format of the field:
    1. “[CUSTOMER_ID]-[BRAND]-[LAST_FOUR]-[EXP_DATE]”
    2. E.g. “0283759-Mastercard-4242-06/25” <<< Line Record will have this on a field like TOKEN LOOKUP KEY
  4. Also affects Create, Resume, Edit of Autoship where the option to select payment card is available – to make sure the custom field is updated

For ERP

  1. Create a User Event script that will be triggered when a new Payment Instrument record of type Payment Card Token is created
  2. Capture the following details of the newly created card token
    1. Customer ID
    2. Card Token Internal ID
      1. Card Brand
      2. Last Four Digits
      3. Expiration Date
    3. Logic in the User Event will take the above fields and construct a string like this:
      1. “0283759-Mastercard-4242-06/25”
      2. function generateLookupKey(customerId, brand, lastFour, expDate) => “0283759-Mastercard-4242-06/25”
  1. Search for the Customer’s active line records with empty Payment Card Token (custrecord_vv_payment_card_token) field
    1. Set the Card Token Internal ID to this field if it matches the card info saved on the custom field created from web (see above)

Note: we expect the Auto-Ship map/reduce to automatically pick up and copy the card token lookup fields when creating the next generation of line records.

Fallback Solution

Fallback solution was drafted due to initial design concerns around the above solution. Notes below:

  • Originally we discussed triggering the card search and replace logic on delete of Payment Instrument of type Credit Card
  • We considered this uncertain because of a possible race condition: what if the token was not saved in the system at the time the afterSubmit fired on credit card deletion?
  • We adjusted our solution to fire on create of the token to eliminate the possibility of the race condition
  • Therefore we do not expect to use this fallback solution
  • Use scheduled process in the searching and replace logic instead of the above approach
  • VV | Auto Ship Rx Status Change | MR we utilize this script to see all those active line records that have an empty Card detail field.

Downside/Risk, there is a gap in time when card is deleted and when it was replaced with the new reference of the token card

Leave a comment

Your email address will not be published. Required fields are marked *