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

Got 400 error code in eAPI v1.7 #330

Closed ketannsangani12 closed 7 years ago

ketannsangani12 commented 7 years ago

Hi,

I am using eApi 1.7 for payments and send all data as described in documentation and stated that

When a request is being processed, basic parameters are checked first and the request signature is verified. If an error is detected, the response contains only a general HTTP status code, in terms of security, such as 400 Bad Request or 403 Forbidden

This is my input json : {
"merchantId":"M1MIPS1716", "orderNo":"123456", "dttm":"20171014101019", "payOperation":"payment", "payMethod":"card", "totalAmount":100, "currency":"CZK", "closePayment":"false", "returnUrl":"http:\/\/localhost\/csob\/return.php", "returnMethod":"POST", "cart":[
{
"name":"Shopping at ...", "quantity":1, "amount":100, "description":"Lenovo ThinkPad Edge E540..." }, {
"name":"Shipping", "quantity":1, "amount":0, "description":"PPL" } ], "description":"N\u00e1kup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)", "merchantData":null, "customerId":"1234", "language":"CZ", "signature":"Fog6OUGMPMytONBmeBnlFDbA4fU+\/ak3MBWeDimWbCWbuamzAc\/FUEWZrlnKXnDAaxKKhmhwPwffveUcSUzgrKQfl58j6iUdBtC\/NSRqgcfk3n42Qty5b+ymQ5EToYSSYg6UQVENfUiFWYtDjAUhR6g24Q4LOZC6JQmZ4bz\/loHTOSnLXVqBHYrqV8Rxrn+y1xrPg6YisZf2icAxNgi90GDm3Z\/BHxt9kMgIpM8dgSyxqPrx1KD0RzKWogsEFs5kB03bVLzDL9Fuu6s2H8hnd9Mvge7oD6vjZCiyNGNxdZ7rm7VlqffyU9iDams9+\/qMy5P6m\/+ymE8tC0ydUL9CMw==" }

how can i verify these things?Please help me

mrazekl commented 7 years ago

Hello,

to be able to help you,i need your Merchant ID.

mrazekl commented 7 years ago

I checked service log of your trying, you havn´t generate keys, right? You must generate testing keys for your merchant id here: https://iplatebnibrana.csob.cz/keygen/ and download bank public key here: https://github.com/csob/paymentgateway/tree/master/keys Instructions, steb by steb are available here(in English): https://github.com/csob/paymentgateway/wiki/eAPI-v1.7-EN#integration-process-keys-and-where-to-get-them You are blocked in production environment, so set up url of payment gateway: https://iapi.iplatebnibrana.csob.cz/api/v1.6

ketannsangani12 commented 7 years ago

I have both public and private keys.I am using version 1.7 not 1.6 and my merchant id is A2817KXBaz

mrazekl commented 7 years ago

I still seeing message: merchant key for M1MIPS1716 not found, it means error with keys. Are you sure you forwarded your public key to the bank when generated? Or Downloading right file of bank public key(mips_iplatebnibrana.csob.cz.pub)?? If not, please generate keys again, forward your public key to the bank(press button) and try. Should be work correctly.

ketannsangani12 commented 7 years ago

Sorry my merchant id is A2817KXBaz and tell me i have got one public key name rsa_A2817KXBaz.pub and one private key rsa_A2817KXBaz.key.I am confusing in this.again i am asking i am using v1.7 not 1.6

mrazekl commented 7 years ago

You have anonymous ID, which can be used only in testing environment. Testing payment gateway has latest version api 1.6. ***.key is for woocommerce plugin.

ketannsangani12 commented 7 years ago

New merchant ID is A2819fVRxG. Public key has been submitted. I have downloaded your repository and check examples in which signature generated with the use of **.key.Help me please still get error 400

ketannsangani12 commented 7 years ago

atleast please help how can i debug it mate?

mrazekl commented 7 years ago

You have bad signature now. This can happened from more reason. You send "closePayment": false, can you try set up "closePayment": 0

ketannsangani12 commented 7 years ago

yes i have tried that mate still not working

mrazekl commented 7 years ago

with these setup looking OK on my side, but now i can see you send "closePayment": false again, can you send same code unchanged, only set up "closePayment": 0

ketannsangani12 commented 7 years ago

csob.zip

This is my whole implementation please check and let me know what is the issue please?

mrazekl commented 7 years ago

thank you for file. You using woocommerce plugin? I tried your merchant ID and your key in woocommerce plugin and all did well. I add my code to inspire you. A2819fVRxG.txt

ketannsangani12 commented 7 years ago

no i am not using woocommerce i want simple payment method

ketannsangani12 commented 7 years ago

anything need to change in code?please tell me

ketannsangani12 commented 7 years ago

how can i solve error in my code mate?Please check my code mate?Please help me

mrazekl commented 7 years ago

in your file CSOB/sign-verify-test you have invalid merchand ID and public key. If you using this for generate signature, can be problem. Can you fix and try again?

ketannsangani12 commented 7 years ago

this file not used to generate signature its generated from crypto.php.Mate please check my code?Have you skype?Can we discuss over it?its better i think

mrazekl commented 7 years ago

can you add screen from your client? (settings etc...)

mrazekl commented 7 years ago

You have still bad signature. Can you delete old key from your key folder?(rsa_A2817KXBaz.* and mips_platebnibrana.csob.cz) also set ""closePayment": 0.

ketannsangani12 commented 7 years ago

still not working mate. I don't know.I am trying to resolve from morning and here now its evening

mrazekl commented 7 years ago

deleted old keys? and can you add screen from your client?

ketannsangani12 commented 7 years ago

yes deleted wait i will give you

ketannsangani12 commented 7 years ago

untitled1 untitled2 untitled

Hello,

Please check attachments and let me know

mrazekl commented 7 years ago

well, this is POSMERCHANT(in production environment, you should sign in testing environment here: https://iposman.iplatebnibrana.csob.cz), i think screen from your e-shop. POSMERCHANT is for merchant to check his transaction. NOT for create transaction. All day we talk about merchant ID A2819fVRxG and you now send screen for M1MIPS1716. Keys for A2819fVRxG are NOT SAME like keys for M1MIPS1716(must generate here: https://iplatebnibrana.csob.cz/keygen/ insert merchantID: M1MIPS1716 and email: tomas.jankuj@trv.cz) Store private and public key and forward public key to bank(button "odeslat veřejný klíč do banky") Replace your old key for this new in your e-shop.

ketannsangani12 commented 7 years ago

okay i am developer and previous key given by client and also did not give access before this.Once again sorry for this.Let me try with this.

Thank you very much

ketannsangani12 commented 7 years ago

image image image

Please check both above screens 1st from https://posman.csob.cz and 2nd from https://iposman.iplatebnibrana.csob.cz and 3rd from https://iposman.iplatebnibrana.csob.cz users information.

When i am trying to generate keys with robert.kvapil@trv.cz and merchant id M1MIPS1716 it gives me error invalid merchant id or email. When i am trying to generate keys with tomas.jankuj@trv.cz and merchant id M1MIPS1716 keys successfully generated.Then i have sent public key to bank and implement it in my code but still my code is not working.I dont know why?

mrazekl commented 7 years ago

I don´t know, what are you trying now? Let´s start from begining. Can you try "echo" using merchantID and keys for M1MIPS1716. Examples here: https://github.com/csob/paymentgateway/wiki/eAPI-v1.7-EN#getpost-httpsapiplatebnibranacsobczapiv17echo-

ketannsangani12 commented 7 years ago

i have tried with echo with v 1.6 its giving me 404 error and with 1.7 its giving me 400 error

mrazekl commented 7 years ago

this is example for production environment. U are in TESTING environment. Must use echo for https://iapi.iplatebnibrana.csob.cz/api/v1.6/echo

ketannsangani12 commented 7 years ago

Huhhhh got a response

{"dttm":"20171015063622","signature":"QLckyR8pPVBSsYPleXPeFdPhDgwmvj3TFQRNZDLDcJAF+VA+gDPg/NxC+syBu5pa+yLp+woa2XfKKNetCDXB/xdTdeQJk1GBfIGQ+0svXQUjhjuAAZF2gDvfG9g01clqZRz4vIVeteBMfTM33ccxkVOQ1VaTal0e/w4b9r7E5YF86gituZG78E6fi+6sIYgJgCpqTV4sc7dcCh1C9GFP6ynXs4aOPhEfLU/lvPoUAy2Zzwbsp1DoNXPKsCAD2PrxX0jz7CW61GbWPZqKEeCtSY4rs93fhkJHxD56+FsjdcSUlA+qnu9evJ2gYmDn80CiK68pEXivnstB/QmuRLk5/Q==","resultCode":0,"resultMessage":"OK"}

ketannsangani12 commented 7 years ago

now please tell me what should i do?

mrazekl commented 7 years ago

well done :-) now you can try payment/init (https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init...) with your data (merchantID, returnUrl etc...), example from GitHub:

curl -v –X POST https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init \ -H "Content-Type:application/json" \ -d '{ "merchantId":"012345", "orderNo":"5547", "dttm":"20140425131559", "payOperation":"payment", "payMethod":"card", "totalAmount":1789600, "currency":"CZK", "closePayment": true, "returnUrl":"https://yourshop.com/gateway-return", "returnMethod":"POST", "cart":[ { "name": "Purchase on yourshop.com", "quantity": 1, "amount": 1789600, "description":"Lenovo ThinkPad Edge E540" }, { "name": "Shipping", "quantity": 1, "amount": 0, "description": "DHL Express" } ], "description":"Purchase on yourshop.com (Lenovo ThinkPad Edge E540, DHL Express)", "merchantData":"some-base64-encoded-merchant-data", "language":"CZ", "signature":"base64-encoded-signature-of-payment-request" }'

ketannsangani12 commented 7 years ago

{
"merchantId":"M1MIPS1716", "orderNo":"123456", "dttm":"20171015070931", "payOperation":"payment", "payMethod":"card", "totalAmount":100, "currency":"CZK", "closePayment":true, "returnUrl":"http:\/\/localhost\/csob\/return.php", "returnMethod":"POST", "cart":[
{
"name":"Shopping at ...", "quantity":1, "amount":100, "description":"Lenovo ThinkPad Edge E540..." }, {
"name":"Shipping", "quantity":1, "amount":0, "description":"PPL" } ], "description":"N\u00e1kup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)", "merchantData":null, "customerId":"1234", "language":"CZ", "signature":"NEv+\/DXAb2IKHzLhX1pE9cBH7qXnKRkMUZMKUPBb45yinpD0akVIlqWLDIH6J66hNxhZIH2A2cmQ9JH1FSvlmKtYK6nmAQx3mTEBOC5jEdkihnCBHQX\/YydhyF6m6bziotXYsPtbUxHmt7ogzVj5oxl8ShKUkIeWRMc5Gb5p23OMtSyZlPJM2jgK4plsLEzFWiKISpITzxR32dcR3vbVGRcfXTmCZKl7yNzgQmwKTzIWFyNWil0Ft2X5BsePz54u45Q2d5ci4iF+pDtlatYDq2HxcA\/uOhsTWeZlprf7b\/qkKMoEPCffYl998guxP6mtWegcP3M420OiOxxWNCEz3w==" } I am trying but still getting error 400 response

mrazekl commented 7 years ago

can you try replace this for example I wrote above? with your MerchantID etc ??

ketannsangani12 commented 7 years ago

I have tried with same only merchantData is null but its not mandatory so this should work but still not worked {
"merchantId":"M1MIPS1716", "orderNo":5547, "dttm":20140425131559, "payOperation":"payment", "payMethod":"card", "totalAmount":1789600, "currency":"CZK", "closePayment":true, "returnUrl":"https:\/\/yourshop.com\/gateway-return", "returnMethod":"POST", "cart":[
{
"name":"Purchase on yourshop.com", "quantity":1, "amount":1789600, "description":"Lenovo ThinkPad Edge E540" }, {
"name":"Shipping", "quantity":1, "amount":0, "description":"DHL Express" } ], "description":"Purchase on yourshop.com (Lenovo ThinkPad Edge E540, DHL Express)", "language":"CZ", "signature":"Q+J9Dw7roP7p6lzLojocs3zFi2OJn50CmKMJbw6DAEYX0mD4UV8JujfW8H58Mh\/vfjC8tCCIBBnE6tgH6P8I5iohb\/RpNC+re8LvP5UJwBvhPmN1RSOaseTriXFKU4XhiJtlvU6liGqQPbTOWZtN3pl2todZuYx5BAhg22Fpotnn4SED2x1Dj4sGJdU3vDKJfYX0pSuS10Qqs47bu6cZGgkb8UBpLkTiC7uhyxnLiWjs7wIqaxF0KFbwLA0Q\/j9Mu2C4F4tVCI8+oJ9BuBlr3Y4P6FhNYZpSkj+aBRF0TvhQfU4UTPEsFJ8ns0I7pA34OVYkSmC0\/hYcZmkh+qvgSA==" }

mrazekl commented 7 years ago

you have still the same problem with signature. I don´t know how you generated it. But you must have a valid "returnUrl" parameter, "https://yourshop.com/gateway-return" is example and doesn´t exist. Can you try this with valid MerchantID and returnUrl of your eshop. Also can you try set up "closePayment": 0

https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init \ -H "Content-Type:application/json" \ -d '{ "merchantId":"012345", "orderNo":"5547", "dttm":"20140425131559", "payOperation":"payment", "payMethod":"card", "totalAmount":1789600, "currency":"CZK", "closePayment": true, "cart":[ { "name": "Nákup: vasobchod.cz", "quantity": 1, "amount": 1789600, "description":"Lenovo ThinkPad Edge E540" }, { "name": "Poštovné", "quantity": 1, "amount": 0, "description": "Doprava PPL" } ], "description":"Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)", "merchantData":"some-base64-encoded-merchant-data", "language":"CZ", "returnUrl":"https://vasobchod.cz/gateway-return", "returnMethod":"POST", "signature":"base64-encoded-signature-of-payment-request" }'

ketannsangani12 commented 7 years ago

I have used same method which used in Echo API following are data to create signature which generated with pipes as documentation please check anything wrong: ''M1MIPS1716|5547|20140425131559|payment|card|1789600|CZK|0|http://localhost/csob/return.php|POST|Purchase on yourshop.com|1|1789600|Lenovo ThinkPad Edge E540|Shipping|1|0|DHL Express|Purchase on yourshop.com (Lenovo ThinkPad Edge E540, DHL Express)|CZ''

mrazekl commented 7 years ago

"http://localhost/csob/return.php" doesn´t exist, enter a valid adress from my last example must be string data for generate like this: "012345|5547|20140425131559|payment|card|1789600|CZK|true|https://vasobchod.cz/gateway-return|POST|Nákup: vasobchod.cz|1|1789600|Lenovo ThinkPad Edge E540|Poštovné|1|0|Doprava PPL|Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)|some-base64-encoded-merchant-data|CZ" but with your specific data like merchantID, returnUrl so you can compare.

ketannsangani12 commented 7 years ago

its on my local server pc mate so url is type of that

mrazekl commented 7 years ago

OK, I am sorry, but you still havn´t valid signature. Can you try this:

https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init -H "Content-Type:application/json" -d '{ "merchantId":"M1MIPS1716", "orderNo":"5555", "dttm":"20171015121559", "payOperation":"payment", "payMethod":"card", "totalAmount":1789600, "currency":"CZK", "closePayment": 0, "cart":[ { "name": "Nákup: vasobchod.cz", "quantity": 1, "amount": 1789600, "description":"Lenovo ThinkPad Edge E540" }, { "name": "Poštovné", "quantity": 1, "amount": 0, "description": "Doprava PPL" } ], "description":"Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)", "merchantData":"some-base64-encoded-merchant-data", "language":"CZ", "returnUrl":"http://localhost/csob/return.php", "returnMethod":"POST", "signature":"base64-encoded-signature-of-payment-request" }'

with these string for signature: "M1MIPS1716|5555|20171015121559|payment|card|1789600|CZK|0|http://localhost/csob/return.php|POST|Nákup: vasobchod.cz|1|1789600|Lenovo ThinkPad Edge E540|Poštovné|1|0|Doprava PPL|Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)|some-base64-encoded-merchant-data|CZ"

code in BASE64_ENCODE(RSA_SIGN(string above))

then i check sevice log.

ketannsangani12 commented 7 years ago

Yes i have already used that please check below screenshot signature

mrazekl commented 7 years ago

I saw in service log you still trying orderNo: 5547, can you set up example from my last comment?

ketannsangani12 commented 7 years ago

Still not working please check

mrazekl commented 7 years ago

i checked, you dont use all parameters, i saw you didn´t set up actual "dttm" and "closePayment":0, can you repair and run?

ketannsangani12 commented 7 years ago

Now check please i did not send only merchantData other params as your example

aKocian commented 7 years ago

Hello, Try to send "orderNo": 5555 as string ---> "orderNo": "5555", I see that you are sending it with number value.

aKocian commented 7 years ago

Also check if u are using https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init instead of https://iapi.iplatebnibrana.csob.cz/api/v1.6/payment/init/

ketannsangani12 commented 7 years ago

Still not working order no sent as string

ketannsangani12 commented 7 years ago

Please help me how can i resolve this?It is difficult to find what is the exact problem?