<?php
    require_once "vendor/stripe/stripe-php/init.php";
    $stripe = new \Stripe\StripeClient('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');

    if(array_key_exists('create_customer', $_POST)) { 
        create_customer(); 
    }

    function create_customer() {
    	//echo "this is button";
    	global $stripe;
	    $test_customer = $stripe->customers->create([
            'description' => 'My First Test Customer (created for API docs at https://www.stripe.com/docs/api)',
            'email' => 'haxibo3218@nexxterp.com',
            'name' => 'haxibo sonfon',
        ]);
        //echo $test_customer->id;
        $invoice = $stripe->invoices->create([
            'customer' => $test_customer->id,
            'collection_method'=>"send_invoice",
            'days_until_due'=>5,
        ]);
        $stripe->invoices->sendInvoice(
            $invoice->id,
            []
        );
    }

?>

<!DOCTYPE html>
<html>

<body>
  
    <form method="post"> 
        <input type="submit" name="create_customer" class="button" value="SEND EMAIL" /> 
    </form>


</body>

</html>