hmacSHA512 verfügbar?

Hallo Synesty Team und Experten,

für einen API Call zum Payment Gateway benötigen wir einen hmacSHA512 Auth Header. Steht diese überhaupt zur Verfügung? Laut Transformy Doku gibt es nur hmacSHA256 https://apps.synesty.com/transformy/de-de?action=showTemplateFunctionDocumentation#hmacSHA256



Hallo,


wir werden uns das anschauen und versuchen es einzubauen. Wir geben nochmal bescheid falls es nutzbar ist.


Viele Grüße,

Der Synesty Support

Hi Synesty Support,


es wäre extrem wichtig für uns, dieses Feature zu haben, andernfalls haben wir einen echten Showstopper für wichtige Teile des Projektes und müssten uns nach Alternativen zu Synesty umschauen.

Hallo,


Sie können das Feature nun nutzen.

https://apps.synesty.com/transformy?action=showTemplateFunctionDocumentation&target=functions#hmacSHA512


Viele Grüße,

Der Synesty-Support

Super! Dann werde ich das ASAP testen :-)

Hallo Synesty Team,


evtl. gibt es ein Problem mit dieser Funktion oder ich mache etwas falsch...


Hier ein Beispiel des Herstellers für PHP

$key = base64_decode("someBase64endcodedData=");
$timestamp = time(); //Unix Timestamp in Seconds
$hash_string = "1|26624|$timestamp|POST|/api/charge-attempt/search?spaceId=1234&id=9876543";
echo base64_encode(hash_hmac("sha512",$hash_string,$key, true));

In meinem Step verabeite ich die Daten wie folgt:

${hmacSHA512(result['hashstring']!, decodeBase64(meta.authkey!), "base64")!}

result['hashstring'] entspricht dem Format aus dem PHP Beispiel.


Wenn ich nun den in PHP und in Synesty erstellten bas64 Hash vergleiche, dann bekomme ich unterschiedliche Ergebnisse:

// PHP
Z94ujnH0JH/yBgvFH5j2Grf0XGRTJMO6leOGOSGp5/tBW25M2Gvf0UM8zujzSVfIfjBzGjUjajoPXWVbh6dTOQ==
// Synesty
bGFozDt9hrXyz+p8c39QG2pB2T2GuNnIMbsh8HWxusKl28oTfq2fG3M2kXI6pHabiQOhfTvCvJ/feTNUNq83zw==

Key, Timestamp und Hashstring sind in beiden Umgebungen identisch

Hallo,


unter https://www.freeformatter.com/hmac-generator.html können Sie einmal das ganze teste. Bei gleichem Hash sollte auch das selbe rauskommen. Eventuell hat sich in der Zeit zwischen den beiden Tests, der timestamp geändert.


Viele Grüße,

Der Synesty-Support


Hallo Support,


ich vermute, das Problem liegt in der Funktion decodeBase64()


Die Daten des Base64 Strings sind keine reinen Textdaten und können nicht in UTF-8 oder ISO-8859-1 dargestellt werden. Wenn ich in PHP einen MD5 Hash der decodierten Daten erstelle und in Synesty, dann ist eindeutig ein Unterschied erkennbar:

// PHP
md5(base64_decode($key)) => 41181cbd6cef51455df398eb13646895

// Synesty
${md5(decodeBase64(meta.wallee_authkey!))} => c41bad8f43db9ecd4bedefa50aa2dbeb

Mit dem in PHP dekodierten Key kann ich mich übrigens auch an der API anmelden, sprich der PHP-Referenzcode funktioniert.

Hi,


ist es Ihnen eventuell möglich uns einmal die Rohdaten zukommen zu lassen? Am besten per Ticket. Anhand von konkreten Beispielen gestaltet sich die Fehlersuche deutlich einfacher.


Viele Grüße,

Der Synesty Support

Siehe Ticket 20472

Hallo

Wir versuchen auch gerade die Wallee API abzurufen und sind an der gleichen Stelle gelandet. Habt Ihr damals eine Lösung gefunden, könntet Ihr diese eventuell hier ins Forum posten?

Danke

Hallo @oceanus-nk,

das Problem lag damals beim Zeichensatz des dekodierten Base64 Secrets.
Man kann den Zeichensatz optional bei der Template Funktion decodeBase64 und hmacSHA512 angeben.

Ein Beispiel finden sie hier:

Ich hoffe das hilft weiter.

VG Torsten

@oceanus-nk

Ich stelle hier mal das JSON der Steps rein, welche wir zur Abfrage der Transaktionsfos von der Wallee API nutzen, aber bitte daran denken, dass der API Endpoint und Request Body jeweils individuell anzupassen sind:

Spreadsheet Mapper um die Daten für den API Zugriff aufzubereiten

{
  "executorflowuniqename" : "",
  "description" : "",
  "condition" : "",
  "rank" : 530,
  "active" : true,
  "permaId" : 47,
  "stepprovider" : "SpreadsheetMapper@com.synesty.stepesty.plugin.transformycore",
  "stepproviderversion" : "1.0",
  "stepProperty" : [ {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "false",
    "key" : "cacheMode",
    "type" : "IN"
  }, {
    "datatype" : "STRINGLIST",
    "contextkey" : null,
    "value" : "",
    "key" : "disableWarnings",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "{\"groupByColumn\":\"\",\"groupMode\":\"\",\"sortByCol\":\"\",\"sortDir\":\"ASC\",\"colDefs\":[{\"colDef\":{\"name\":\"transaction_id\",\"sourceColName\":\"transaction_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"order_id\",\"sourceColName\":\"order_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"kind\",\"sourceColName\":\"kind\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"gateway\",\"sourceColName\":\"gateway\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"status\",\"sourceColName\":\"status\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"message\",\"sourceColName\":\"message\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"created_at\",\"sourceColName\":\"created_at\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"test\",\"sourceColName\":\"test\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"authorization\",\"sourceColName\":\"authorization\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"location_id\",\"sourceColName\":\"location_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"user_id\",\"sourceColName\":\"user_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"parent_id\",\"sourceColName\":\"parent_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"processed_at\",\"sourceColName\":\"processed_at\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"device_id\",\"sourceColName\":\"device_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"receipt\",\"sourceColName\":\"receipt\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"error_code\",\"sourceColName\":\"error_code\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"source_name\",\"sourceColName\":\"source_name\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"amount\",\"sourceColName\":\"amount\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"currency\",\"sourceColName\":\"currency\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"admin_graphql_api_id\",\"sourceColName\":\"admin_graphql_api_id\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"timestamp\",\"sourceColName\":\"\",\"value\":\"${(.now?long / 1000)?round}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"path\",\"sourceColName\":\"\",\"value\":\"/api/charge-attempt/search?spaceId=${meta.wallee_spaceid!}&id=${authorization!}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"hashstring\",\"sourceColName\":\"\",\"value\":\"${meta.xmacversion!}|${meta.wallee_accountid!}|${result['timestamp']!}|POST|${result['path']!}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"decoded_key_md5\",\"sourceColName\":\"\",\"value\":\"${md5(decodeBase64(meta.wallee_authkey!))}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"hmac512_alt\",\"sourceColName\":\"\",\"value\":\"${hmacSHA512(result['hashstring']!, decodeBase64(meta.wallee_authkey!), \\\"base64\\\")!}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"hmac512_neu\",\"sourceColName\":\"\",\"value\":\"${hmacSHA512(result['hashstring']!, decodeBase64(meta.wallee_authkey!,\\\"ISO-8859-1\\\"), \\\"base64\\\", \\\"\\\", \\\"ISO-8859-1\\\", \\\"\\\")!}\",\"commentField\":\"\",\"colFunctions\":[]}},{\"colDef\":{\"name\":\"api_auth_header\",\"sourceColName\":\"\",\"value\":\"x-mac-version=${meta.xmacversion!}\\nx-mac-userid=${meta.wallee_accountid!}\\nx-mac-timestamp=${result['timestamp']!}\\nx-mac-value=${result['hmac512_neu']!}\",\"commentField\":\"\",\"colFunctions\":[{\"stringColFunction\":{\"trimMode\":\"SBENL\"}}]}}]}",
    "key" : "mappingdefinition",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "mappingMode",
    "type" : "IN"
  }, {
    "datatype" : "SPREADSHEET",
    "contextkey" : "output@SpreadsheetFilter_48",
    "value" : "",
    "key" : "source",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "targetSchemaName",
    "type" : "IN"
  } ],
  "steptype" : "DEFAULT",
  "uiColor" : null,
  "name" : "Daten aggregieren für Wallee API"
}

