-
-
Save anonymous/266b166175d059b3d723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
try { | |
//Open the database - EDIT THIS TO CONNECT TO YOUR DB | |
$db = new PDO('mysql:host=localhost;dbname=test', 'root', ''); | |
} catch(Exception $e) { | |
die($error); | |
} | |
//Create new invoice in table | |
$stmt = $db->prepare("INSERT INTO invoices VALUES(null, :refund_addr, 0)"); | |
$stmt->execute(array(':refund_addr' => $_GET['refund_addr'])); | |
//Get the ID of the invoice | |
$invoice_id = $db->lastInsertId(); | |
$secret = 'ZzsMLGKe162CfA5EcG6j'; | |
$my_address = '1Pqh1kXjMVa8KvSJFg9DoUoKz9G1kNiYvo'; | |
$my_callback_url = 'https://mystore.com?invoice_id='.$invoice_id.'&secret='.$secret; | |
$root_url = 'http://blockchain.info/api/receive'; | |
$parameters = 'method=create&address=' . $my_address .'&shared=false&callback='. urlencode($my_callback_url); | |
$response = file_get_contents($root_url . '?' . $parameters); | |
$object = json_decode($response); | |
echo "Your invoice ID is $invoice_id. Send payment to " . $object->input_address; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment