<p>I modified the open source Intersango exchange code so that it can issue and accept Bitcoin coupons.  You can <a href="https://github.com/dooglus/intersango/blob/aud/voucher.php" rel="nofollow">view the code</a> to see how I did it.  My code doesn't store the whole coupon code in the database, so even if a hacker gains read access to the database, they can't redeem the unclaimed coupons.</p>

<p>To answer your particular questions:</p>

<p>1) Is there a sample code for sending coins using bitcoind / PHP ?</p>

<p>Yes.  <a href="https://github.com/dooglus/intersango/blob/4f509499f24481d4a2c8fad795fb7b42ab2c450b/util.php#L592" rel="nofollow">Here's some code</a> that does it in a very simple way.</p>

<p>2) Is there a 3d party API providing such functionality (instead of using bitcoind)?</p>

<p>I don't know.  Maybe <a href="http://lovebitcoins.org/getStarted.html" rel="nofollow">one of these</a> has what you want.</p>

<p>3) Do MtGox and Tradehill have APIs for transfers?</p>

<p>Tradehill's no longer operating.  <a href="https://en.bitcoin.it/wiki/MtGox/API/HTTP/v0#0.2Fwithdraw.php" rel="nofollow">MtGox does</a>.</p>

<p>4) Is captcha a must?</p>

<p>No.  They're annoying.  Have the code which checks the coupons take a long time to return a result, and only allow the users to check one at a time.  Then they can't brute force the coupons in reasonable time.</p>

CC BY-SA 3.0
2012-03-05T08:11:25.460Z
How do you stop a malicious user from trying more than one at a time?
David Schwartz
CC BY-SA 3.0
2012-03-05T09:57:56.693Z
I use a lock to stop each logged in account doing more than one thing at a time.  I can't stop one malicious user making a million accounts and using them all at once, but that is a lot more obvious if it happens.
Chris Moore
CC BY-SA 3.0
2012-03-05T10:11:26.293Z
If a malicious user creates `N` accounts, he can check `N` coupons at a time. You can't hold him to one. And while it might be obvious if a user creates millions of accounts, how do you stop him? The delay also tends to turn it into a self-DOS because you tend to run yourself out of connections.
David Schwartz
CC BY-SA 3.0
2012-03-05T07:51:58.583Z
2012-03-05T07:51:58.583Z
Chris Moore
<ol>
<li>Issue coupons with some serial number that is unique to each coupon, preferably concealed in a way that once the number is visible, the coupon can't be made to look unopened.</li>
<li>Have a list of all coupon serial numbers and their values in your database.</li>
<li>Upon redeeming the coupon with a proper Bitcoin address, convert the amount according to some value form an exchange (like Mt.Gox) and send the proper amount of coins to the specified address.</li>
</ol>

<p>As for the actual program to perform those actions, can't help you much, but if you can communicate with Bitcoind through JSON-RPC, the rest should be pretty easy to program for.</p>

CC BY-SA 3.0
2012-01-04T07:09:54.417Z
tnx ThePiachu, i've edited the question, added some more specific points.
asi
CC BY-SA 3.0
2012-01-03T21:56:08.813Z
2012-01-03T21:56:08.813Z
ThePiachu
<p>I would like to issue Bitcoin coupons with a given USD value. The redeeming web app should accept the coupon pin-code and a Bitcoin address and transfer bitcoins to that address according to the current exchange rate. I'm looking for a quick / simple solution, preferably with PHP. Looking for design guidelines and any advice to help me get started.</p>

<p>[edit]
To be more specific:</p>

<ol>
<li>Is there a sample code for sending coins using bitcoind / PHP ?</li>
<li>Is there a 3d party API providing such functionality (instead of using bitcoind)?</li>
<li>Do MtGox and Tradehill have APIs for transfers?</li>
<li>Is captcha a must?</li>
</ol>

<p>[end edit]</p>

CC BY-SA 3.0
2012-01-04T10:36:54.047Z
I suggest you don't try to maintain a bitcoin daemon yourself, but rather work with something like the Overlay Network / Stratum - https://bitcointalk.org/index.php?topic=55842.0
ripper234
CC BY-SA 3.0
2012-01-04T12:59:39.647Z
4. never EVER captcha. They provide no benefit, in exchange for enraging users. Don't. Ever.
o0'.
<bitcoind><websites>
Guidelines for creating a PHP driven web app for redeeming Bitcoin coupons
asi
# Guidelines for creating a PHP driven web app for redeeming Bitcoin coupons

(Asked by: username_0 on 2012-01-03)

I would like to issue Bitcoin coupons with a given USD value. The redeeming web app should accept the coupon pin-code and a Bitcoin address and transfer bitcoins to that address according to the current exchange rate. I'm looking for a quick / simple solution, preferably with PHP. Looking for design guidelines and any advice to help me get started.

[edit]
To be more specific:

1. Is there a sample code for sending coins using bitcoind / PHP ?
2. Is there a 3d party API providing such functionality (instead of using bitcoind)?
3. Do MtGox and Tradehill have APIs for transfers?
4. Is captcha a must?

[end edit]

**Tags:** bitcoind, websites

> **Comments:**
> **username_1**: I suggest you don't try to maintain a bitcoin daemon yourself, but rather work with something like the Overlay Network / Stratum - https://bitcointalk.org/index.php?topic=55842.0  
> **username_2**: 4. never EVER captcha. They provide no benefit, in exchange for enraging users. Don't. Ever.  

---

## 2 answers

### Answer by username_3 on 2012-03-05. Score: 2

I modified the open source Intersango exchange code so that it can issue and accept Bitcoin coupons. You can [view the code](https://github.com/dooglus/intersango/blob/aud/voucher.php) to see how I did it. My code doesn't store the whole coupon code in the database, so even if a hacker gains read access to the database, they can't redeem the unclaimed coupons.

To answer your particular questions:

1) Is there a sample code for sending coins using bitcoind / PHP ?

Yes. [Here's some code](https://github.com/dooglus/intersango/blob/4f509499f24481d4a2c8fad795fb7b42ab2c450b/util.php#L592) that does it in a very simple way.

2) Is there a 3d party API providing such functionality (instead of using bitcoind)?

I don't know. Maybe [one of these](http://lovebitcoins.org/getStarted.html) has what you want.

3) Do MtGox and Tradehill have APIs for transfers?

Tradehill's no longer operating. [MtGox does](https://en.bitcoin.it/wiki/MtGox/API/HTTP/v0#0.2Fwithdraw.php).

4) Is captcha a must?

No. They're annoying. Have the code which checks the coupons take a long time to return a result, and only allow the users to check one at a time. Then they can't brute force the coupons in reasonable time.

> **Comments:**
> **username_4**: How do you stop a malicious user from trying more than one at a time?  
> **username_3**: I use a lock to stop each logged in account doing more than one thing at a time.  I can't stop one malicious user making a million accounts and using them all at once, but that is a lot more obvious if it happens.  
> **username_4**: If a malicious user creates `N` accounts, he can check `N` coupons at a time. You can't hold him to one. And while it might be obvious if a user creates millions of accounts, how do you stop him? The delay also tends to turn it into a self-DOS because you tend to run yourself out of connections.  

---

### Answer by username_5 on 2012-01-03. Score: 0

1. Issue coupons with some serial number that is unique to each coupon, preferably concealed in a way that once the number is visible, the coupon can't be made to look unopened.
2. Have a list of all coupon serial numbers and their values in your database.
3. Upon redeeming the coupon with a proper Bitcoin address, convert the amount according to some value form an exchange (like Mt.Gox) and send the proper amount of coins to the specified address.

As for the actual program to perform those actions, can't help you much, but if you can communicate with Bitcoind through JSON-RPC, the rest should be pretty easy to program for.

> **Comments:**
> **username_0**: tnx username_5, i've edited the question, added some more specific points.  

---

