concardis / PHP_SDK

MIT License
3 stars 10 forks source link

Issue with DateTime type for AbstractOrder::$terms and AbstractOrder::$privacy #3

Closed ocean90 closed 6 years ago

ocean90 commented 7 years ago

The code documentation says that both properties accept a DateTime object but the API only accepts a timestamp (integer) in requests.

Request:

request

Response:

response

Example of a request payload that produces a "Malformed request!" error.

{
   "payment":{
      "paymentInstrumentId":"paymentinstrument_xxxxxxxx"
   },
   "product":"creditcard",
   "async":{
      "successUrl":"http:\/\/google.de?q=success",
      "failureUrl":"http:\/\/google.de?q=failure",
      "cancelUrl":"http:\/\/google.de?q=cancel"
   },
   "terms":{
      "date":"2017-10-26 14:48:15.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "privacy":{
      "date":"2017-10-26 14:48:15.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "description":"Tickets",
   "initialAmount":6000,
   "currency":"CHF",
   "basket":[
      {
         "name":"Stehplatz",
         "totalPrice":6000,
         "unitPrice":6000,
         "quantity":1
      }
   ],
   "customer":"customer_xxxxxxxx",
   "channel":"ECOM",
   "source":"Website"
}
ocean90 commented 6 years ago

Turns out the middleware requires the use of milliseconds. To get the current time in milliseconds you have to use round( microtime( true ) * 1000 ); which will return a float by default.

Sharenkamp commented 6 years ago

Hi @ocean90,

the upcoming release will support timestamp and Datetime. The conversion to milliseconds will be handled by the SDK.

For the current version your solution works fine.

best regards, Stefan

Sharenkamp commented 6 years ago

Fixed with 1.1.0