In-App purchases on Win/Mac/Lnx?

Previous topic - Next topic

ampos

I need to implement In-App purchases in my upcoming project. On iPhone it is there, but I need a solution for desktop machines.

Any clue?

Thx.

Really it is 2 problems:

1.- how to implement an in-app purchase

2.- How to implement "to know if a content as been purchased"
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Kitty Hello

I do that with a server and paypal.

It would be interesting to port that to GLBasic directly. :D

Here's part of the code:

Code (glbasic) Select

// PayPal
if(isset($_POST['txn_id']) )
{
$debuginfo.= "Paypal checkout\n";
$sandbox = 0; // toggle sandbox use

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate
$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";

// If testing on Sandbox use:
if($sandbox)
$header .= "Host: www.sandbox.paypal.com:443\r\n";
else
$header .= "Host: www.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// assign posted variables to local variables
$item_name = $_POST['item_name'];

if($item_name == "your product info") ...

$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];


// If testing on Sandbox use:
if($sandbox)
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
else
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
$debuginfo.= "HTTP ERROR\n";
// HTTP ERROR
}
else
{
fputs ($fp, $header . $req);
while (!feof($fp))
{
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0)
{
$valid_money_transfer = true;
$_POST['program'] = $item_name;
$_POST['email'] = $payer_email; // recipent and license email
}
else if (strcmp ($res, "INVALID") == 0)
{
$debuginfo.= "->INVALID CHECKOUT!\n";
}
}
fclose ($fp);
}



Any volunteers?

[edit]
Oh, that uses SSL :/

ampos

I have found a way to implement a payment using PAYPAL and GLBasic.

First, in Paypal website, you have to create a button (sold on your web -> create "buy now" button.

Here, you set your button options.

Once created, the HTML code is shown, but we have to choose the tab "email".

You will get a code like this:

Code (glbasic) Select
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN


Just add this to GLBasic

Code (glbasic) Select
NETWEBEND "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN"


If you want to sent something into the Paypal email, you can add this:

Code (glbasic) Select
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN&custom=your_text_here

This custom text will be sent to you in the paypal income receipt.

I am using

Code (glbasic) Select
NETWEBEND "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KYU26B8XLMVAN&custom="+PLATFORMINFO$("ID")

so I can use this code to track purchases. At least, in "manual" mode...  =D I got this code, encrypt it and upload to my site, and the app can check online if it has been purchased...

Not a very nice solution, but it works (at least, to me).

More codes to be added to the button link can be found here:

https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Kitty Hello

Now we only need a way to check if the item was bought properly. I think you need php for this.

ampos

It has to be someone else... I have no idea of php. I am going to do something similar to this:

If platforminfo(ID) is, "ABCD", I will upload a file called ABCD.key, that contains the ABCD text encoded ("1234509876").

Then, the app will try to download/netwebget the file ABCD.key, and check if his own platforminfo-ID encoded is the same as the one inside. If so, full=true :)

My projects are so tiny to implicate someone else...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE