Lanka Developers Community

    Lanka Developers

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Shop

    Help me on Payment Gateway in PHP

    Web Development
    php payment gateway
    3
    7
    1072
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Theesan
      Theesan last edited by

      I am a trainee web developer, developing a eCommerce site, which need to be linked with payment gateway.
      I got the payment gateway details from the bank.
      But I don't know how to use the API, what are the parameters should be passed and what will I get back.

      Better if I get a sample code set.

      1 Reply Last reply Reply Quote 0
      • dev_lak
        dev_lak last edited by

        have you received the API doc from bank? all the details are in that document, if you share the API document, we can help you

        Theesan 1 Reply Last reply Reply Quote 0
        • Theesan
          Theesan @dev_lak last edited by

          @dev_lak Have you done the dealings with Commercial Bank's Payment gateway..?
          This is the integration link they send me. https://test-gateway.mastercard.com/api/documentation/integrationGuidelines/index.html?locale=en_US

          1 Reply Last reply Reply Quote 0
          • dev_lak
            dev_lak last edited by

            @Theesan in this doc, they have 4 checkout models, first decide what is suitable model for you,

            1. Hosted Checkout
            2. Hosted Session
            3. Direct Payment
            4. Batch

            and then read the relavant integration guid,
            and also this doc has some sample codes, see this - https://test-gateway.mastercard.com/api/documentation/downloads/index.html?locale=en_US

            1 Reply Last reply Reply Quote 2
            • root
              root Linux Help last edited by

              you need to use, php curl request to the payment gateway endpoint with required payment method data. that's only. then use request endpoint response to show the errors and success infomation to the end user.

              Theesan 1 Reply Last reply Reply Quote 0
              • Theesan
                Theesan @root last edited by

                @root I don't know how to use it. Do you have any sample code?

                dev_lak 1 Reply Last reply Reply Quote 0
                • dev_lak
                  dev_lak @Theesan last edited by

                  @Theesan

                  <?php
                  // A sample PHP Script to POST data using cURL
                  // Data in JSON format
                   
                  $data = array(
                      'username' => 'tecadmin',
                      'password' => '012345678'
                  );
                   
                  $payload = json_encode($data);
                   
                  // Prepare new cURL resource
                  $ch = curl_init('https://api.example.com/api/1.0/user/login');
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
                  curl_setopt($ch, CURLOPT_POST, true);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
                   
                  // Set HTTP Header for POST request 
                  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                      'Content-Type: application/json',
                      'Content-Length: ' . strlen($payload))
                  );
                   
                  // Submit the POST request
                  $result = curl_exec($ch);
                   
                  // Close cURL session handle
                  curl_close($ch);
                   
                  ?>
                  

                  this is a curl example.

                  1 Reply Last reply Reply Quote 1
                  • 1 / 1
                  • First post
                    Last post

                  0
                  Online

                  3.7k
                  Users

                  1.3k
                  Topics

                  5.3k
                  Posts

                  • Privacy
                  • Terms & Conditions
                  • Donate

                  © Copyrights and All right reserved Lanka Developers Community

                  Powered by Axis Technologies (PVT) Ltd

                  Made with in Sri Lanka

                  | |