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) Paynow.pl -- Make a Payment RequestMake a payment request POST with prepared message on Paynow payment request endpoint. For more information, see https://docs.paynow.pl/#section/Payments/Make-a-payment
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Json string ls_MyApiAccessKey string ls_MySigCalcKey oleobject loo_Crypt string ls_MessageBody string ls_Signature oleobject loo_Resp oleobject loo_JsonResp string ls_RedirectUrl string ls_PaymentId string ls_Status // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Implements the following CURL command: // curl --request POST 'https://api.sandbox.paynow.pl/v1/payments' \ // -H 'Content-Type: application/json' \ // -H 'Api-Key: c12c386b-650b-43db-9430-d84fc05d9433' \ // -H 'Signature: aYPCytCoc+/wFgqHZJjgBCi20omXTn0yzm9LysJgnFo=' \ // -H 'Idempotency-Key: 59c6dd26-f905-487b-96c9-fd1d2bd76885' \ // --data-raw '{ // "amount": 45671, // "externalId": "234567898654", // "description": "Test transaction", // "buyer": { // "email": "jan.kowalski@melements.pl" // } // }' // Use the following online tool to generate HTTP code from a CURL command // Convert a cURL Command to HTTP Source Code // Use this online tool to generate code from sample JSON: // Generate Code to Create JSON // The following JSON is sent in the request body. // { // "amount": 45671, // "externalId": "234567898654", // "description": "Test transaction", // "buyer": { // "email": "jan.kowalski@melements.pl" // } // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateInt("amount",45671) loo_Json.UpdateString("externalId","234567898654") loo_Json.UpdateString("description","Test transaction") loo_Json.UpdateString("buyer.email","jan.kowalski@melements.pl") ls_MyApiAccessKey = "c12c386b-650b-43db-9430-d84fc05d9433" ls_MySigCalcKey = "b758f20d-ba92-44fa-acca-f57e99787b9d" // Calculate the Signature header. 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.MacAlgorithm = "hmac" loo_Crypt.EncodingMode = "base64" loo_Crypt.SetMacKeyString(ls_MySigCalcKey) loo_Crypt.HashAlgorithm = "SHA-256" ls_MessageBody = loo_Json.Emit() ls_Signature = loo_Crypt.MacStringENC(ls_MessageBody) loo_Http.SetRequestHeader("Idempotency-Key",loo_Crypt.GenerateUuid()) loo_Http.SetRequestHeader("Api-Key",ls_MyApiAccessKey) loo_Http.SetRequestHeader("Signature",ls_Signature) loo_Http.SetRequestHeader("Content-Type","application/json") loo_Http.Accept = "application/json" loo_Resp = loo_Http.PostJson3("https://api.sandbox.paynow.pl/v1/payments","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Json destroy loo_Crypt return end if Write-Debug "Response body:" Write-Debug loo_Resp.BodyStr // Sample response: // { // "redirectUrl": "https://paywall.sandbox.paynow.pl/NOA0-YJ9-Y1P-29V?token=eyJraWQiOiJhMD ... L60wk", // "paymentId": "NOA0-YJ9-Y1P-29V", // "status": "NEW" // } loo_JsonResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonResp.ConnectToNewObject("Chilkat.JsonObject") loo_JsonResp.Load(loo_Resp.BodyStr) ls_RedirectUrl = loo_Json.StringOf("redirectUrl") ls_PaymentId = loo_Json.StringOf("paymentId") ls_Status = loo_Json.StringOf("status") destroy loo_Http destroy loo_Json destroy loo_Crypt destroy loo_JsonResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.