Translate from C# to ABL

hugoyamil

New Member
I received an C# DLL to access an API and another C# to invoke the DLL.

I'm trying to make an ABL program to INVOKE the DLL.

Ive tried the USING, also run it as an EXTERNAL but no luck.

Never used C#, but it looks like a very simple program can't find how to instatiate the DLL from ABL.

Thanks in advance,

Hugo

Here is the C# code, will appreciate any help
==============================================================================
Code:
using System;
using System.Windows.Forms;

namespace CayanConnectSample
{
    public partial class MainFrm : Form
    {
        public MainFrm()
        {
            InitializeComponent();
        }

        private string merchantName = "Test Dynamic Payments";
        private string merchantSiteId = "2Q5JSJH3";
        private string merchantKey = "GQPXT-GTJTP-66A1Y-RWT5G-CNULU";
        private string terminalIPAddress = "192.168.1.32"; //ip address in CDI Technologies
        private int requestTimeout = 60;

        private void btnCreateTransaction_Click(object sender, EventArgs e)
        {

            decimal amount = Convert.ToDecimal(0.09);
            string clerkId = "MIKE";

            //only transactionType used are sale & refund
            CayanConnect.CreateTransaction.Request request = new CayanConnect.CreateTransaction.Request()
            {
                MerchantName = merchantName,
                MerchantSiteId = merchantSiteId,
                MerchantKey = merchantKey,
                TransactionType = CayanConnect.CreateTransaction.TransactionTypeEnum.SALE,
                ClerkId = clerkId,
                Dba = merchantName,
                Amount = amount,
                //[Amount] is always positive.  TransactionType has the sign.  Sale or Refund
                OrderNumber = "1234"
            };

            CayanConnect.CreateTransaction createTrx = new CayanConnect.CreateTransaction();

            CayanConnect.CreateTransaction.Response ctr = createTrx.Process(request, CayanConnect.ThemeEnum.None);

            if (ctr.Success)
            {
                CayanConnect.InitiateTransaction it = new CayanConnect.InitiateTransaction(terminalIPAddress, ctr.TransportKey, null, CayanConnect.ThemeEnum.None, "Waiting for customer...");

                CayanConnect.InitiateTransaction.Response response = it.Process(requestTimeout, true);

                string emvDetail = response.EMVDetail;
                bool approved = false;


                if (response.Success)
                {
                    //THERE IS NO TIMEOUT OR ERROR CALLING THE SERVICE
                    if (response.Status.ToUpper() == "APPROVED")
                    {
                        //AN AMOUNT HAS BEEN APPROVED
                        if (Convert.ToDecimal(Math.Abs(amount)) == response.AmountApproved)
                        {
                            //FULL AMOUNT APPROVED
                            approved = true;
                            txtResponse.Text = "Good to go!!";
                        }
                        else
                        {
                            //PARTIALLY APPROVED, HAS TO VOID THIS
                            string v = this.VoidApprovedTransaction(response.Token);
                            string em = v.IsEmpty() ? "Transaction was voided succesfully." : v;
                            txtResponse.Text = $"Invalid approved amount.{Environment.NewLine}Amount: {amount.ToString("C")}{Environment.NewLine}Approved Amount: {response.AmountApproved.ToString("c")}{em}";
                        }
                    }
                    else
                    {
                        //AMOUNT WAS DECLINED
                        txtResponse.Text = response.DeclinedMessage(amount);
                    }
                }
                else
                {
                    //THERE WAS A PROBLEM CALLING THE SERVICE
                    txtResponse.Text = response.ErrorMessage;
                }
            }
            else
            {
                //THERE WAS A PROBLEM CALLING THE SERVICE
                txtResponse.Text = ctr.ErrorMessage;
            }
        }
        private string GetStatus()
        {
            string rt = string.Empty;

            CayanConnect.GetStatus status = new CayanConnect.GetStatus(this.terminalIPAddress, null, CayanConnect.ThemeEnum.None, "Verifying terminal status...");
            CayanConnect.GetStatus.Response statusResponse = status.Process(this.requestTimeout);

            rt = statusResponse.ToXml();

            return rt;
        }
        private string VoidApprovedTransaction(string token)
        {
            string rt = string.Empty;

            CayanConnect.Void _void = new CayanConnect.Void();

            CayanConnect.Void.Request request = new CayanConnect.Void.Request()
            {
                MerchantName = this.merchantName,
                MerchantKey = this.merchantKey,
                MerchantSiteId = this.merchantSiteId,
                Token = token,
                Timeout = this.requestTimeout
            };

            CayanConnect.Void.Response response = _void.Process(request, CayanConnect.ThemeEnum.None);

            if (!response.Success)
            {
                rt = $"Error voiding transaction.{Environment.NewLine}{Environment.NewLine}{response.ErrorMessage}";
            }

            return rt;
        }

        private void btnIsOnLine_Click(object sender, EventArgs e)
        {
            txtResponse.Text = GetStatus();
        }
    }
}
============================================================================
 
Last edited:

Cringer

ProgressTalk.com Moderator
Staff member
I think you need to add the dll to your assemblies.xml and add
USING dllname FROM ASSEMBLY.
to your ABL.
 

hugoyamil

New Member
Hi Cringer,

1 Progress 11.7.4 OPENEDGE
2 Windows 2016

3
USING CayanConnect.*.

DEFINE VARIABLE CreateTransaction AS CLASS CayanConnect.CreateTransaction.
CreateTransaction = NEW CayanConnect.CreateTransaction.

4
1570621502703.png
 
Last edited:

hugoyamil

New Member
This DLL is to access Merchants Credit Cards processing software.

I was able to run the C# program with the Software's Vendor and it works fine.

if I can use this DLL Wont have to create a new API to the service directly.
 

Osborne

Active Member
As Cringer posted, have you added to assemblies.xml?

For a quick start try the following:
  1. Place the .dll files in the Progress/Project working directory - MESSAGE SESSION:TEMP-DIRECTORY VIEW-AS ALERT-BOX.
  2. As per this site - OpenEdge 11.7 Documentation - add all the .dll files via the "Local Assemblies" tab.
  3. Save the assemblies.xml in the same directory as the .dll files and quit Assembly References. You may need to restart the session so these will be picked up.
  4. Try writing a line of code such as DEFINE VARIABLE CreateTransaction AS CayanConnect.CreateTransaction NO-UNDO. and then checking syntax. If you get this error it means Progress is not referencing the components:
Invalid datatype specified: CayanConnect.CreateTransaction. Specify a datatype such as 'character' or the name of a class. (5638)
** Could not understand line 1. (196)

If no error then Progress can work with the dll and so hopefully this will get you started.
 

hugoyamil

New Member
Thank You Osborne

I first tried with just the define statement and gave me the error.

I created the assemblies.xml with the tools, and now no error appears.

so it looks it should work now, I'll go now with the rest of the code.

Thanks again

Hugo
 

Cecil

19+ years progress programming and still learning.
Can you provided us with a link the developers SDK for the product that you are trying to interface with.
Some of these SDK .dll are just wrappers for SOAP services. If that the case you might be able to by-pass the .dll and consume the SOAP services directly. More information required.
 

hugoyamil

New Member
Thanks, Cecil

Yes, what you say is correct. This program is a wrapper to run the WEBService, thinking it would be much easier to consume.

we do not have experience running WebServices, but eager to learn, but also a short time to implement.

Have read the WEBService specs, but seams not friendly on how to connect to service and execute calls.

Seems to be SOAP, but can't find a WSDL file on documentation, although I see it uses XML for the protocol.

Here is the link of documentation: send you link by email PROGRESSTALK is banning it.

CREATED SPACE ON LINK because gave me error sending thinking it was a suspicious link


Thanks in advance

Hugo
 

Cringer

ProgressTalk.com Moderator
Staff member
I've updated your post to show the link correctly. I've also liked some of your posts meaning you should now have enough reputation to post links yourself as well.
 

Cecil

19+ years progress programming and still learning.
Try doing the following from a proenv shell
bprowsdldoc https://transport.merchantware.net/v4/transportService.asmx?wsdl

This should get you started in creating a "stage transaction" request. Then the next step (step 2) it looks like you need to send a GET request direct to the terminal to Initiate the Transaction. This is where you can use the OpenEdge.Net.HTTP.HttpClient .

Also, I was unable to find the SDK download to install the .NET assembler file(s). I do have a feeling that .NET class objects are multi-threaded which will cause you problems.


Found the XSD for the GENIUS terminal device returns:
TSYS-Merchant/developer-docs
 
Last edited:

Cecil

19+ years progress programming and still learning.
Using the ABL DoJo I was able to create a mock code on how to consume the TSYS SOAP services.
ABL Dojo
 
Last edited:

Cecil

19+ years progress programming and still learning.
Code:
DEFINE VARIABLE hWebService AS HANDLE NO-UNDO.
DEFINE VARIABLE hTransportServiceSoap AS HANDLE NO-UNDO.

CREATE SERVER hWebService.

hWebService:CONNECT("-WSDL 'https://transport.merchantware.net/v4/transportService.asmx?wsdl'
                     -Port TransportServiceSoap12").

RUN TransportServiceSoap SET hTransportServiceSoap ON hWebService.

DEFINE VARIABLE merchantName AS CHARACTER NO-UNDO.
DEFINE VARIABLE merchantSiteId AS CHARACTER NO-UNDO.
DEFINE VARIABLE merchantKey AS CHARACTER NO-UNDO.

DEFINE TEMP-TABLE request NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD TransactionType AS CHARACTER
    FIELD Amount AS DECIMAL
    FIELD ClerkId AS CHARACTER
    FIELD OrderNumber AS CHARACTER
    FIELD Dba AS CHARACTER
    FIELD SoftwareName AS CHARACTER
    FIELD SoftwareVersion AS CHARACTER
    FIELD AddressLine1 AS CHARACTER
    FIELD Zip AS CHARACTER
    FIELD Cardholder AS CHARACTER
    FIELD LogoLocation AS CHARACTER
    FIELD RedirectLocation AS CHARACTER
    FIELD TransactionId AS CHARACTER
    FIELD ForceDuplicate AS LOGICAL
    FIELD CustomerCode AS CHARACTER
    FIELD PoNumber AS CHARACTER
    FIELD TaxAmount AS DECIMAL
    FIELD EntryMode AS CHARACTER
    FIELD AuthorizationCode AS CHARACTER
    FIELD TerminalId AS CHARACTER
    FIELD EnablePartialAuthorization AS LOGICAL .

DEFINE TEMP-TABLE DisplayColors NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD ScreenBackgroundColor AS CHARACTER
    FIELD ContainerBackgroundColor AS CHARACTER
    FIELD ContainerFontColor AS CHARACTER
    FIELD ContainerHelpFontColor AS CHARACTER
    FIELD ContainerBorderColor AS CHARACTER
    FIELD LogoBackgroundColor AS CHARACTER
    FIELD LogoBorderColor AS CHARACTER
    FIELD TooltipBackgroundColor AS CHARACTER
    FIELD TooltipBorderColor AS CHARACTER
    FIELD TooltipFontColor AS CHARACTER
    FIELD TextboxBackgroundColor AS CHARACTER
    FIELD TextboxBorderColor AS CHARACTER
    FIELD TextboxFocusBackgroundColor AS CHARACTER
    FIELD TextboxFocusBorderColor AS CHARACTER
    FIELD TextboxFontColor AS CHARACTER
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE DisplayOptions NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD AlignLeft AS LOGICAL
    FIELD NoCardNumberMask AS LOGICAL
    FIELD HideDetails AS LOGICAL
    FIELD HideDowngradeMessage AS LOGICAL
    FIELD HideMessage AS LOGICAL
    FIELD HideTooltips AS LOGICAL
    FIELD UseNativeButtons AS LOGICAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE HealthCareAmountDetails NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD CopayAmount AS DECIMAL
    FIELD ClinicalAmount AS DECIMAL
    FIELD DentalAmount AS DECIMAL
    FIELD HealthCareTotalAmount AS DECIMAL
    FIELD PrescriptionAmount AS DECIMAL
    FIELD VisionAmount AS DECIMAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE LoyaltyAmountDetails NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD EligibleAmount AS DECIMAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE TipDetails NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD EligibleAmount AS DECIMAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE Invoice NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD TaxIndicator AS CHARACTER
    FIELD ProductDescription AS CHARACTER
    FIELD DiscountAmount AS DECIMAL
    FIELD ShippingAmount AS DECIMAL
    FIELD DutyAmount AS DECIMAL
    FIELD DestinationPostalCode AS CHARACTER
    FIELD DestinationCountryCode AS CHARACTER
    FIELD ShipFromPostalCode AS CHARACTER
    FIELD AlternateTaxAmount AS DECIMAL
    FIELD AlternateTaxRate AS DECIMAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE LineItems NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD Invoice_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE LineItem NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD CommodityCode AS CHARACTER
    FIELD Description AS CHARACTER
    FIELD Upc AS CHARACTER
    FIELD Quantity AS DECIMAL
    FIELD UnitOfMeasure AS CHARACTER
    FIELD UnitCost AS DECIMAL
    FIELD DiscountAmount AS DECIMAL
    FIELD TotalAmount AS DECIMAL
    FIELD TaxAmount AS DECIMAL
    FIELD ExtendedAmount AS DECIMAL
    FIELD DebitOrCreditIndicator AS CHARACTER
    FIELD NetOrGrossIndicator AS CHARACTER
    FIELD LineItems_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE EbtAmountDetails NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD SnapAmount AS DECIMAL
    FIELD SnapTaxAmount AS DECIMAL
    FIELD request_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE DATASET requestDset NAMESPACE-URI "http://transport.merchantware.net/v4/"
    XML-NODE-TYPE "HIDDEN"
    FOR request, DisplayColors, DisplayOptions, HealthCareAmountDetails, LoyaltyAmountDetails, TipDetails, Invoice, LineItems, LineItem, EbtAmountDetails
    PARENT-ID-RELATION RELATION1 FOR request, DisplayColors
        PARENT-ID-FIELD request_id
        PARENT-FIELDS-BEFORE (TransactionType,Amount,ClerkId,OrderNumber,Dba,SoftwareName,SoftwareVersion,AddressLine1,Zip,Cardholder,LogoLocation,RedirectLocation,TransactionId,ForceDuplicate,CustomerCode,PoNumber,TaxAmount)
    PARENT-ID-RELATION RELATION2 FOR request, DisplayOptions
        PARENT-ID-FIELD request_id
        PARENT-FIELDS-AFTER (EntryMode,AuthorizationCode,TerminalId)
    PARENT-ID-RELATION RELATION3 FOR request, HealthCareAmountDetails
        PARENT-ID-FIELD request_id
        PARENT-FIELDS-AFTER (EnablePartialAuthorization)
    PARENT-ID-RELATION RELATION4 FOR request, LoyaltyAmountDetails
        PARENT-ID-FIELD request_id
    PARENT-ID-RELATION RELATION5 FOR request, TipDetails
        PARENT-ID-FIELD request_id
    PARENT-ID-RELATION RELATION6 FOR LineItems, LineItem
        PARENT-ID-FIELD LineItems_id
    PARENT-ID-RELATION RELATION7 FOR Invoice, LineItems
        PARENT-ID-FIELD Invoice_id
    PARENT-ID-RELATION RELATION8 FOR request, Invoice
        PARENT-ID-FIELD request_id
    PARENT-ID-RELATION RELATION9 FOR request, EbtAmountDetails
        PARENT-ID-FIELD request_id.

DEFINE TEMP-TABLE CreateTransactionResult NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD TransportKey AS CHARACTER
    FIELD ValidationKey AS CHARACTER .

DEFINE TEMP-TABLE Messages NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    FIELD CreateTransactionResult_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE TEMP-TABLE Message1 NO-UNDO
    NAMESPACE-URI "http://transport.merchantware.net/v4/"
    XML-NODE-NAME "Message"
    FIELD Field1 AS CHARACTER
        XML-NODE-NAME "Field"
    FIELD Information AS CHARACTER
    FIELD Messages_id AS RECID
        XML-NODE-TYPE "HIDDEN" .

DEFINE DATASET CreateTransactionResultDset NAMESPACE-URI "http://transport.merchantware.net/v4/"
    XML-NODE-TYPE "HIDDEN"
    FOR CreateTransactionResult, Messages, Message1
    PARENT-ID-RELATION RELATION1 FOR Messages, Message1
        PARENT-ID-FIELD Messages_id
    PARENT-ID-RELATION RELATION2 FOR CreateTransactionResult, Messages
        PARENT-ID-FIELD CreateTransactionResult_id.


ASSIGN
merchantName = "Test Dynamic Payments"
merchantSiteId = "2Q5JSJH3"
merchantKey = "GQPXT-GTJTP-66A1Y-RWT5G-CNULU".


RUN CreateTransaction IN hTransportServiceSoap(INPUT merchantName, INPUT merchantSiteId, INPUT merchantKey, INPUT DATASET requestDset, OUTPUT DATASET CreateTransactionResultDset).

FOR EACH CreateTransactionResult:
    display CreateTransactionResult.
END.


for each Message1:

    display Message1.
end.
 
Top