Bitcoin Forum

Economy => Marketplace => Topic started by: edd on May 07, 2011, 04:08:20 PM



Title: Help needed finishing shopping cart integration
Post by: edd on May 07, 2011, 04:08:20 PM
I've got just about everything set up for my site to accepts bitcoins as payment but I'd like to customize my shopping cart a bit more. I'm not a developer, so I need a bit of assistance configuring some variables and sending data to the appropriate places. Right now, I have the MyBitcoin SCI working fine but only using one set price for each generated button. How do I get it to change the amount based on the total in my customers' shopping carts?


Title: Re: Help needed finishing shopping cart integration
Post by: unfinishe on May 07, 2011, 07:04:21 PM
I haven't used the SCI myself, but looking at it, it seems that the key is to use the function mbc_encryptformdata()

If you look at the file sci-auto-sample.php in the toolkit, there's an example of how to use it at line 34. You should be able to just change the $amount variable to the price of the shopping cart.


Title: Re: Help needed finishing shopping cart integration
Post by: BioMike on May 07, 2011, 07:11:24 PM
After presenting the form to the user to fill in the amount (or other vars), send the data through the following code:

Code:
$plaintext_querystring="amount=".$amount."&currency=".$currency."&payee_bcaddr=".$payee_bc_addr."&payee_name=".$payee_name."&note=".$note."&success_url=".$success_url."&cancel_url=".$cancel_url."&baggage=".$baggage;

$result=mbc_encryptformdata($plaintext_querystring);

$redirect_url="https://www.mybitcoin.com/sci/paypage.php?t=".$result['SCI Encrypted Form Data Token'];
header("Location: $redirect_url");

You can also get most vars from your own database/cart and fill in the blanks from there.


Title: Re: Help needed finishing shopping cart integration
Post by: edd on May 07, 2011, 07:53:04 PM
Sorry, BioMike, I guess I'm a little dense; where does this code go?


Title: Re: Help needed finishing shopping cart integration
Post by: lulzplzkthx on May 07, 2011, 08:02:05 PM
When you have the required info you need from the user. That will redirect them to the MyBitcoin page.


Title: Re: Help needed finishing shopping cart integration
Post by: BioMike on May 07, 2011, 08:07:29 PM
Sorry, BioMike, I guess I'm a little dense; where does this code go?

It goes in its own page.

Example:
Code: ("shoppingcart.php")
<form action="mybitcoin.php" method="post>
...
input fields that you need in mybitcoin.php (or you get them from a checkout db)
...
<input type="submit" value="Checkout with MyBitcoin">
</form>

Code: ("mybitcoin.php")
Read the fields from shoppingcart.php or checkout database and parse them into $plaintext_querystring

$plaintext_querystring="amount=".$amount."&currency=".$currency."&payee_bcaddr=".$payee_bc_addr."&payee_name=".$payee_name."&note=".$note."&success_url=".$success_url."&cancel_url=".$cancel_url."&baggage=".$baggage;

$result=mbc_encryptformdata($plaintext_querystring);

$redirect_url="https://www.mybitcoin.com/sci/paypage.php?t=".$result['SCI Encrypted Form Data Token'];
header("Location: $redirect_url");