Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Adyen HMAC Signature Calculation for Hosted Payment PagesDemonstrates how to do the HMAC Signature Calculation for a hosted payment page (HPP) in Adyen. For a C# ASP.NET Razor Pages example showing the HTML Form with HMAC signature code, see Adyen HMAC Signature Calculation in C# For more information, see https://docs.adyen.com/classic-integration/hosted-payment-pages/hmac-signature-calculation/
integer li_rc integer li_Success string ls_StrHtml oleobject loo_Gzip string ls_GzOrderData oleobject loo_Xml string ls_SessionValidity string ls_CountryCode string ls_ShopperLocale string ls_MerchantReference string ls_MerchantAccount string ls_PaymentAmount string ls_CurrencyCode string ls_SkinCode string ls_ShopperReference string ls_ShopperEmail string ls_ShipBeforeDate oleobject loo_SbTags oleobject loo_SbValues oleobject loo_SbContent integer n integer i integer li_NumReplaced oleobject loo_SbSigningStr oleobject loo_Crypt string ls_HmacKey string ls_MerchantSig // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. ls_StrHtml = "<table class=~"od~"><tr><th>Description</th><th>Quantity</th><th>Amount</th></tr><tr><td>1 Digital Camera</td><td class=~"r~">1</td><td class=~"r~">100 GBP</td></tr><tr><td class=~"b~">Total</td><td class=~"r~"></td><td class=~"b r~">100.00 GBP</td></tr></table>" loo_Gzip = create oleobject // Use "Chilkat_9_5_0.Gzip" for versions of Chilkat < 10.0.0 li_rc = loo_Gzip.ConnectToNewObject("Chilkat.Gzip") if li_rc < 0 then destroy loo_Gzip MessageBox("Error","Connecting to COM object failed") return end if ls_GzOrderData = loo_Gzip.CompressStringENC(ls_StrHtml,"utf-8","base64") loo_Xml = create oleobject // Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0 li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml") loo_Xml.Tag = "keyValuePairs" loo_Xml.NewChild2("orderData",ls_GzOrderData) // required, The payment deadline; the payment needs to occur within the specified time value. ls_SessionValidity = "2019-08-11T10:30:00Z" loo_Xml.NewChild2("sessionValidity",ls_SessionValidity) // optional. Normally we'll let Adyen automatically know the country based on the IP address. // By default, the payment methods offered to a shopper are filtered based on the country the shopper's IP address is mapped to. // In this way, shoppers are not offered payment methods that are not available in the country they are carrying out the transaction from. // This IP-to-country mapping is not 100% accurate, so if you have already established the country of the shopper, you can set it explicitly // in the countryCode parameter. ls_CountryCode = "GB" loo_Xml.NewChild2("countryCode",ls_CountryCode) // optional ls_ShopperLocale = "en_GB" // If not specified, the locale preference is set to en_GB by default. // When it is not necessary to include the country-specific part, use only the language code. // For example: it instead of it_IT to set the locale preferences to Italian. loo_Xml.NewChild2("shopperLocale",ls_ShopperLocale) // required, A reference to uniquely identify the payment. This reference is used in all communication with you about the payment status. // We recommend using a unique value per payment; however, it is not a requirement. If you need to provide multiple references for a transaction, // you can enter them in this field. Separate each reference value with a hyphen character ("-"). This field has a length restriction: // you can enter max. 80 characters. ls_MerchantReference = "paymentTest1234" loo_Xml.NewChild2("merchantReference",ls_MerchantReference) // required, The merchant account identifier you want to process the (transaction) request with. ls_MerchantAccount = "ChilkatSoftwareIncCOM" loo_Xml.NewChild2("merchantAccount",ls_MerchantAccount) // required. 10000 for $100.00 ls_PaymentAmount = "10000" loo_Xml.NewChild2("paymentAmount",ls_PaymentAmount) // required, The three-character ISO currency code ls_CurrencyCode = "GBP" loo_Xml.NewChild2("currencyCode",ls_CurrencyCode) // required. ls_SkinCode = "S7uWsvfB" loo_Xml.NewChild2("skinCode",ls_SkinCode) // optional, A unique identifier for the shopper, for example, a customer ID. // We recommend providing this information, as it is used in velocity fraud checks. It is also the key in recurring payments. // This field is mandatory in recurring payments. ls_ShopperReference = "somebody@example.com" loo_Xml.NewChild2("shopperReference",ls_ShopperReference) // optional ls_ShopperEmail = "somebody@example.com" loo_Xml.NewChild2("shopperEmail",ls_ShopperEmail) // optional, An integer value that adds up to the normal fraud score. // The value can be either a positive or negative integer. loo_Xml.NewChild2("offset","0") // Apparently this is a required field. ls_ShipBeforeDate = "2019-06-04" loo_Xml.NewChild2("shipBeforeDate",ls_ShipBeforeDate) loo_Xml.SortByTag(1) // Encode... // "\" (backslash) as "\\" // ":" (colon) as "\:" loo_SbTags = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbTags.ConnectToNewObject("Chilkat.StringBuilder") loo_SbValues = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbValues.ConnectToNewObject("Chilkat.StringBuilder") loo_SbContent = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbContent.ConnectToNewObject("Chilkat.StringBuilder") n = loo_Xml.NumChildren i = 0 do while i < n if i > 0 then loo_SbTags.Append(":") loo_SbValues.Append(":") end if loo_Xml.GetChild2(i) loo_SbTags.Append(loo_Xml.Tag) loo_SbContent.SetString(loo_Xml.Content) li_NumReplaced = loo_SbContent.Replace("~","\~") li_NumReplaced = loo_SbContent.Replace(":","\:") loo_SbValues.AppendSb(loo_SbContent) loo_Xml.GetParent2() i = i + 1 loop loo_SbSigningStr = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbSigningStr.ConnectToNewObject("Chilkat.StringBuilder") loo_SbSigningStr.AppendSb(loo_SbTags) loo_SbSigningStr.Append(":") loo_SbSigningStr.AppendSb(loo_SbValues) loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") loo_Crypt.HashAlgorithm = "sha256" loo_Crypt.MacAlgorithm = "hmac" ls_HmacKey = "934D1E806DDD99595EB430076FD7F8E4D12D0A3F51243A4C0C3897703118E739" loo_Crypt.SetMacKeyEncoded(ls_HmacKey,"hex") loo_Crypt.EncodingMode = "base64" ls_MerchantSig = loo_Crypt.HmacStringENC(loo_SbSigningStr.GetAsString()) Write-Debug ls_MerchantSig destroy loo_Gzip destroy loo_Xml destroy loo_SbTags destroy loo_SbValues destroy loo_SbContent destroy loo_SbSigningStr destroy loo_Crypt |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.