web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Payment Gateway API Call

(0) ShareShare
ReportReport
Posted on by

Dear NAV guru,

Have any of you tried writing a code to send payment request to Payment Gateway through REST API?

The idea is to click a button in NAV on the customer ledger entries page to charge customer on a particular invoice and this will send a request to the payment gateway to charge the customer.


I would love to use dynamicsonline however Australia is not in the list of countries that the service is available.

Regards,


Susy

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Andrey Baludin Profile Picture
    3,941 on at

    Hi Susy.

    You need some .Net for it.

    For example:

    LOCAL PROCEDURE SendRequest@1000000001();
        VAR
          _HttpWebRequest@1000000001 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.HttpWebRequest" RUNONCLIENT;
          _WebResponse@1000000002 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Net.WebResponse" RUNONCLIENT;
          _XMLRequestDoc@1000000004 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument" RUNONCLIENT;
          _XMLElement@1000000007 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlElement" RUNONCLIENT;
          _XMLNode@1000000010 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode" RUNONCLIENT;
          _XMLResponseDoc@1000000006 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument" RUNONCLIENT;
          _MemoryStream@1000000005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.MemoryStream" RUNONCLIENT;
        BEGIN
          CLEAR(_HttpWebRequest);
          CLEAR(_MemoryStream);
          CLEAR(_WebResponse);
          CLEAR(_XMLElement);
          CLEAR(_XMLNode);
          CLEAR(_XMLRequestDoc);
          CLEAR(_XMLResponseDoc);
    
          _XMLRequestDoc := _XMLResponseDoc.XmlDocument;
    
          _XMLElement := _XMLRequestDoc.CreateElement('ROOT');
    
          _XMLNode := _XMLRequestDoc.CreateElement('myrequest');
          _XMLNode.InnerText := 'request text';
          _XMLElement.AppendChild(_XMLNode);
    
          _XMLRequestDoc.AppendChild(_XMLElement);
    
          _HttpWebRequest := _HttpWebRequest.Create('paste api url here');
          _HttpWebRequest.Timeout := 30000;
          _HttpWebRequest.UseDefaultCredentials(TRUE);
          _HttpWebRequest.Method := 'POST';
          _HttpWebRequest.ContentType := 'application/xml';
          _HttpWebRequest.Accept := 'application/xml';
          _MemoryStream := _HttpWebRequest.GetRequestStream;
          _XMLRequestDoc.Save(_MemoryStream);
          _MemoryStream.Flush;
          _MemoryStream.Close;
    
          _WebResponse := _HttpWebRequest.GetResponse;
          _MemoryStream := _WebResponse.GetResponseStream;
          _XMLResponseDoc := _XMLResponseDoc.XmlDocument;
          _XMLResponseDoc.Load(_MemoryStream);
          _MemoryStream.Flush;
          _MemoryStream.Close;
        END;


    This way you'll get Response XML in _XMLResponseDoc object and you could parse it to get the needed data.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    Please check 1297, 1298 and 1290 codeunits for how to call REST API. Are you trying to write a custom moduel to send the payment information to the payment gateway ? If so , you need to consider PCI Compliance, security....

    You can check for add-ons which provides these services.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans