Android Question PostString Question

tufanv

Expert
Licensed User
Longtime User
Hello,

I am trying to implement a payment method to android app. For 2 weeks I am trying but There is a problem at some place. They sent me an example code from java which needed to be posted via http post method can you confirm that this java codes http post paramaters :.

B4X:
 params.put("MERCHANT",merchant_name);
    params.put("ORDER_REF",order_ref_number);
    params.put("ORDER_DATE",order_date);

equals to b4a ? :

B4X:
connection.PostString("url","MERCHANT="&merchant_name&"&"&"ORDER_REF="&order_ref_number&"&"&"ORDER_DATE="&order_date"


Thanks
 

sorex

Expert
Licensed User
Longtime User
what comes after "&order_date" ?

is that last double quote a ) in your actual code or is there more?
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
which means :

B4X:
connection.PostString("url","MERCHANT="&merchant_name&"&"&"ORDER_REF="&order_ref_number&"&"&"ORDER_DATE="&order_date")

there is no error while sending the code. Server response return a hash mismatch error which is the hmac_md5 of sent values when the keys are sorted alphabeticly . The servers calculated hash and my calculated hash are not equal. So I figured that there may be a problem while sending the post string because i am sure that my hash is correct , I verified it via the server.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
that shouldn't even compile since there is a " too much there
Why ? I am just creating a single string with using & . Maybe thats the problem. Can you suggest a better way ? Becausei have to send about 30 variable to payment server like billing address cc number cc ownder etc...
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Build the string and log it. Maybe there is an extra & somewhere.
Erel ,
I owe you a dinner one day. OMG I am spending 5 hours everyday to solve this issue for at least 2 weeks. I checked everything , I also checked the &s many times but when i log it , it was very easy to see.
I can't believe. Thanks . I successfully implemented payU global cc payment system, with or without the 3ds verification. !
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
when things can become a mess (like here ;) ) it's wise to use the multiline string features to keep a good overview over it

B4X:
Dim p As String
Dim p1 As String="string1"
Dim p2 As String="string3"
Dim p3 As String="string3"
p="p1="& p1 & _
  "&p2="& p2 & _
  "&p3="& p3
Log(p)   'p1=string1&p2=string3&p3=string3

or use the variable update method p=p & "&p2=" & p2 etc but it's more typing and not so clear to follow as the other one.

not sure if it works with the smart strings method as it seems to add real linefeeds to the string after each line.
 
Upvote 0
Top