auto-account setup

Oh wise masters . . .

Had a new user spend 2 hours trying to access my program today, but he couldn’t because setup is manual on my part. eeep.

I need to automate my account setup. Subscriptions are created on PayPal and a username and password are automatically sent to the new user.

I need to automatically enter the data in my users.sqlite file.

ideas?

If there is an API on Paypal where you can retrieve the information, I would create a desktop app (or an administrative method in the web app, that users cannot access), and use a timer to trigger a scan of Paypal registration info with the method. New accounts would be added to the database. A scan every 5 minutes or so seems appropriate, but I would probably check with Paypal docs to see whether that frequency is allowed.

just an idea.

PayPal does have an API you should be able to make use of.

https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/

I believe there are also some classes available for purchase in the Xojo store.

I’ve using the IPN to send an email. need to figger out how to open my database and add info from the IPN listener

Guys . . . I could really use some help here, please.

I’m using a php ipn listener for payments through PayPal. Right now it just sends me and the new users emails with php generated username and password.

I need the php ipn listener to open my SQLite users database and insert the new user with his username and password.

Seems like this is something you smart folks have probably done time and again. I’ll take any help available.

Please note that the users database is on a different server than the listener.

Thanks,

[quote=121128:@John Scanlan]Guys . . . I could really use some help here, please.

I’m using a php ipn listener for payments through PayPal. Right now it just sends me and the new users emails with php generated username and password.

I need the php ipn listener to open my SQLite users database and insert the new user with his username and password.

Seems like this is something you smart folks have probably done time and again. I’ll take any help available.

Please note that the users database is on a different server than the listener.[/quote]

I use a php listener to send customers download instructions, and a copy of that to me. The same script saves a log of all operations that the download interface which is a Xojo Web app uses to verify the credential of the user before initiating the download. All are on the same server.

Since your database is on another server, the best way would be to use a web service on your database application which uses the /special directory and HandleSpecialURL to receive the new user username and password. You will have to hash the information in your php and decrypt it on arrival in the Web app, but it seems relatively simple to create. Of course the password must be stored encrypted in the database.

Really what I’m doing than is your first suggestion, the database. The problem I’m having is understanding php well enough to open the database and write to it. remember . . . amateur here.

No problem. I was talking general principles and not nitty gritty.

It would be a lot simpler if you could install the PHP on the same server as your app. That would allow you to keep a log of transactions in a text file that your app will read. For my customers, I use the Paypal transaction number and their email address as credential. You could do the same for the first access to your app and then the user can change.

If the PHP must reside on another site, then it will be necessary to have it contact your app through specialurl, so your app can add the credentials.

In both cases, you will need to learn a bit of PHP.

I’ve been able to rebuild a paypal listener to my purposes. I generate a username and password for the clients and they can change them upon going to the app. The problem is that they have to wait for me to enter them in the users database. I’d like to allow them to sign up and get to work right away.

btw, the program is a gymnastics routine evaluator.

What I’ve tried so far is to open the database and print an opened successfully notice to my notice email.

Can I just send data to and automatically start an app that will add the user to the database?

specialURL?

Definitely.

Posting to specialurl with PHP is elementary.

All you have to do is

<?php header(‘Location: http://www.somewebsite.com/cgi-bin/myapp.cgi/special?mydata’); ?>

Then in you webapp, use the HandleSpecialURL to get the query string with request.QueryString and act accordingly. Since you will be dealing with sensitive information, you want to make sure nobody but you can use specialurl, so you need to encrypt mydata and include a way to verify the request really came from your listener.

See /Xojo 2014 Release 2.1/Example Projects/Web/QuoteService-SpecialURL.xojo_binary_project

Damn . . . now I can’t even get the ipn simulator to work.

After quite a while I get “This page cannot be displayed”. That’s it.

My listener url is http://sc1473a.dfw1.1701hosting.com/paypalipn.php.

My php begins with

$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
";

// If testing on Sandbox use:
///$header .= "Host: www.sandbox.paypal.com:443\r
";
$header .= "Host: ipnpb.paypal.com:443\r
";
$header .= "Content-Type: application/x-www-form-urlencoded\r
";
$header .= "Content-Length: " . strlen($req) . "\r
\r
";
// If testing on Sandbox use:
///$fp = fsockopen (‘ssl://www.sandbox.paypal.com’, 443, $errno, $errstr, 30);
$fp = fsockopen (‘ssl://ipnpb.paypal.com’, 443, $errno, $errstr, 30);

[quote=125560:@John Scanlan]Damn . . . now I can’t even get the ipn simulator to work.

After quite a while I get “This page cannot be displayed”. That’s it.

My listener url is http://sc1473a.dfw1.1701hosting.com/paypalipn.php.

My php begins with

$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
";

// If testing on Sandbox use:
///$header .= "Host: www.sandbox.paypal.com:443\r
";
$header .= "Host: ipnpb.paypal.com:443\r
";
$header .= "Content-Type: application/x-www-form-urlencoded\r
";
$header .= "Content-Length: " . strlen($req) . "\r
\r
";
// If testing on Sandbox use:
///$fp = fsockopen (‘ssl://www.sandbox.paypal.com’, 443, $errno, $errstr, 30);
$fp = fsockopen (‘ssl://ipnpb.paypal.com’, 443, $errno, $errstr, 30);[/quote]

There is no errors when entering the URL of the listener, so it is not a question of permissions. Have you changed anything ?

apparently the non-connection was a paypal problem so I’m off the races again.

[quote=125295:@Michel Bujardet]Definitely.

Posting to specialurl with PHP is elementary.

All you have to do is

<?php header(‘Location: http://www.somewebsite.com/cgi-bin/myapp.cgi/special?mydata’); ?>

Then in you webapp, use the HandleSpecialURL to get the query string with request.QueryString and act accordingly. Since you will be dealing with sensitive information, you want to make sure nobody but you can use specialurl, so you need to encrypt mydata and include a way to verify the request really came from your listener.

See /Xojo 2014 Release 2.1/Example Projects/Web/QuoteService-SpecialURL.xojo_binary_project[/quote]
If you’re using usernames and passwords, please use an ssl certificate with your app and only use hashed passwords. That way its less likely that any one users account will be stolen (https) and if the database is taken, you’re not giving away everyone’s passwords as well. Come to think of it, if you’re using sqlite, you should add an encryption key as well.

turns out I can put my ipn listener on the server (one of phillips’). I’m getting the IPN successfully sent message, but can’t get an email. I’ve cut out everything out of my listener except this:

// read the post from PayPal system and add ‘cmd’
$req = ‘cmd=_notify-validate’;

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

// If testing on Sandbox use:
$header .= "Host: www.sandbox.paypal.com:443\r
";
///$header .= "Host: ipnpb.paypal.com:443\r
";

$header .= "Content-Type: application/x-www-form-urlencoded\r
";
$header .= "Content-Length: " . strlen($req) . "\r
\r
";

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

$mail_From = “From: circlecalc@purchase.com”;
$mail_To = “jvscanlan@q.com”;
$mail_Subject = "CircleCalc Purchase from ";
$mail_body = “test from ipn simulator”;
mail($mail_To, $mail_Subject, $mail_Body, $mail_From);

?>

I’m guessing I have an error, but can’t find it.

Try :

mail("$mail_To\ ", "$mail_Subject\ ", "$mail_Body\ ", "$mail_From\ ");

Nope that didn’t do it. Thanks.

the php is now this:

<?php // 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\ "; // If testing on Sandbox use: $header .= "Host: www.sandbox.paypal.com:443\\r\ "; ///$header .= "Host: ipnpb.paypal.com:443\\r\ "; $header .= "Content-Type: application/x-www-form-urlencoded\\r\ "; $header .= "Content-Length: " . strlen($req) . "\\r\ \\r\ "; // If testing on Sandbox use: $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); ///$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR Failed to connect //error handling or email here $mail_From = "From: circlecalc@purchase.com"; $mail_To = "jvscanlan@q.com"; $mail_Subject = "IPN FAILED "; $mail_body = "test from ipn simulator"; mail($mail_To, $mail_Subject, $mail_Body, $mail_From); } else // if we've connected OK { fputs ($fp, $header . $req);//post the data back while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $mail_From = "From: circlecalc@purchase.com"; $mail_To = "jvscanlan@q.com"; $mail_Subject = "CircleCalc Purchase from "; $mail_body = "test from ipn simulator"; mail($mail_To, $mail_Subject, $mail_Body, $mail_From); } } } fclose($fp); ?>

ok … so … er … Turns out Phillip blocks email sending from his server. But he says I can send email using an external SMTP server.

I’ve tried to figger this out, but I’m stuck. Anyone know where I can find instructions?

Thanks all, specially Michel . . .

It WORKS !!!

Now if anyone needs to figure this out send 'm my way.

I did not want to say anything when you wrote Phillip was blocking email, but I have been on 1701 for a while and my php script for online delivery has been faithfully sending email to my customer all along :wink:

I am glad to have been of help.