1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How can I send requests via HTTP Post to URL in php

Discussion in 'PHP' started by alimoses, Nov 1, 2015.

  1. #1
    I have website that has page for donation. Merchants registered on the Gateway are to send transaction requests to GTPay via HTTP Post to URLhttps://ibank.gtbank.com/GTPay/Tranx.aspx

    When I submit my request I see this page of the above URL displayed inside my donation page instead of taking me to the URL Below is my code:

    $url ='https://ibank.gtbank.com/GTPay/Tranx.aspx';
    $fields = array('gtpay_mert_id'=> urlencode($gtpay_mert_id),'gtpay_tranx_id'=> urlencode($gtpay_tranx_id),'gtpay_tranx_amt'=> urlencode($gtpay_tranx_amt),'gtpay_tranx_curr'=> urlencode($gtpay_tranx_curr),'gtpay_cust_id'=> urlencode($gtpay_cust_id),'gtpay_tranx_noti_url'=> urlencode($gtpay_tranx_noti_url),'gtpay_hash'=> urlencode($gtpay_hash));


    //url-ify the data for the POSTforeach($fields as $key=>$value){ $fields_string .= $key.'='.$value.'&';}
    rtrim($fields_string,'&');

    $form_files=array();
    $form_options=array('cookies'=> array('auth'=> $auth ));
    http_post_fields($url, $fields, $form_files, $form_options);//open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);

    //execute post
    $result = curl_exec($ch);

    //close connection
    curl_close($ch);

    Note: The donation amount entered is to be multiplied by 100 and the value of the parameter gtpay_hash(a hidden field in the form) to be submitted is supposed to be sha512 of a concatenation of the values of the following parameters of the form. gtpay_mert_id,gtpay_tranx_id,gtpay_tranx_amt,gtpay_tranx_curr,gtpay_cust_id,gtpa‌y_tranx_noti_url,hashkey. How do I get the values entered in the form, perform the hash on those values and assign to the hidden parameter and submit to the url along with the other values entered in the form?
     
    alimoses, Nov 1, 2015 IP
  2. Webpass.io

    Webpass.io Member

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    33
    #2
    Can you link to the documentation provided by gtbank?

    Also, are you responsible for paying a fee if there's a disputed transaction and there's a chargeback? If so, it might be safer if you use a service where you don't have to worry about these things (I think doing donations through paypal may be one such service, but I'm not completely sure). Otherwise, you're open to fraudsters who use your site to test a bunch of stolen credit cards, and you pay a chargeback on each successful transaction that is later disputed.

    https://www.reddit.com/r/startups/comments/3lehge/what_i_learned_about_chargebacks_after_getting/
     
    Webpass.io, Nov 2, 2015 IP
  3. alimoses

    alimoses Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    https://ibank.gtbank.com/GTPay/Tranx.aspx
     
    alimoses, Nov 3, 2015 IP
  4. Webpass.io

    Webpass.io Member

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    33
    #4
    That link doesn't provide any documentation that I can see.
     
    Webpass.io, Nov 3, 2015 IP
  5. alimoses

    alimoses Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
     
    alimoses, Nov 3, 2015 IP
  6. alimoses

    alimoses Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    Sorry, I typed the initial link in error
    Below is the correct link
    https://ibank.gtbank.com/gtpay/integrationapi/mman-tech.html
     
    alimoses, Nov 3, 2015 IP
  7. Webpass.io

    Webpass.io Member

    Messages:
    8
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    33
    #7
    If I'm reading this right, then your visitor is supposed to make the POST request with their browser, not you on the backend. On the gtbank page, you can see an example form. Put that form somewhere on your page, and relabel the 'submit' button to 'donate' or whatever you like. You won't need the javascript inside the body tag. When someone clicks on the button in their browser, it should take them to the gtbank page to complete the transaction.
     
    Webpass.io, Nov 3, 2015 IP