RTP|One Guide: Validated Prompt Setup

Aspenware Commerce supports validating against a stored procedure in RTP|One when checking out in Aspenware Commerce. When configured, a customer validates they are eligible for a purchase of a particular fenced product either through entering data in a prompt field on the personalize step of checkout, or by only allowing only certain eligible guests to be assigned to a gated product on the PDP or on the Assign step of checkout. This document outlines the setup needed in RTP|One to make this work. Aspenware Commerce configuration can be completed after this is done in RTP|One by following this guide: Configuration: Validated Prompts.

Many varieties of validations are in use on customer sites which validate various pieces of data in RTP|One. These include Access Rules, Voucher Templates, Pass Media Prefixes, etc.

Almost anything in RTP|One can be validated against, but the key to the validation stored procedure is that a 0 needs to be returned to pass validation and a 1 needs to be returned to fail validation. Aspenware will always send the parameters, IPCode, ProductHeaderCode, PromptData, PromptCode, and ProductStartDate but these can either be used or not for the validation stored procedure.

The setup includes deploying the validated stored procedure to the RTPOne/RTPOneTest database, a new Rule and Prompt in RTP|One Admin, and a Product Prompt in Aspenware.

Detailed Setup Guide

  1. Create a new Rule in RTP|One Administration like below.

    1. General Tab

      1. Name and Keyword – set to the same upper case description

      2. Description – this description shows in when adding the Rule to the Prompt

      3. Rule Type: Stored Procedure

      4. XML Map: None

      5. Data Type: String

      6. Compare Type: None

      7. Stored Proc. Name: description of stored procedure

         

    2. Entities Tab

      1. Add: RTP.Enterprise.Framework.BLL.Prompt

         

    3. Rule Parameters Tab (*the Parameter descriptions must match exactly) - Add appropriate Object XML Map entry

      1. Add Line Item IPCode and enter: IPCode

      2. Add Line Item Product Header Code and enter: ProductHeaderCode

      3. Add Prompt Data and enter: PromptData

      4. Add Prompt Code and enter: PromptCode

      5. Add Line Item Product Date and enter: ProductStartDate

         

  2. Create a new Prompt in RTP Admin

    1. General Tab:

      1. Enter any Code, Display Order, Description, Display Caption and Security Level (recommend 0)

      2. Validate Stored Procedure: enter KEYWORD from Rule

         

    2. Rules tab: Add new Rule

       

  3. Create a customer stored procedure. Below is an example where the assigned customer in check-out is being validated along with whether the VoucherID entered was created in RTP with VoucherTypeCode 123.  The validation portion of the stored procedure (in red below) can be customized to validate anything in RTP.  As long as a 0 is returned in the stored procedure results, the validation will succeed online.  If a 1 is returned, it will fail validation.  After deploying the stored procedure, you must GRANT EXECUTE privileges to the RTPOneRole or Unity role.

CREATE PROCEDURE [dbo].[AW_EcommValidatedPromptVoucherType123]--GRANT EXECUTE ON [dbo].[AW_EcommValidatedPromptVoucherType123] TO [RTPOneRole](@SessionToken nvarchar(32)='', -- Required@PromptData nvarchar(255)='', -- Required@PromptCode nvarchar(32)=-1, --Required@ProductHeaderCode nvarchar(32) = '',@IPCode nvarchar(32)=-1, --Required,@ProductStartDate DATE = '')ASBEGINset nocount onDECLARE @i_OperatorID nvarchar(255)DECLARE @i_ReturnMessage nvarchar(255)DECLARE @i_ReturnValue intDECLARE @i_SeedValue intDECLARE @i_ReturnCode intDECLARE @i_EligibilityInd char(1)SET @SessionToken = LTRIM(RTRIM(@SessionToken))SET @PromptData = LTRIM(RTRIM(@PromptData))SET @PromptCode = LTRIM(RTRIM(@PromptCode))SET @IPCode = LTRIM(RTRIM(@IPCode))SET @ProductHeaderCode = LTRIM(RTRIM(@ProductHeaderCode))-- Verify SessionSELECT @i_OperatorID = AuthenticationIDFROM dbo.UserSession WITH (NOLOCK)WHERE SessionToken = @SessionTokenIF @@ROWCOUNT = 0BEGINSET @i_ReturnMessage = 'Error: The User Session is not valid.'RAISERROR (@i_ReturnMessage, 16, 1)RETURN @@ERROREND--Validate VoucherType 123IF EXISTS( SELECT 0FROM dbo.Voucher vJOIN VoucherRecipient vrON v.VoucherID = vr.VoucherIDAND vr.RecipientIPCode = @IPCodeJOIN VoucherType vtON v.VoucherTypeCode = vt.VoucherTypeCodeAND v.VoucherStatusCode = 1and vt.VoucherTypeCode = 123AND v.VoucherID = @PromptData)BEGINSELECT 0 AS Code,'Valid' AS TextRETURNEND--Catch-allBEGINSELECT 1 AS Code,'Invalid' AS TextRETURNENDRETURN @@ERROREND
  1. CREATE PROCEDURE [dbo].[AW_EcommValidatedPromptVoucherType123]
    --GRANT EXECUTE ON [dbo].[AW_EcommValidatedPromptVoucherType123] TO [RTPOneRole]
    (
    @SessionToken nvarchar(32)='', -- Required
    @PromptData nvarchar(255)='', -- Required
    @PromptCode nvarchar(32)=-1, --Required
    @ProductHeaderCode nvarchar(32) = '',
    @IPCode nvarchar(32)=-1, --Required,
    @ProductStartDate DATE = ''
    )
    AS
    BEGIN
    set nocount on
    DECLARE @i_OperatorID nvarchar(255)
    DECLARE @i_ReturnMessage nvarchar(255)
    DECLARE @i_ReturnValue int
    DECLARE @i_SeedValue int
    DECLARE @i_ReturnCode int
    DECLARE @i_EligibilityInd char(1)
    SET @SessionToken = LTRIM(RTRIM(@SessionToken))
    SET @PromptData = LTRIM(RTRIM(@PromptData))
    SET @PromptCode = LTRIM(RTRIM(@PromptCode))
    SET @IPCode = LTRIM(RTRIM(@IPCode))
    SET @ProductHeaderCode = LTRIM(RTRIM(@ProductHeaderCode))
    -- Verify Session
    SELECT @i_OperatorID = AuthenticationID
    FROM dbo.UserSession WITH (NOLOCK)
    WHERE SessionToken = @SessionToken
    IF @@ROWCOUNT = 0
    BEGIN
    SET @i_ReturnMessage = 'Error: The User Session is not valid.'
    RAISERROR (@i_ReturnMessage, 16, 1)
    RETURN @@ERROR
    END
    --Validate VoucherType 123
    IF EXISTS
    ( SELECT 0
    FROM dbo.Voucher v
    JOIN VoucherRecipient vr
    ON v.VoucherID = vr.VoucherID
    AND vr.RecipientIPCode = @IPCode
    JOIN VoucherType vt
    ON v.VoucherTypeCode = vt.VoucherTypeCode
    AND v.VoucherStatusCode = 1
    and vt.VoucherTypeCode = 123
    AND v.VoucherID = @PromptData
    )
    BEGIN
    SELECT 0 AS Code,
    'Valid' AS Text
    RETURN
    END
    --Catch-all
    BEGIN
    SELECT 1 AS Code,
    'Invalid' AS Text
    RETURN
    END
    RETURN @@ERROR
    END