That is already available. The question is whether Xojo will allow access to a Xojo Cloud database from outside Xojo Cloud.
This would be a huge security risk.
Yes I know that. The whole idea is to set up someone’s account immediately after signing up.
I’m still doing it manually and have lost customers because of it. They expect to immediately be able to log in.
Perhaps you could tap into HandleURL with an encrypted and base64 version of the data.
At this point, the listener is getting the PayPal IPN just fine but sending the message back to PayPall (as a URL) doesn’t seem to be working. I’m not getting anything back from PayPal, neither Verified nor Invalid. Below is the code I’m using to send the message back to PayPal (I’m testing this live using a product that costs $0.01).
Any suggestions?
payPalURL = “https://ipnpb.paypal.com/cgi-bin/webscr”
reqContents = request.body.split(“&”)
responseString = payPalURL + “?cmd=_notify-validate”
for i as integer = 0 to reqContents.lastIndex
if reqContents(i).indexof(“payment_date”) >= 0 then
responseString = responseString + “&” + replaceAll(reqContents(i), “+”, “%2B”)
else
responseString = responseString + “&” + reqContents(i)
end if
next i
ppc.requestHeader(“User-Agent”) = “PHP-IPN-VerificationScript”
ppc.setRequestContent(responseString, “application/x-www-form-urlencoded”)
ppc.send(“POST”, responseString, 120)
I’d imagine you need to use ppc.sendSync
to make a synchronous request so that you can reply to request
before the end of the event loop.
I think async is ok, but trying sendSync finally got me a result. It’s INVALID but that’s better than nothing.
Thanks,
Now it’s VERIFIED. Thanks,
Congrats.
Can you share a sample code for others to learn/use?
You are aware you can use the PayPal sandbox environment so you do not need to pay anything for doing tests?
As was stated earlier, the sandbox is broken.
Works fine here. Well, yesterday it worked fine doing some tests here.
I will when it’s fully working . . . Right now getting to VERIFIED is great
A product for one cent . . . . I could run 2,000 tests and it will cost me just $20
Sure, but PayPal has a percentage fee + fixed fee. So $0.01 will become +$1 fast (depending were you live).
Just checked. PayPal is taking $0.01 per transaction
I’ve had trouble with PayPal’s sandbox since the age of the dinosaurs. Way back when, I actually had a callback from them to help me sort out what was going on and the call ended with “We’ll look in to this on our side and see if we can determine the cause.” I do live transactions for testing, also. There’s no crazy charges, and it actually works with my account.
Here ya go. I loads weirdly here, but you need it all:
// Local URL:
// http://127.0.0.1:8080/ipn
// https://paypalipn.xojocloud.net/ipn
// WriteToLog is a separate method that writes a log
var sqlStatement as string
var rs as rowSet
if not request.path.isEmpty then 'Is the connection trying to do something? (see above)
var ppc as new payPalConnection
var message, paymentStatus as string
response.status = 200 'Tell PayPal to not send more messages
writeToLog "IPN received (IPN version " + str(majorVersion) + “.” + str(minorVersion) + “)”
req = request
if request.path = “ipn” then 'the something and ipn?
writeToLog “ipn confirmed”
payPalURL = liveURL '“https://ipnpb.paypal.com/cgi-bin/webscr”
//You'll need to send the message PayPal sent you right back for verification
reqContents = request.body.split("&") 'Get each piece of data from the IPN message (reqContents() as string)
responseString = payPalURL + "?cmd=_notify-validate"
for i as integer = 0 to reqContents.lastIndex
// Send the request.body back exactly as you got it. Don't try to edit it.
responseString = responseString + "&" + reqContents(i) 'Add request contents to your response string
if reqContents(i).indexof("payment_status") = 0 then 'get useful data
var item() as string = reqContents(i).split("=")
paymentStatus = item(1)
end if
if reqContents(i).indexof("mc_gross") = 0 then 'Example of getting useful data
var item() as string = reqContents(i).split("=")
price = item(1)
end if
if reqContents(i).indexof("item_name") = 0 then 'get useful data
var item() as string = reqContents(i).split("=")
product = replaceAll(item(1), "+", " ")
end if
if reqContents(i).indexof("payment_date") = 0 then 'get useful data
var item() as string = reqContents(i).split("=")
var parts() as string = item(1).split("+")
currentDate = str(months.indexof(parts(1)) + 1) + "/" + replace(parts(2), "%2C", "") + "/" + parts(3)
end if
next i
writeToLog "Response sent"
writeToLog "Test email sent"
ppc.requestHeader("User-Agent") = "PHP-IPN-VerificationScript"
ppc.setRequestContent(responseString, "application/x-www-form-urlencoded")
//While the documentation says this is all asynchronous to get the result back from PayPal you have to use sendSync
sendResult = ppc.sendSync("POST", responseString, 60)
if sendResult = "VERIFIED" then 'PayPal verifies that what you sent back matches what PayPal sent you.
writeToLog "Verified returned"
writeToLog paymentStatus
if paymentStatus = "Completed" then 'Only act if payment completed
writeToLog "payment confirmed"
if price = "0.01" then 'Only act if the price is ritht
writeToLog "price confirmed"
if product = "CircleCalc MAG Monthly Subscription" then 'Determine which action to take
writeToLog "product confirmed"
// Do stuff
end if
end if
end if
elseif sendResult = "INVALID" then 'If invalid returned, record it
writeToLog "Invalid returned"
sendInvalidEmail responseString
writeToLog "Invalid email sent"
end if
return true
else
return true
end if
end if
Just for clarity, the reason you need SendSync is because it is not asynchronous. You need the ppc request to hold up the thread so that you can return a success/failure status before the end of the method. Using Send is asynchronous, so the ppc request will not complete until some time after method ends, which is too late to send back a status.
I was going by PayPal’s statement that it’s asynchronous . . .