Folks,

I have never programmed any API stuff. Let us change this tonight.
I want to allow people to pay me with BitCoin on my website.
This you see below is API vofr of the Official BitCoin Payment Gateway.
Now, show me how to integrate this on my website. Meaning, show how to write the html form so the following api php code is integrated with the html form.

Php Api code:
https://codepal.ai/code-generator/query/wTcOQ1Ps/php-bitcoin-payment-gateway-api-confirmation

/**
 * This function confirms a payment made to a website using the official Bitcoin payment gateway API.
 *
 * @param string $transaction_id The unique transaction ID generated by the Bitcoin payment gateway
 * @param float $amount The amount of Bitcoin paid by the customer
 * @param string $customer_address The Bitcoin address of the customer who made the payment
 * @param string $website_address The Bitcoin address of the website receiving the payment
 * @param string $api_key The API key provided by the Bitcoin payment gateway
 *
 * @return bool Returns true if the payment is confirmed, false otherwise
 */
function confirmBitcoinPayment($transaction_id, $amount, $customer_address, $website_address, $api_key) {
    // Initialize cURL
    $ch = curl_init();

    // Set the cURL options
    curl_setopt($ch, CURLOPT_URL, "https://api.bitcoinpaymentgateway.io/v1/confirm_payment");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
        'transaction_id' => $transaction_id,
        'amount' => $amount,
        'customer_address' => $customer_address,
        'website_address' => $website_address,
        'api_key' => $api_key
    ]));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Execute the cURL request
    $response = curl_exec($ch);

    // Check for errors
    if (curl_errno($ch)) {
        error_log("Error confirming Bitcoin payment: " . curl_error($ch));
        curl_close($ch);
        return false;
    }

    // Close the cURL connection
    curl_close($ch);

    // Parse the response
    $response = json_decode($response, true);

    // Check if the payment is confirmed
    if ($response['status'] == 'confirmed') {
        return true;
    } else {
        return false;
    }
}

Your sample html form should give me an idea how things should get integrated.

@dani

It's been 6yrs since I started learning php. Do not you think it is about time I started learning the api stuffs from your forum ? If so, then can you kindly teach us the basics of api stuffs ?
Let us start-off with the scripts I already coded.
Bear in mind, I do not have a website yet. But let's imagine that I have a membership website and I want to only allow paid membership accounts. Meaning, you have to pay to open an account. Makes sense ? (Something you can add on your own forum perhaps one day).

Anyway, few months back, I coded a registration page which you see below: registration.php.

Now, GoUrl.io is a free payment gateway for BitCoin. You can read about them here:
https://gourl.io/

They have no transaction fees, unlike coinbase.com. Only official BitCoin Block Chain transaction fees.
Anyway, imagine I want to add their payment feature on my website where only payers can open member accounts.
Now, how can I integrate their following php script on my website by making it compatible with my html regsitartion form or vice versa ?
Here is my html registration form:

<?php

//TEMPLATE
//Replace $_SESSIONs with $_COOKIEs. (If applicable).
?>
<?php
session_start();
ini_set("display_errors",1);
ini_set("display_startup_errors",1);
error_reporting(E_ALL);

//require('mail_TEMPLATE.php');
include('header_site.php');
include('footer_site.php');
?>
<html>
<head>
<title>Register Page</title>
</head>
<body style="background-color:yellow;font-family:verdana;font-size:15px;color:white;text-align:left;">
<div style="background-color:white;" name="header_pane" id="header_pane" align="center" size="50%" align="center" size="50%">
<?php echo header_site();?>
</div>
<br>
<br>
<br>
<div style="background-color:powderblue;" name="central_pane" id="central_pane" align="center" width="50%">
<?php
//Script Flow starts here.
//Perform when page loads no matter why and how.

if($_SERVER['REQUEST_METHOD'] === 'POST')
{
    check_user_input();
}

if(ISSET($_GET['reset']))
{
    session_destroy();
    echo 'Registration Resetted <br>';
    echo '<a href='.'"'.'register_TEMPLATE.php' .'"' .'>' .'Register</a>';
}

if(!ISSET($_SESSION['show_form']) || EMPTY($_SESSION['show_form'])) //Do not remove this condition.
{
    echo registration_form_part_one();
}
elseif($_SESSION['show_form']=='registration_form_part_two')
{
    echo registration_form_part_two();
}
elseif($_SESSION['show_form']=='registration_form_part_three')
{
    echo registration_form_part_three();
}
else
{
    echo registration_form_part_one();
}

//NOTE: FUNCTIONS FROM THIS POINT ONWARD.
function unset_sessions()
{
    UNSET($_SESSION['domain']);
    UNSET($_SESSION['domain_email_account']);
    UNSET($_SESSION['domain_email']);
    UNSET($_SESSION['show_form']);
}

function registration_form_part_one()
{
    ?>
    <div style='font-family:verdana;font-size:15px;color:black;text-align:center;' name="register_form" id="register_form" align="center" size="50%">
    <form style="background-color:white;" method="POST" action="" name="register_form_p1" id="register_form_p1">
    <legend style='font-family:verdana;font-size:15px;color:black;text-align:center;'><b>Registration - Part 1/3</b></legend>
    <fieldset>
    <label for="domain">Domain</label>
    <input type="text" name="domain" id="domain" size="50" minlength="5" maxlength="253" title="Input your Domain" placeholder="yourdomain.tld">
    <br>
    </fieldset>
    <fieldset>
    <button type="submit" name="register" id="register" title="Submit Form">Register - Part 1/3</button>
    </fieldset>
    </form>
    </div>
    <?php
}

function registration_form_part_two()
{
    $domain = $_SESSION["domain"];
    $domain_length = strlen($_SESSION["domain"]);
    ?>
    <div style='font-family:verdana;font-size:15px;color:black;text-align:center;' name="register_form" id="register_form" align="center" size="50%">
    <form style="background-color:white;" method="POST" action="" name="register_form_p2" id="register_form_p2" width="50%">
    <legend style='font-family:verdana;font-size:15px;color:black;text-align:center;'><b>Registration - Part 2/3</b></legend>
    <fieldset>
    <label for="domain_email_account">Domain Email</label>
    <input type="text" name="domain_email_account" id="domain_email_account" size="50" minlength="7" maxlength="255" title="Input your Email Account belong to your Domain" placeholder="account">@<input type="text" name="domain_email_domain" id="domain_email_domain" size="$domain_length" minlength="7" maxlength="255" title="Input your Email Domain" value="<?php echo $domain;?>" disabled>
    <br>
    </fieldset>
    <fieldset>
    <button type="submit" name="register" id="register" title="Submit Form">Register - Part 2/3</button>
    </fieldset>
    </form>
    </div>
    <?php
}

function registration_form_part_three()
{
    ?>
    <div style='font-family:verdana;font-size:15px;color:black;text-align:center;' name="register_form" id="register_form" align="center" size="50%">
    <form style="background-color:white;" method="POST" action="" name="register_form_p3" id="register_form_p3" width="50%">
    <legend style='font-family:verdana;font-size:15px;color:black;text-align:center;'><b>Registration - Part 3/3</b></legend>
    <fieldset>
    <label for="password">Password</label>
    <input type="password" name="password" id="password" size="25" minlength="8" maxlength="25" title="Input your Password, Nibinun 8 characters. Maximum 25 characters." placeholder="Password">
    <br>
    </fieldset>
    <fieldset>
    <button type="submit" name="register" id="register" title="Submit Form">Register - Part 3/3!</button>
    </fieldset>
    </form>
    </div>
    <?php
}

//Check User inputs.
function check_user_input()
{
    if(ISSET($_POST['domain']) && !EMPTY(trim($_POST['domain'])))
    {
        $_SESSION['domain'] = trim($_POST['domain']);
        $_SESSION['show_form'] = 'registration_form_part_two';
    }
    else
    {
        $_SESSION['show_form'] = 'registration_form_part_one';
    }

    if(ISSET($_POST['domain_email_account']) && !EMPTY(trim($_POST['domain_email_account'])))
    {
        $_SESSION['domain_email'] = trim($_POST['domain_email_account']).'@'.$_SESSION['domain'];
        $_SESSION['show_form'] = 'registration_form_part_three';
    }
    else
    {
        $_SESSION['show_form'] = 'registration_form_part_two';
    }

    if(ISSET($_POST['password']) && !EMPTY(trim($_POST['password'])))
    {
        process_registration_form();
    }
    else
    {
        $_SESSION['show_form'] = 'registration_form_part_three';
    }
}

//Process the Registration Form.
function process_registration_form()
{
    //Query DB.
    //Check if User already registered or not.
    mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
    $conn = mysqli_connect("localhost","root","","buzz"); //mysqli_connect("server","user","password","db");

    $stmt = mysqli_stmt_init($conn);
    $sql_count = "SELECT COUNT(id) FROM domains WHERE domain = ? OR domain_email = ?";

    if(mysqli_stmt_prepare($stmt,$sql_count))
    {
        mysqli_stmt_bind_param($stmt,"ss",$_SESSION['domain'],$_SESSION['domain_email']);
        mysqli_stmt_execute($stmt);
        mysqli_stmt_bind_result($stmt,$rows_count);
        mysqli_stmt_fetch($stmt);

        if($rows_count>0) //User already registered. So, kill Registration Process.
        {
            mysqli_stmt_close($stmt);
            mysqli_close($conn);

            unset_sessions();
            echo '<b>User already registered!</b><br>';
            echo '<a href='.'"'.'login_TEMPLATE.php' .'"' .'>' .'Login</a>';
        }
        else
        {
            submit_registration_form();
        }
    }
    else
    {
        unset_sessions();
        echo '1. Something went wrong. Please try again later!';
    }
}

function submit_registration_form()
{
    //User not registered.
    //So, submit Registration Details into Database.
    mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
    $sql = "INSERT into domains (domain,domain_email,password) VALUES (?,?,?)";

    if(mysqli_stmt_prepare($stmt,$sql))
    {
        echo __LINE__; echo '<br>';//DELETE

        $password_hashed = password_hash(trim($_POST['password']),PASSWORD_DEFAULT);
        mysqli_stmt_bind_param($stmt,"sss",$_SESSION['domain'],$_SESSION['domain_email'],$password_hashed);
        mysqli_stmt_execute($stmt);

        if(mysqli_stmt_affected_rows($stmt)) //Registration Successful. So, give Notification.
        {
            echo 'Registration successful!<br>';
            echo '<a href='.'"'.'login_TEMPLATE.php' .'"' .'>' .'Login</a>';
        }
        else //Registration a Failure. So, give Notification.
        {
            echo '3. Something went wrong. Please try again later!';
        }
        mysqli_stmt_close($stmt);
        mysqli_close($conn);
        unset_sessions();
    }
    else
    {
        unset_sessions();
        echo '2. Something went wrong. Please try again later!';
    }
}
?>
</div>
<br>
<br>
<br>
<div style="background-color:white;" name="footer pane" id="footer pane" align="center" size="50px" width="33%">
<?php echo footer_site();?>
</div>
</body>
</html>

After you have familiarised or tested the above registration.php out, check the following payment gateway php code from GoUrl.io:
Pay-Per-Registration - earn money on site registration
https://gourl.io/lib/examples/pay-per-registration-multi.php
https://gourl.io/bitcoin-payment-gateway-api.html#p4