SpreadsheetURLDownload Step (Auswertung dann mittels JSON Reader Step)

{
  "executorflowuniqename" : "",
  "description" : "",
  "condition" : "",
  "rank" : 540,
  "active" : true,
  "permaId" : 49,
  "stepprovider" : "SpreadsheetUrlDownload@com.asolida.delivor.plugin.steps.httpurldownloadimpl",
  "stepproviderversion" : "1.0",
  "stepProperty" : [ {
    "datatype" : "ACCOUNT",
    "contextkey" : null,
    "value" : "",
    "key" : "account",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "1",
    "key" : "batchSize",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "application/json; charset=UTF-8",
    "key" : "bodyContentType",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "UTF-8",
    "key" : "encoding",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "errorStatusCodes",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "filename",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "fileNameInList",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "fileParameterName",
    "type" : "IN"
  }, {
    "datatype" : "FILELIST",
    "contextkey" : null,
    "value" : "",
    "key" : "filesToUpload",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "application/json; charset=UTF-8",
    "key" : "headerContentType",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "${meta.wallee_api_host!}${path!}",
    "key" : "host",
    "type" : "IN"
  }, {
    "datatype" : "SPREADSHEET",
    "contextkey" : "spreadsheet@SpreadsheetMapper_47",
    "value" : "",
    "key" : "input",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "10000",
    "key" : "limit",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "POST",
    "key" : "method",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "10000",
    "key" : "numErrorsToStopFlow",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "addResponseContentColumn",
    "key" : "outputMode",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "transaction_id,order_id,kind,gateway,status,message,created_at,test,authorization,location_id,user_id,parent_id,processed_at,device_id,receipt,error_code,source_name,amount,currency,admin_graphql_api_id,timestamp,path,hashstring,hashstring_to_byte,hmac512,api_auth_header",
    "key" : "outputSourceColumns",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "password",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "4",
    "key" : "rateLimitPerSecond",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "{\r\n    \"filter\": {\r\n        \"children\": [\r\n            {\r\n                \"fieldName\": \"state\",\r\n                \"operator\": \"EQUALS\",\r\n                \"type\": \"LEAF\",\r\n                \"value\": \"SUCCESSFUL\"\r\n            },\r\n            {\r\n                \"fieldName\": \"charge.transaction.id\",\r\n                \"operator\": \"EQUALS\",\r\n                \"type\": \"LEAF\",\r\n                \"value\": \"${authorization!}\"\r\n            }\r\n        ],\r\n        \"type\": \"AND\"\r\n    }\r\n}",
    "key" : "requestBody",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "x-mac-version=${meta.xmacversion!}\r\nx-mac-userid=${meta.wallee_accountid!}\r\nx-mac-timestamp=${timestamp!}\r\nx-mac-value=${hmac512_neu!}",
    "key" : "requestHeaders",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "false",
    "key" : "sslCertificates",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "60",
    "key" : "timeoutInSeconds",
    "type" : "IN"
  }, {
    "datatype" : "STRING",
    "contextkey" : null,
    "value" : "",
    "key" : "username",
    "type" : "IN"
  } ],
  "steptype" : "BILLABLE",
  "uiColor" : null,
  "name" : "Transaktionsinfos aus Walle herunterladen"
}
1 „Gefällt mir“

Ich danke euch beiden sehr, mit den Infos konnten wir Daten über die API abrufen. Das eine war der Zeichensatz, den anderen Fehler konnten wir dank dem Spreadsheet Mapper ausfindig machen und zwar haben wir den Timestamp in Millisekunden statt Sekunden übergeben.

Grüsse

1 „Gefällt mir“