Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Visual FoxPro Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Visual FoxPro) 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

LOCAL lnSuccess
LOCAL lcStrHtml
LOCAL loGzip
LOCAL lcGzOrderData
LOCAL loXml
LOCAL lcSessionValidity
LOCAL lcCountryCode
LOCAL lcShopperLocale
LOCAL lcMerchantReference
LOCAL lcMerchantAccount
LOCAL lcPaymentAmount
LOCAL lcCurrencyCode
LOCAL lcSkinCode
LOCAL lcShopperReference
LOCAL lcShopperEmail
LOCAL lcShipBeforeDate
LOCAL loSbTags
LOCAL loSbValues
LOCAL loSbContent
LOCAL n
LOCAL i
LOCAL lnNumReplaced
LOCAL loSbSigningStr
LOCAL loCrypt
LOCAL lcHmacKey
LOCAL lcMerchantSig

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

lcStrHtml = '<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>'

loGzip = CreateObject('Chilkat_9_5_0.Gzip')
lcGzOrderData = loGzip.CompressStringENC(lcStrHtml,"utf-8","base64")

loXml = CreateObject('Chilkat_9_5_0.Xml')
loXml.Tag = "keyValuePairs"

loXml.NewChild2("orderData",lcGzOrderData)

* required, The payment deadline; the payment needs to occur within the specified time value.
lcSessionValidity = "2019-08-11T10:30:00Z"
loXml.NewChild2("sessionValidity",lcSessionValidity)

* 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.
lcCountryCode = "GB"
loXml.NewChild2("countryCode",lcCountryCode)

* optional
lcShopperLocale = "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.
loXml.NewChild2("shopperLocale",lcShopperLocale)

* 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.
lcMerchantReference = "paymentTest1234"
loXml.NewChild2("merchantReference",lcMerchantReference)

* required, The merchant account identifier you want to process the (transaction) request with.
lcMerchantAccount = "ChilkatSoftwareIncCOM"
loXml.NewChild2("merchantAccount",lcMerchantAccount)

* required.  10000 for $100.00
lcPaymentAmount = "10000"
loXml.NewChild2("paymentAmount",lcPaymentAmount)

* required, The three-character ISO currency code
lcCurrencyCode = "GBP"
loXml.NewChild2("currencyCode",lcCurrencyCode)

* required.
lcSkinCode = "S7uWsvfB"
loXml.NewChild2("skinCode",lcSkinCode)

* 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.  
lcShopperReference = "somebody@example.com"
loXml.NewChild2("shopperReference",lcShopperReference)

* optional
lcShopperEmail = "somebody@example.com"
loXml.NewChild2("shopperEmail",lcShopperEmail)

* optional, An integer value that adds up to the normal fraud score.
* The value can be either a positive or negative integer.
loXml.NewChild2("offset","0")

* Apparently this is a required field.
lcShipBeforeDate = "2019-06-04"
loXml.NewChild2("shipBeforeDate",lcShipBeforeDate)

loXml.SortByTag(1)

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

loSbTags = CreateObject('Chilkat_9_5_0.StringBuilder')
loSbValues = CreateObject('Chilkat_9_5_0.StringBuilder')

loSbContent = CreateObject('Chilkat_9_5_0.StringBuilder')
n = loXml.NumChildren
i = 0
DO WHILE i < n
    IF (i > 0) THEN
        loSbTags.Append(":")
        loSbValues.Append(":")
    ENDIF

    loXml.GetChild2(i)
    loSbTags.Append(loXml.Tag)

    loSbContent.SetString(loXml.Content)
    lnNumReplaced = loSbContent.Replace("\","\\")
    lnNumReplaced = loSbContent.Replace(":","\:")
    loSbValues.AppendSb(loSbContent)
    loXml.GetParent2()

    i = i + 1
ENDDO

loSbSigningStr = CreateObject('Chilkat_9_5_0.StringBuilder')
loSbSigningStr.AppendSb(loSbTags)
loSbSigningStr.Append(":")
loSbSigningStr.AppendSb(loSbValues)

loCrypt = CreateObject('Chilkat_9_5_0.Crypt2')
loCrypt.HashAlgorithm = "sha256"
loCrypt.MacAlgorithm = "hmac"

lcHmacKey = "934D1E806DDD99595EB430076FD7F8E4D12D0A3F51243A4C0C3897703118E739"
loCrypt.SetMacKeyEncoded(lcHmacKey,"hex")

loCrypt.EncodingMode = "base64"
lcMerchantSig = loCrypt.HmacStringENC(loSbSigningStr.GetAsString())

? lcMerchantSig

RELEASE loGzip
RELEASE loXml
RELEASE loSbTags
RELEASE loSbValues
RELEASE loSbContent
RELEASE loSbSigningStr
RELEASE loCrypt


 

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