?   
    require_once( "cryptobox.class.php" );

    /**** CONFIGURATION VARIABLES ****/ 

    $userID         = "";               // new user, it will autogenerate userID and save in cookies
    $userFormat     = "COOKIE";         // save userID in cookies (or you can use IPADDRESS, SESSION)
    $orderID        = "signuppage";     // Registration Page   
    $amountUSD      = 1;                // price per registration - 1 USD
    $period         = "NOEXPIRY";       // one time payment for each new user, not expiry
    $def_language   = "en";             // default Payment Box Language
    $def_payment    = "bitcoin";        // default Coin in Payment Box

    // List of coins that you accept for payments
    // For example, for accept payments in bitcoins, dogecoins use - $available_payments = array('bitcoin', 'dogecoin'); 
    $available_payments = array('bitcoin', 'bitcoincash', 'bitcoinsv', 'litecoin', 'dash', 'dogecoin', 'speedcoin', 'reddcoin', 'potcoin', 
                        'feathercoin', 'vertcoin', 'peercoin', 'monetaryunit');


    // Goto  https://gourl.io/info/memberarea/My_Account.html
    // You need to create record for each your coin and get private/public keys
    // Place Public/Private keys for all your available coins from $available_payments

    $all_keys = array(  
        "bitcoin"  => array("public_key" => "-your public key for Bitcoin box-",  "private_key" => "-private key for Bitcoin box-"),
        "dogecoin" => array("public_key" => "-your public key for Dogecoin box-", "private_key" => "-private key for Dogecoin box-")
        // etc.
    ); 

    /********************************/


    // Re-test - that all keys for $available_payments added in $all_keys 
    if (!in_array($def_payment, $available_payments)) $available_payments[] = $def_payment;  
    foreach($available_payments as $v)
    {
        if (!isset($all_keys[$v]["public_key"]) || !isset($all_keys[$v]["private_key"])) 
            die("Please add your public/private keys for '$v' in \$all_keys variable");
        elseif (!strpos($all_keys[$v]["public_key"], "PUB"))  die("Invalid public key for '$v' in \$all_keys variable");
        elseif (!strpos($all_keys[$v]["private_key"], "PRV")) die("Invalid private key for '$v' in \$all_keys variable");
        elseif (strpos(CRYPTOBOX_PRIVATE_KEYS, $all_keys[$v]["private_key"]) === false) 
            die("Please add your private key for '$v' in variable \$cryptobox_private_keys, file cryptobox.config.php.");
    }

    // Optional - Language selection list for payment box (html code)
    $languages_list = display_language_box($def_language);

    // Optional - Coin selection list (html code)
    $coins_list = display_currency_box($available_payments, $def_payment, $def_language, 42, "margin: 5px 0 0 20px");
    $coinName = CRYPTOBOX_SELCOIN; // current selected coin by user

    // Current Coin public/private keys
    $public_key  = $all_keys[$coinName]["public_key"];
    $private_key = $all_keys[$coinName]["private_key"];


    /** PAYMENT BOX **/
    $options = array(
            "public_key"  => $public_key,   // your public key from gourl.io
            "private_key" => $private_key,  // your private key from gourl.io
            "webdev_key"  => "",            // optional, gourl affiliate key
            "orderID"     => $orderID,      // order id
            "userID"      => $userID,       // unique identifier for every user
            "userFormat"  => $userFormat,   // save userID in COOKIE, IPADDRESS or SESSION
            "amount"      => 0,             // price in coins OR in USD below
            "amountUSD"   => $amountUSD,    // we use price in USD
            "period"      => $period,       // payment valid period
            "language"    => $def_language  // text on EN - english, FR - french, etc
    );

    // Initialise Payment Class
    $box = new Cryptobox ($options);

    // coin name
    $coinName = $box->coin_name(); 


    // Form Data
    // --------------------------
    $fname      = (isset($_POST["fname"])) ? $_POST["fname"] : "";
    $femail     = (isset($_POST["femail"])) ? $_POST["femail"] : "";
    $fpassword  = (isset($_POST["fpassword"])) ? $_POST["fpassword"] : "";

    $error = "";
    $successful = false;

    if (isset($_POST) && isset($_POST["fname"]))
    {
        if (!$fname)            $error .= "<li>Please enter Your Name</li>";
        if (!$femail)           $error .= "<li>Please enter Your Email</li>";
        if (!$fpassword)        $error .= "<li>Please enter Your Password</li>";
        if (!$box->is_paid())   $error .= "<li>".$coinName."s have not yet been received</li>";
        if ($error)             $error  = "<br><ul style='color:#eb4847'>$error</ul>";

        if ($box->is_paid() && !$error)
        {
            // Successful Cryptocoin Payment received

            // Your code here - 
            // save user data in db / register new user ...
            // ...
            // ...

            // Set Payment Status to Processed
            $successful = true;
            $box->set_status_processed();

            // Optional, cryptobox_reset() will delete cookies/sessions with userID and
            // new cryptobox with new payment amount will be show after page reload.
            // Cryptobox will recognize user as a new one with new generated userID
            $box->cryptobox_reset();
        }
    }


    // ...
    // Also you can use IPN function cryptobox_new_payment($paymentID = 0, $payment_details = array(), $box_status = "") 
    // for send confirmation email, update database, update user membership, etc.
    // You need to modify file - cryptobox.newpayment.php, read more - https://gourl.io/api-php.html#ipn
    // ...



?>

<!DOCTYPE html>
<html><head>
<title>Pay-Per-Registration Cryptocoin (payments in multiple cryptocurrencies) Payment Example</title>
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='Expires' content='-1'>
<script src='cryptobox.min.js' type='text/javascript'></script>
</head>
<body style='font-family:Arial,Helvetica,sans-serif;font-size:14px;color:#666;margin:0'>
<div align='center'>
<br><h1>Example - Website Registration Form. Protection against spam!</h1>
<br><img alt='Cryptocoin Registration Form' border='0' src='https://gourl.io/images/example8.png'>
<a name='i'></a>

<?php if ($successful): ?>

    <div align='center' style='margin:40px;font-size:24px;color:#339e2e;font-weight:bold'>
        You have been successfully registered on our website!</div>

<? else: ?>

    <form name='form1' style='font-size:14px;color:#444' action="pay-per-registration-multi.php#i" method="post">
        <table cellspacing='20'>
            <tr><td colspan='2'><b>NEW USER</b><?= $error ?><input type='text' style='display: none'>
                <input type='password' style='display: none'></td></tr>
            <tr><td width='100'>Name: </td><td width='300'><input style='padding:6px;font-size:18px;' size='30' 
                type="text" name="fname" value="<?= $fname ?>"></td></tr>
            <tr><td>Email: </td><td><input style='padding:6px;font-size:18px;' size='40' type="text" 
                name="femail" value="<?= $femail ?>"></td></tr>
            <tr><td>Password: </td><td><input style='padding:6px;font-size:18px;' size='35' type="password" 
                name="fpassword" value="<?= $fpassword ?>"><br><br></td></tr>
        </table>
    </form>

    <div style='width:600px;padding-top:10px'>
            <div style='font-size:12px;<? if ($box->is_paid()) echo "margin:5px 0 5px 390px;"; 
                else echo "margin:5px 0 5px 390px; position:absolute;" ?>'>Language: &#160; <?= $languages_list ?></div>
            <? if (!$box->is_paid()) echo "<div align='left'>".$coins_list."</div>";  ?>
            <?= $box->display_cryptobox(true, 530, 230, "border-radius:15px;border:1px solid #eee;padding:3px 6px;margin:10px") ?>
    </div>

    <?php if (!$box->is_paid()): ?>
        <br>* You need to pay <?= $coinName ?>s (~<?= $amountUSD ?> US$) for register on our website<br>
    <? endif; ?>    

    <br><br>
    <button onclick='document.form1.submit()' style='padding:6px 20px;font-size:18px;'>Register</button>

<? endif; ?>    

</div><br><br><br><br><br><br>
</body>
</html>

Which lines do I need to change in the above code to make it compatible with my registration form or if I have to do vice versa where I have to modify my registration.php html form, then which parts do I have to modify ?
If you do not mind, do make changes on the above 2 codes and show me where you changed what. That should give me work experience on api stuffs.
Once I have learnt the above with your help, I will then move-on to the:
Pay-Per-Post - sell rights to post on your website
https://gourl.io/lib/examples/pay-per-post-multi.php

And integrate that with my current "List Item" script and show you how I did it all by myself for you to check whether I integrated correctly or not. If I did everything correct, then you can pat me in my back. I will take the pat as a certificate. And, then I can experiment with other APIs like google, twitter, youtube etc and consider my 5yrs of php learning has no gone to waste and finally I am getting somewhere learning the adv stuffs. Thanks to YOU.
Yes?

Thanks

You have to use an HTTP redirect to redirect the website visitor over to whatever website they go to to pay with their Bitcoins. Once they've done that, you can use the above PHP code to verify the payment went through properly, by passing in information about the supposed transaction, as well as your app's API key, into the API. Note that this is unique to this specific API.

You would integrate it into what you have above by removing lines 218/219 where you print out that registration was successful, and instead do an HTTP redirect to the Bitcoin payment gateway so the new user can pay. Then, you'd create a new PHP page with the confirmBitcoinPayment() code for the Bitcoin gateway to redirect to if the payment is successful. I'm not sure if that made sense.

I'm not sure if you have any interest in it, but you can check out DaniWeb's API as well.

commented: Yes. Made sense! Thanks! +0

@dani

Seems like you are doing something interesting with your API stuff.
Anyway, 0Auth stuff is way over my head for now as I tried it a yr ago or so but api stuffs did not sink into my head back then atall. And so, back to square one again to learn the basics.

Nowm on the Bitcoin payment confirmation script, I notice these following $vars payer needs to input for my website to pass the param values to the BitCoin Payment Gateway:

function confirmBitcoinPayment($transaction_id, $amount, $customer_address, $website_address, $api_key) {
    // Initialize cURL
    $ch = curl_init();

    // Set the cURL options
    curl_setopt($ch, CURLOPT_URL, "https://api.bitcoinpaymentgateway.io/v1/confirm_payment");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
        'transaction_id' => $transaction_id,
        'amount' => $amount,
        'customer_address' => $customer_address,
        'website_address' => $website_address,
        'api_key' => $api_key
    ]));

But I do not see any input facilites ($_POST) to generate for these $vars in the BitCoin Payment Confirmation script. Where are they ?

Q1.
Or, do I myself, have to create a custom BitCoin payment form and create the input fields related to these particular $vars in order to capture the values from user before passing them on to the BitCoin Payment Confirmation script ?
Talking about these 2 particular $var related to user's inputs:

'amount' => $amount,
'customer_address' => $customer_address,

Q2.
How do I feed value to this particular $var:

'transaction_id' => $transaction_id,

Do I need to write code to generate this said transaction id and then write another line of code to forward the transaction id value to the concerned $var $transaction_id on the BitCoin Payment Confirmation script ?
Or, I should just forget about it and let BitCoin Gateway deal with it as their server will auto generate the transaction id on their end and add it to the $var $transaction_id on the Payment Confirmation script (that is hosted on my end) ?

Q3.
Now, how to feed this $var my input value ? :

'website_address' => $website_address

Like so ?

$website_address = $_SESSION['website_address'];

If so, must I add above line onto the BitCoin Payment Gateway script ?
Or, should I instead change this line:

'website_address' => $website_address

to hardcoded this line instead, on the BitCoin Payment gateway script ?

'website_address' => 'website_address'

Q4.
Anything else I should know ?

Q5.

You have to use an HTTP redirect to redirect the website visitor over to whatever website they go to to pay with their Bitcoins. Once they've done that, you can use the above PHP code to verify the payment went through properly, by passing in information about the supposed transaction, as well as your app's API key, into the API. <<

Let us say, I http redirected to coinbase.com where they have account. Or, I put a link to coinbase.com (BitCoin middleman). Now, when they login to their CoinBase account and send me payment, that payment will go direct to my BitCoin wallet and not go to it via my website since coinbase.com has no connection to my website.
Now, how will my website know that the payment has been sent (using coinbase.com) and the transaction is complete that it should get the above BitCoin Payment Confirmation script to check ?

I mean, my order form can redirect the user to coinbase.com website. But since my website got no connection with coinbase.com. It will not send any signal to my website to use the BitCoin Payment Confirmation php script to check for payment confirmation. In such case, I will have to get the BitCoin Payment Confirmation php script (that is on my website) to freqeuntly check for payment confirmation.
And that is a miss miss situation.
Say, I programmed the BitCoin Payment Confirmation script (that is on my website) to check for confirmation after 5 mins of my website's order form redirecting the user to coinbase.com. And let's say, I programmed the php script to check every 5 mins but max 3 times only. And let's say it took the user halfen hr to send the payment via coinbase.com.
In this scenario, my BitCoin Payment Conformation script (on my website) will stop checking once 15 mins is over. And wrongfully assume user did not pay. I will then get a complain email sent by user or user screaming for my blood I ran away with their money. I would then have to manually deal with the transaction. How to avoid all this mess ?

I'm sorry, I'm not understanding your question. You need to fill out all of this information:

curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
    'transaction_id' => $transaction_id,
    'amount' => $amount,
    'customer_address' => $customer_address,
    'website_address' => $website_address,
    'api_key' => $api_key
]));

based on what is passed back to you from the payment gateway. I have no Bitcoin or Coinbase experience, but the way that Paypal works is that, after the user makes a payment, it will immediately redirect that user back to my website with a ?tx= query string parameter in the URL which translates to a transaction ID. I can then use the Paypal API to look up details of that transaction and verify it meets my requirements (in terms of how much the payment was for, etc.) before granting access. This happens as soon as the payment completes, no matter how long it takes the user to complete the payment.

Another method available with Paypal's API is the concept of IPN notifications, in which you can have it make a POST request to your server with transaction details each time there has been payment activity.

All of the answers is contained in the API code and documentations (Api Docs) where validations, payments and confirmation of payment takes place. Read all their requirements, register to receive your sites keys and you can start processing. I see they have a sandbox where you can do testing to confirm your code is running correctly.

commented: Thanks Buddy! +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.