Skip to content

Commit

Permalink
fix(ivr): address issue preventing cards or bank accounts from being …
Browse files Browse the repository at this point in the history
…validated
  • Loading branch information
hendrickson-tyler committed Aug 20, 2024
1 parent 927564f commit 306ed9b
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 18 deletions.
2 changes: 2 additions & 0 deletions lib/c3-amazon-connect-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class C3AmazonConnectStack extends Stack {
this.tokenizeTransactionFunction,
this.submitPaymentFunction,
this.sendReceiptFunction,
this.validateEntryFunction,
);
}
if (this.featuresContext.agentAssistedIVR) {
Expand All @@ -118,6 +119,7 @@ export class C3AmazonConnectStack extends Stack {
this.tokenizeTransactionFunction,
this.submitPaymentFunction,
this.sendReceiptFunction,
this.validateEntryFunction,
);
}
if (this.featuresContext.subjectLookup) {
Expand Down
12 changes: 12 additions & 0 deletions lib/connect/content-transformations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { IvrSpeakingContext } from '../models';
* @param tokenizeTransactionLambdaArn The Lambda function that tokenizes a transaction.
* @param submitPaymentLambdaArn The Lambda function that submits a payment.
* @param sendReceiptLambdaArn The Lambda function that sends a receipt.
* @param validateEntryLambdaArn The Lambda function that validates the user's entry.
* @param amazonConnectSecurityKeyId The security key ID for Amazon Connect.
* @param amazonConnectSecurityKeyCertificateContent The security key certificate content for Amazon Connect.
* @param amazonConnectReceiptQueueArn The ARN for the Amazon Connect receipt queue.
Expand All @@ -22,6 +23,7 @@ export function getPaymentIVRFlowModuleContent(
tokenizeTransactionLambdaFunction: Function,
submitPaymentLambdaFunction: Function,
sendReceiptLambdaFunction: Function,
validateEntryLambdaFunction: Function,
amazonConnectSecurityKeyId: string,
amazonConnectSecurityKeyCertificateContent: string,
amazonConnectReceiptQueueArn: string,
Expand All @@ -46,6 +48,10 @@ export function getPaymentIVRFlowModuleContent(
/<<sendReceiptLambdaArn>>/g,
sendReceiptLambdaFunction.functionArn,
);
transformedContent = transformedContent.replace(
/<<validateEntryLambdaArn>>/g,
validateEntryLambdaFunction.functionArn,
);

// Replace Amazon Connect security key placeholders with actual values.
transformedContent = transformedContent.replace(
Expand Down Expand Up @@ -90,6 +96,7 @@ export function getPaymentIVRFlowModuleContent(
* @param tokenizeTransactionFunction The Lambda function that tokenizes a transaction.
* @param submitPaymentLambdaFunction The Lambda function that submits a payment.
* @param sendReceiptLambdaFunction The Lambda function that sends a receipt.
* @param validateEntryLambdaFunction The Lambda function that validates the user's entry.
* @param amazonConnectSecurityKeyId The security key ID for Amazon Connect.
* @param amazonConnectSecurityKeyCertificateContent The security key certificate content for Amazon Connect.
* @param ivrSpeakingContext The speaking context for the IVR.
Expand All @@ -101,6 +108,7 @@ export function getSelfServicePaymentIVRFlowContent(
tokenizeTransactionFunction: Function,
submitPaymentLambdaFunction: Function,
sendReceiptLambdaFunction: Function,
validateEntryLambdaFunction: Function,
amazonConnectSecurityKeyId: string,
amazonConnectSecurityKeyCertificateContent: string,
ivrSpeakingContext: IvrSpeakingContext,
Expand Down Expand Up @@ -128,6 +136,10 @@ export function getSelfServicePaymentIVRFlowContent(
/<<sendReceiptLambdaArn>>/g,
sendReceiptLambdaFunction.functionArn,
);
transformedContent = transformedContent.replace(
/<<validateEntryLambdaArn>>/g,
validateEntryLambdaFunction.functionArn,
);

// Replace Amazon Connect security key placeholders with actual values.
transformedContent = transformedContent.replace(
Expand Down
16 changes: 8 additions & 8 deletions lib/connect/flows/c3-agent-assisted-payment-ivr-flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -924,7 +924,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -1005,7 +1005,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -1102,7 +1102,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -2684,7 +2684,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "CardNumber",
Expand Down Expand Up @@ -2793,7 +2793,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "AccountNumber",
Expand Down Expand Up @@ -2902,7 +2902,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "RoutingNumber",
Expand Down Expand Up @@ -3054,7 +3054,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "ExpirationDate",
Expand Down
16 changes: 8 additions & 8 deletions lib/connect/flows/modules/c3-payment-ivr-flow-module.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -782,7 +782,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -897,7 +897,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -978,7 +978,7 @@
"isFriendlyName": true,
"parameters": {
"LambdaFunctionARN": {
"displayName": "C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI"
"displayName": "<<validateEntryLambdaArn>>"
},
"LambdaInvocationAttributes": {
"CustomerEntry": {
Expand Down Expand Up @@ -2409,7 +2409,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "CardNumber",
Expand Down Expand Up @@ -2542,7 +2542,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "AccountNumber",
Expand Down Expand Up @@ -2695,7 +2695,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "RoutingNumber",
Expand Down Expand Up @@ -2804,7 +2804,7 @@
},
{
"Parameters": {
"LambdaFunctionARN": "arn:aws:lambda:us-west-2:815407490078:function:C3AmazonConnectStack-C3ValidateEntry0579D515-hLF7slsKAxyI",
"LambdaFunctionARN": "<<validateEntryLambdaArn>>",
"InvocationTimeLimitSeconds": "8",
"LambdaInvocationAttributes": {
"ValidationType": "ExpirationDate",
Expand Down
2 changes: 2 additions & 0 deletions lib/features/agent-assisted-payment-ivr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export class AgentAssistedPaymentIVR {
private tokenizeTransactionFunction: Function,
private submitPaymentFunction: Function,
private sendReceiptFunction: Function,
private validateEntryFunction: Function,
) {
console.log('Creating resources for agent-assisted IVR payments...');
this.createSendAgentMessageFunction();
Expand Down Expand Up @@ -127,6 +128,7 @@ export class AgentAssistedPaymentIVR {
this.tokenizeTransactionFunction,
this.submitPaymentFunction,
this.sendReceiptFunction,
this.validateEntryFunction,
this.amazonConnectContext.securityKeyId,
this.amazonConnectContext.securityKeyCertificateContent,
optionsContext.ivrSpeaking,
Expand Down
2 changes: 2 additions & 0 deletions lib/features/self-service-payment-ivr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class SelfServicePaymentIVR {
private tokenizeTransactionFunction: Function,
private submitPaymentFunction: Function,
private sendReceiptFunction: Function,
private validateEntryFunction: Function,
) {
console.log('Creating resources for self-service IVR payments...');
this.createFlowModule();
Expand All @@ -41,6 +42,7 @@ export class SelfServicePaymentIVR {
this.tokenizeTransactionFunction,
this.submitPaymentFunction,
this.sendReceiptFunction,
this.validateEntryFunction,
this.amazonConnectContext.securityKeyId,
this.amazonConnectContext.securityKeyCertificateContent,
this.amazonConnectContext.receiptQueueArn,
Expand Down
6 changes: 4 additions & 2 deletions lib/helpers/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export function associateLambdaFunctionsWithConnect(
const instanceArn = stack.node.tryGetContext('amazonConnect').instanceArn;
for (const lambdaFunction of lambdaFunctions) {
// Allow Amazon Connect to invoke the Lambda functions.
console.log('Adding Amazon Connect permissions for function...');
console.log(
`Adding Amazon Connect permissions for function "${lambdaFunction.node.id}"...`,
);
lambdaFunction.addPermission('AllowAmazonConnectInvoke', {
principal: new ServicePrincipal('connect.amazonaws.com'),
sourceArn: instanceArn,
Expand All @@ -63,7 +65,7 @@ export function associateLambdaFunctionsWithConnect(

// Create an integration between the Lambda functions and Amazon Connect.
console.log(
'Creating Amazon Connect integration association for function...',
`Creating Amazon Connect integration association for function "${lambdaFunction.node.id}"...`,
);
new CfnIntegrationAssociation(
stack,
Expand Down
6 changes: 6 additions & 0 deletions scripts/insert-placeholders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ FUNCTION_NAME="C3SubjectLookup"
PLACEHOLDER="<<subjectLookupLambdaArn>>"
sed -i '' "s|\(\"[^\"]*\": \)\".*${FUNCTION_NAME}.*\"|\1\"$PLACEHOLDER\"|g" "$SUBJECT_LOOKUP_FLOW_FILE"

# Replace the ARN of the C3ValidateEntry Lambda function
FUNCTION_NAME="C3ValidateEntry"
PLACEHOLDER="<<validateEntryLambdaArn>>"
sed -i '' "s|\(\"[^\"]*\": \)\".*${FUNCTION_NAME}.*\"|\1\"$PLACEHOLDER\"|g" "$AGENT_ASSISTED_PAYMENT_IVR_FLOW_FILE"
sed -i '' "s|\(\"[^\"]*\": \)\".*${FUNCTION_NAME}.*\"|\1\"$PLACEHOLDER\"|g" "$PAYMENT_IVR_FLOW_MODULE_FILE"

# ---- SECURITY KEY ----

# Replace the security key ID
Expand Down

0 comments on commit 306ed9b

Please sign in to comment.