PAN Verification Activity - NeoSOFT-Technologies/workflow-plugins GitHub Wiki
PAN Verification Activity verifies the PAN Number.
The PanVerification class under Activities folder will look like:
using Elsa.ActivityResults;
using Elsa.Attributes;
using Elsa.Expressions;
using Elsa.Server.IServices;
using Elsa.Server.Models.Sandbox;
using Elsa.Services;
using Elsa.Services.Models;
using System;
using System.Threading.Tasks;
namespace Elsa.Server.Activities
{
[Action(
Category = "Custom",
DisplayName = "PAN Verification",
Description = "Verify PAN Number",
Outcomes = new[] { "Success", "Failed" }
)]
public class PanVerification : Activity
{
private readonly ISandboxService _sandboxService;
public PanVerification(ISandboxService sandboxService)
{
_sandboxService = sandboxService;
}
[ActivityInput(
Label = "PAN Number",
Hint = "PAN Number to verify",
SupportedSyntaxes = new [] { SyntaxNames.Literal, SyntaxNames.Liquid, SyntaxNames.JavaScript }
)]
public string PanNumber { get; set; }
[ActivityInput(
Label = "Consent",
Hint = "Y if you have consent from PAN Card Holder",
SupportedSyntaxes = new[] { SyntaxNames.Literal, SyntaxNames.Liquid, SyntaxNames.JavaScript }
)]
public string Consent { get; set; }
[ActivityInput(
Label = "Reason",
Hint = "Reason for PAN Card Verification",
SupportedSyntaxes = new[] { SyntaxNames.Literal, SyntaxNames.Liquid, SyntaxNames.JavaScript }
)]
public string Reason { get; set; }
[ActivityOutput(
Hint = "PAN Verification Response"
)]
public PanBasicData Output { get; set; } = default!;
protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
{
AuthenticateResponse authenticateResponse = await _sandboxService.AuthenticateAsync();
VerifyPanRequest request = new VerifyPanRequest()
{
PanNumber = PanNumber,
Consent = Consent,
Reason = Reason
};
BaseResponse<PanBasicData> response = await _sandboxService.VerifyPanAsync(request, authenticateResponse.Access_token);
Output = response.Data;
if (Output is not null && Output.Status.ToLower().Equals("valid"))
{
return Outcome("Success");
}
else
{
return Outcome("Failed");
}
}
}
}
Activities can have properties. These properties can be made available to visual workflow composers by annotating them with ActivityInputAttribute and ActivityOutputAttribute.
These attributes have more properties:
- Name: Controls the technical name of the property.
- Label: Controls the display text when rendering this property on a form in the activity editor.
- Hint: Controls the hint text displayed underneath the field editor in the activity editor.
- SupportedSyntaxes: Controls what syntaxes are available to use when specifying a value for this property through the activity editor.
The results of this activity after executing the request are as shown below: