csob / paymentgateway

English documentation of the ČSOB Payment Gateway that offers an API for credit card payments, Apple Pay, Google Pay, mallpay and ČSOB Payment Button.
https://platbakartou.csob.cz/platebni-brana
GNU General Public License v3.0
121 stars 68 forks source link

Signing request algorythm #3

Closed bendis closed 9 years ago

bendis commented 9 years ago

Hi, using which alg. should I sign the request? Using SHA1 does not work for me. Here is my request content, maybe there is some other bug.

{"merchantId"=>"M1MIPS0015", "orderNo"=>"123456", "dttm"=>"20150601170551", "payOperation"=>"payment", "payMethod"=>"card", "totalAmount"=>12000, "currency"=>"CZK", "closePayment"=>"false", "returnUrl"=>"http://localhost:4567/gateway-return", "returnMethod"=>"POST", "cart"=>[{"name"=>"Shopping at ...", "quantity"=>1, "amount"=>10800, "description"=>""}, {"name"=>"Shipping", "quantity"=>1, "amount"=>1200}], "description"=>"Testovací nákup", "merchantData"=>nil, "customerId"=>"123", "language"=>"CZ", "signature"=>"Ivj0RRpoc8QYPnulDSor2xobffsX2peQG4aA0uzUucbz+soXMP26xgvTj3AO\nEU0PBWf3uBTRaA+iUB85WRoI0neUnzgkXVwxCfZga+PUiy6KctNtwomT0GNb\nsL5U/aXnuLdLFpHINUPM+9uPzeOJrtcf1cP+XNItvihSHbZpnbfpWVXNfHxC\n7zqDajKGP2RFsysj+tRVSq+I42HSDjX1igSNBdIEdBr5wrUsdRJ9rWj4z+VG\na6Ig9pQ0Xu1+aByiGR3+6l9qZHXjUNvW7USnm06xOuge/HX8QvBPlJ+6Z5/Q\ncTIsFrS7zMErvehYx2DAgNNiA7LgMZIrpTIA9jcvWg==\n"}

sending to: https://iapi.iplatebnibrana.csob.cz/api/v1/payment/init/

getting: {"resultCode":900,"resultMessage":"Internal error"}

Thanks for help

Jiri

krunal131987 commented 9 years ago

confirm that, which Content-Type you using, "Content-Type:application/json"

https://github.com/csob/paymentgateway/wiki/eAPI-v1-%28English-version%29#-post-httpsapiplatebnibranacsobczapiv1paymentinit-

bendis commented 9 years ago

Yes I have content-type application/json. I am a bit further, now I have 400 Bad Request (just changed the method for generating request body). Could this error be caused by wrong SHA1 alg. or is this correct one? Or maybe wrong order of data for signing. I will also check this out. Please, confirm, that SHA1 is correct.

krunal131987 commented 9 years ago

I am also getting same error, are you trying to implement on android?

bendis commented 9 years ago

No no, I am trying Ruby

dmarek commented 9 years ago

Algorithm to sign/verify is SHA1

in Java use Signature.getInstance("SHA1withRSA") in php use openssl_verify, openssl_sign functions, OPENSSL_ALGO_SHA1 is used as default alg. etc.

Content-type is application/json

bendis commented 9 years ago

Ok, I have checked the script and it seems ok. But I recognized one thing. I used integration env. keygen for generating keys and sending it to the payment gateway. But in posmerchant admin I could not see any added key. Could this be the reason, that it was not properly added automatically? If yes, how to solve it. Should I send the public key by email and you will add it to our posmerchant interface?

ratajskym commented 9 years ago

On integration env, the key is automatically approved and assign to your profile. There is new version of Posmerchant so you will not see Key section anymore.

bendis commented 9 years ago

Sorry, but this issue should not be closed. Because my last question was 2 days old, it was related to the previous version of Posmerchant. Sorry, I will follow up this conv. in czech.

Protože zde není úplně promptní odezva, paralelně komunikuji s panem Horákem po telefonu a emailem. Můj dotaz byl k předešlé verzi posmerchantu, kde po vygenerování klíče a odeslání do posmerchantu nebyla vidět ani žádost na zavedení, ale záložka klíče tam byla. Pan Horák mi řekl, že k tomu má přijít ještě potvrzovací email, kde se to musí ještě explicitně ověřit. Takže včera večer jsem zkusil vygenerovat a odeslat klíče znovu. Nicméně žádný email mi nedorazil. Panu Horákovi jsem dnes ráno psal a je mimo kancelář. Prosím o prověření zavedení klíče. Žádost je 1053. MechantID je M1MIPS0015. Jedná se o integrační prostředí. Poprosím Vás o promptní odpověď. Začínáme mít již problém vysvětlovat našemu klientovi, proč nasazení brány trvá tak dlouhou dobu.

ratajskym commented 9 years ago

Na integrační bráně není potřeba nic schvalovat. Vygenerovaný klíč je schválený automaticky tzn. žádný email s OTP Vám nedorazí. Zkoušel jste poslat transakci?