dpallas
Members-
Content Count
11 -
Joined
-
Last visited
Everything posted by dpallas
-
Hi everybody I have the following code: Var dpHttp : TIdHttp; dpSSL : TIdSSLIOHandlerSocketOpenSSL; BaseURL : String; Body : String; Bearer : String; PostData : TStringStream; sResponse: TStringStream; begin BaseURL:='https://uat.mreceipts.com/api/v2.1/authorization/redeem/'; Body:='{"Type" : "webecr", "Code" : "23916589" }'; Bearer:=Edaccess.Text; sResponse:=TStringStream.Create('',TEncoding.UTF8); PostData := TStringStream.Create(Body,TEncoding.UTF8); dpHttp:=TIdHTTP.Create; dpHttp.Request.Accept :='application/json'; dpHttp.Request.Host :=BaseURL; dpHttp.Request.ContentType:='application/json'; dpHttp.Request.Charset :='UTF-8'; dpHTTP.Request.CustomHeaders.AddValue('Authorization', 'Bearer ' + Bearer); dpSSL:=TIdSSLIOHandlerSocketOpenSSL.Create; dpSSL.SSLOptions.Method :=sslvSSLv3; dpSSL.SSLOptions.SSLVersions:=[sslvTLSv1, sslvTLSv1_1, sslvTLSv1_2]; dpHttp.IOHandler:=dpSSL; try dpHttp.Post(BaseURL,PostData, sResponse); except // Result:=211; end; sResponse.Free; dpHttp.Free; dpSSL.Free; PostData.Free When I run it, it shows the message HTTP/1.1 400 Bad Request. The bearer token is correct. Does anyone have any idea why this is happening? Thank you
-
Thank you all guys for your valuable replies
-
There is this h header in VC++ typedef struct EFTPOS_ERROR { ERROR_LEVEL errorLevel; ERROR_CODE errorCode; char* errorMessage; } typedef struct EFTPOS_DEVICE { char* posId; char* terminalId; char* apiKey; char* host; LONG port; POS_PROTOCOL posProtocol; } typedef struct EFTPOS_CONTEXT { char* licenseKey; char* vatNumber; vector<EFTPOS_DEVICE> devices; vector<SIGNATURE_PROVIDER> providers; } extern "C" __declspec(dllexport) void __cdecl InitContext(char** contextId, EFTPOS_ERROR* error, EFTPOS_CONTEXT context); I tried with PAnsiChar and PChar types and when I call InitContext it shows External Exception or Access violation Can anyone help? Thank you
-
I don't get why the target hardware has anything to do with it, though it is desktop computers (x64). The header comes from a driver library, for which I do not have the source. I agree, however, that the only solution is either a C SDK, or writing a C-like interface dll.
-
Remy thanks again for your response. But I have no idea about C++. So it is impossible for me to implement the C code you wrote. Yes I definitely need this SDK. The only solution is to find someone to write this code.
-
The problem is that I don't know how to write in VC++ Thank you David.
-
Remy thank you for your answer Please look at the code below, I think the field sizes are defined. Thank you again typedef struct EFTPOS_CONTEXT { char* licenseKey; char* vatNumber; vector<EFTPOS_DEVICE> devices; vector<SIGNATURE_PROVIDER> providers; EFTPOS_CONTEXT() : licenseKey(NULL) , vatNumber(NULL) { devices.clear(); providers.clear(); } EFTPOS_CONTEXT(EFTPOS_CONTEXT* context) { if (NULL != context->licenseKey) { licenseKey = new char[strlen(context->licenseKey) + 1]; lstrcpy(licenseKey, context->licenseKey); } if (NULL != context->vatNumber) { vatNumber = new char[strlen(context->vatNumber) + 1]; lstrcpy(vatNumber, context->vatNumber); } devices.clear(); providers.clear(); for (vector<EFTPOS_DEVICE>::iterator it = context->devices.begin(); it != context >devices.end(); it++) { EFTPOS_DEVICE device(it); devices.push_back(device); } for (vector<SIGNATURE_PROVIDER>::iterator it = context->providers.begin(); it != context->providers.end(); it++) { providers.push_back(*it); } }
-
Thanks David Is there an alternative way to do this?
-
I will try Merci beaucoup M. François
-
Thank you Mr Francois. Unfortunately I don't have the ability to use C++
-
Thank you for your answer. Translation in delphi: PEFTPOS_DEVICE = ^EFTPOS_DEVICE; EFTPOS_DEVICE = record posId: PChar; terminalId: PChar; apiKey: PChar; host: PChar; port: LongInt; posProtocol: POS_PROTOCOL; end; PEFTPOS_CONTEXT = ^EFTPOS_CONTEXT; EFTPOS_CONTEXT = record licenseKey: PChar; vatNumber: PChar; devices: TList<EFTPOS_DEVICE>; providers: TList<SIGNATURE_PROVIDER>; end; procedure InitializeEFTPOSDevice(var device: EFTPOS_DEVICE); begin device.posId := nil; device.terminalId := nil; device.apiKey := nil; device.host := nil; device.posProtocol := NOT_SET; device.port := 0; end; procedure InitializeEFTPOSContext(var context: EFTPOS_CONTEXT); begin context.licenseKey := nil; context.vatNumber := nil; context.devices := TList<EFTPOS_DEVICE>.Create; context.providers := TList<SIGNATURE_PROVIDER>.Create; end; The same happens if I use devices: Array<EFTPOS DEVICE>; Thanks again