Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Adyen HMAC Signature Calculation for Hosted Payment Pages

Demonstrates 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/

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Boolean iSuccess
    String sStrHtml
    Handle hoGzip
    String sGzOrderData
    Handle hoXml
    String sSessionValidity
    String sCountryCode
    String sShopperLocale
    String sMerchantReference
    String sMerchantAccount
    String sPaymentAmount
    String sCurrencyCode
    String sSkinCode
    String sShopperReference
    String sShopperEmail
    String sShipBeforeDate
    Variant vSbTags
    Handle hoSbTags
    Variant vSbValues
    Handle hoSbValues
    Variant vSbContent
    Handle hoSbContent
    Integer n
    Integer i
    Integer iNumReplaced
    Handle hoSbSigningStr
    Handle hoCrypt
    String sHmacKey
    String sMerchantSig
    String sTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Move '<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>' To sStrHtml

    Get Create (RefClass(cComChilkatGzip)) To hoGzip
    If (Not(IsComObjectCreated(hoGzip))) Begin
        Send CreateComObject of hoGzip
    End
    Get ComCompressStringENC Of hoGzip sStrHtml "utf-8" "base64" To sGzOrderData

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Set ComTag Of hoXml To "keyValuePairs"

    Send ComNewChild2 To hoXml "orderData" sGzOrderData

    // required, The payment deadline; the payment needs to occur within the specified time value.
    Move "2019-08-11T10:30:00Z" To sSessionValidity
    Send ComNewChild2 To hoXml "sessionValidity" sSessionValidity

    // 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.
    Move "GB" To sCountryCode
    Send ComNewChild2 To hoXml "countryCode" sCountryCode

    // optional
    Move "en_GB" To sShopperLocale
    // 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.
    Send ComNewChild2 To hoXml "shopperLocale" sShopperLocale

    // 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.
    Move "paymentTest1234" To sMerchantReference
    Send ComNewChild2 To hoXml "merchantReference" sMerchantReference

    // required, The merchant account identifier you want to process the (transaction) request with.
    Move "ChilkatSoftwareIncCOM" To sMerchantAccount
    Send ComNewChild2 To hoXml "merchantAccount" sMerchantAccount

    // required.  10000 for $100.00
    Move "10000" To sPaymentAmount
    Send ComNewChild2 To hoXml "paymentAmount" sPaymentAmount

    // required, The three-character ISO currency code
    Move "GBP" To sCurrencyCode
    Send ComNewChild2 To hoXml "currencyCode" sCurrencyCode

    // required.
    Move "S7uWsvfB" To sSkinCode
    Send ComNewChild2 To hoXml "skinCode" sSkinCode

    // 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.  
    Move "somebody@example.com" To sShopperReference
    Send ComNewChild2 To hoXml "shopperReference" sShopperReference

    // optional
    Move "somebody@example.com" To sShopperEmail
    Send ComNewChild2 To hoXml "shopperEmail" sShopperEmail

    // optional, An integer value that adds up to the normal fraud score.
    // The value can be either a positive or negative integer.
    Send ComNewChild2 To hoXml "offset" "0"

    // Apparently this is a required field.
    Move "2019-06-04" To sShipBeforeDate
    Send ComNewChild2 To hoXml "shipBeforeDate" sShipBeforeDate

    Send ComSortByTag To hoXml True

    // Encode...
    //  "\" (backslash) as "\\"
    //  ":" (colon) as "\:"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbTags
    If (Not(IsComObjectCreated(hoSbTags))) Begin
        Send CreateComObject of hoSbTags
    End
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbValues
    If (Not(IsComObjectCreated(hoSbValues))) Begin
        Send CreateComObject of hoSbValues
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbContent
    If (Not(IsComObjectCreated(hoSbContent))) Begin
        Send CreateComObject of hoSbContent
    End
    Get ComNumChildren Of hoXml To n
    Move 0 To i
    While (i < n)
        If (i > 0) Begin
            Get ComAppend Of hoSbTags ":" To iSuccess
            Get ComAppend Of hoSbValues ":" To iSuccess
        End

        Get ComGetChild2 Of hoXml i To iSuccess
        Get ComTag Of hoXml To sTemp1
        Get ComAppend Of hoSbTags sTemp1 To iSuccess

        Get ComContent Of hoXml To sTemp1
        Get ComSetString Of hoSbContent sTemp1 To iSuccess
        Get ComReplace Of hoSbContent "\" "\\" To iNumReplaced
        Get ComReplace Of hoSbContent ":" "\:" To iNumReplaced
        Get pvComObject of hoSbContent to vSbContent
        Get ComAppendSb Of hoSbValues vSbContent To iSuccess
        Get ComGetParent2 Of hoXml To iSuccess

        Move i + 1 To i
    Loop

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbSigningStr
    If (Not(IsComObjectCreated(hoSbSigningStr))) Begin
        Send CreateComObject of hoSbSigningStr
    End
    Get pvComObject of hoSbTags to vSbTags
    Get ComAppendSb Of hoSbSigningStr vSbTags To iSuccess
    Get ComAppend Of hoSbSigningStr ":" To iSuccess
    Get pvComObject of hoSbValues to vSbValues
    Get ComAppendSb Of hoSbSigningStr vSbValues To iSuccess

    Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
    If (Not(IsComObjectCreated(hoCrypt))) Begin
        Send CreateComObject of hoCrypt
    End
    Set ComHashAlgorithm Of hoCrypt To "sha256"
    Set ComMacAlgorithm Of hoCrypt To "hmac"

    Move "934D1E806DDD99595EB430076FD7F8E4D12D0A3F51243A4C0C3897703118E739" To sHmacKey
    Get ComSetMacKeyEncoded Of hoCrypt sHmacKey "hex" To iSuccess

    Set ComEncodingMode Of hoCrypt To "base64"
    Get ComGetAsString Of hoSbSigningStr To sTemp1
    Get ComHmacStringENC Of hoCrypt sTemp1 To sMerchantSig

    Showln sMerchantSig


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.