Forum PayVault Purchasing items with getBuyDirectInfo

Discussion and help relating to the PlayerIO payment solution, PayVault.

Purchasing items with getBuyDirectInfo

Postby azuanagames » November 26th, 2010, 11:31 pm

I'm trying to add the ability to purchase an ad free version of my game. I'm having trouble actually getting all the bits and pieces working with PayVault.

First, I created a sandbox paypal account and am using that.

It seems that my purchases are going through and I complete the transaction with paypal, but a few things go sour.

I've set a "return" parameter and it's currently going to my sitebox to a temporary page which is just dumping all variables. It seems that when the purchase is complete it goes into a loop as it tries to return from paypal.

What's even more odd is that the purchase never gets confirmed by PlayerIO. How does this work exactly? Does the return parameter get interpreted by paypal or player io? Do you confirm purchases then "return" to me?

I'm going to try clearing the "return" parameter next.
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » November 29th, 2010, 5:43 pm

Hi,

When you make a purchase, are you setting the sandbox parameter to true? And are you setting your merchant email in the payvault setup to the one generated by the PayPal sandbox?

Also, do you have the URL of the page that just goes into a loop?
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » November 29th, 2010, 5:55 pm

Hmm,

I did set the paypal sandbox to true. But I didn't use the sandbox email...

I'll double check that later today.

-----

Clarify something for me. How does player.io realize that the payment went through? It can't be through the email. Is it only when "Return to Merchant" is clicked? If so, what happens if the user simply closes that browser window? Is there a different mechanism?
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » November 29th, 2010, 8:53 pm

azuanagames wrote:Clarify something for me. How does player.io realize that the payment went through? It can't be through the email. Is it only when "Return to Merchant" is clicked? If so, what happens if the user simply closes that browser window? Is there a different mechanism?

Yes, PayPal sends a request directly to our servers notifying us that the payment went through. They do send the same information through the return URL, but we're not using that information.
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 1st, 2010, 12:47 am

Here's my call to payvault:

Code: Select all
// buy the 'lifetime_adfree' item directly with PayPal
         client.payVault.getBuyDirectInfo(
            "paypal",                                 //Provider name
            {currency:"USD", item_name:"Azuana Bingo 2 Ad Free For Life",
               sandbox: true,
               cpp_header_image:"http://www.azuanagames.com/img/abingo2_150x50.png",
               "return":"http://apps.facebook.com/azuana-bingo/thanks",
               cancel_return:"http://apps.facebook.com/azuana-bingo/cancel",
               no_shipping:1
            }, //Purchase arguments
            [{itemKey:"lifetime_adfree"}],                     //Items to buy
            // Success handler
            function(info:Object):void {
               // Open paypal in new window
               navigateToURL(new URLRequest(info.paypalurl), "_blank");
               popup.showMessage("Thank You!", "We will now open a new tab for you to complete the payment process.\n\nOnce the payment is processed you may press 'OK' to disable ads, or reload Azuana Bingo 2 by clicking the 'Play' tab above.", okFunction);
            },
            // Error handler
            function(e:*):void {
               popup.showMessage("Unable to buy item", e)
            }
         );


But, it's not working. I get to complete the purchase at the paypal site, but I then get:
Image

When I click return to merchant.

Payvault claims the transaction was never completed.
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » December 1st, 2010, 10:13 pm

Oh wow, PayPal is like a box of chocolates, you never know what you're gonna get...

So, what happened is that PayPal returned something rather unexpected from your test, and we had a bug in our systems that caused it not to log that properly. That is now fixed, so if you retry what you did, the transaction still won't complete, but this time you should get something in your game's errorlog about the transaction being pending.

If you then check that error, you will see the data we receive from paypal, and among that there is a pending reason with the value "unilateral". to find out what that means, we have to check the PayPal IPN Guide, and finally, on page 50 of that we can see that it means "The payment is pending because it was made to an email address that is not yet registered or confirmed."

I have absolutely no idea why they don't say anything about that in their payment flow, I would assume that it to be pretty interesting to know that the email address you're using actually can't receive payments yet. Either way, you can find out how to confirm your PayPal email here:

https://www.paypal.com/helpscr?cmd=_hel ... onId=10607
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 1st, 2010, 11:20 pm

Wow :)

I had just set up that Sandbox. And it's the first time I do that.

I had confirmed the email though, strange...

Do I need to add the email to my paypal account? I thought that was kept separate...

Thanks very much, should help me debug this further.

*edit* I see what I did wrong!
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 2nd, 2010, 12:16 am

Ok looks great now!

Do you forward the GET variables that paypal gives my "return" page? Should print_variables print normal GET variables?

Thanks!
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » December 2nd, 2010, 11:46 am

Great to hear that!

No, we don't forward the variables PayPal sends out, but I suppose we could if you want us to. :)
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 2nd, 2010, 2:25 pm

Henrik,

Can you please check if everything is ok now. I have had a few Open purchases but none went through. I want to make sure I don't have the same error.

You see my paypal account is set up with a certain email address but I've set my primary email address to the one here on payvault.

I'm still seeing errors in my errorlog, but I'm guessing it's from the tests I was doing...

Thanks

P.S. I wish I could add multiple email address here. Because the one email address is seen by the user. Or, alternatively, is there a way to specify a "Business Name?"

*EDIT* I just went ahead and opened a new Paypal Business account. That solves everything pretty much.
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » December 3rd, 2010, 1:42 pm

The problem with having multiple PayPal email addresses is that they will always send the primary email address in the notification regardless of which email you used in the payment. I have no idea why, but that is the way they do it. this means that you have to have the primary email in the PayCault configuration.

We might be able to add a parameter to the API functions so you can display some other email address, but I guess just having a good logo, title, and item name should be enough for most situation.

I'm happy everything works fine now though. :-)
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 4th, 2010, 2:38 am

Is there any way to clear the errors coming from payvault. When I was testing my paypal returned a different email address. I now have it all configured right but I'm still seeing error messages from payvault. I'm assuming it's still seeing a transaction that was never complete from the wrong email address.

Now that I went live with the payments I don't want to set the email to the older address (which should clear that error eventually.) Is there any other choice to getting those errors to not show up. Can you manually clear the payment for me?

Basically if it's not the one set in payvault, you can safely ignore the payment since it was a test purchase.

Thanks
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » December 6th, 2010, 10:43 am

Right, thanks for pointing that out. I've released a change now so that any errors from PayPal transactions will only show up once like they should. So if you clear out all PayVault-related errors from your errorlog, you should at maximum get one more entry in the errorlog for each of the previous bad transactions, but after that it should stop. For any new bad transactions, you should only get one entry in the errorlog ever.
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby azuanagames » December 6th, 2010, 5:08 pm

Thanks :)
azuanagames
 
Posts: 149
Joined: April 29th, 2010, 10:59 pm

Re: Purchasing items with getBuyDirectInfo

Postby wbsaputra » February 28th, 2011, 9:41 pm

hi i need some help and suggestion with payvault,
i do just get payvault installed and create some payvault items.
now i'm trying to test with paypal sandbox with getBuyDirectInfo method.

first.
i'm not sure how to transform users payvault items to user player object when user has complete returning transaction from paypal. i understand how paypal ipn work, do i have to create some php function to receive ipn data or is handled by as3 at succes callback function? how about paypal_url? is this redirect page for user after transaction?
also I have to update player object table after transaction.
Is this can be done with as3 or i have to create some php page and create as3 snippet to connect player io, create room and update user player object on server side because i don't give any save access to player object table at client side.

second,
is any sample auth method for php. I'm hosted my game on my apache server and i think i have to create auth key to secure any connection. (maybe this is needed to secure connection and if i have to create as3 snippet above to complete users transaction)

third.
about facebook credits, is any other way to implement this without added bank account to facebook credit company setting?
seems facebook not currently support bank account in my country.

also when i test paypal direct with my sandbox account i got this error
Image
how to solved this?

thanks for any help
Last edited by wbsaputra on February 28th, 2011, 10:31 pm, edited 1 time in total.
wbsaputra
Paid Member
 
Posts: 140
Joined: June 29th, 2010, 4:38 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » February 28th, 2011, 10:04 pm

Hi wbsaputra,

For your first question, the answer is that you don't need to do any of that. You call the getBuyDirectInfo method and get back a URL. You need to send the player to this URL somehow. You can open it in a popup, or redirect the entire browser or whatever works best for you and your game. When the player has completed the payment, the player's vault is updated: http://playerio.com/documentation/refer ... o.payvault

Just call refresh(), and then you can find the item the player bought in the items array of his vault. You can access the vault both from client-side and server-side, and there are methods for checking if the vault contains an item, or for using them up.

Second question: No, we don't have code snippets for generating auths in PHP currently, you'll have to check the code in the documentation and you can use the example input/output to verify that your code does the same: http://playerio.com/documentation/connections

Third question: I have no idea, you'll have to contact Facebook and ask them.
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby wbsaputra » March 1st, 2011, 9:20 am

thanks for reply, just one more question, how can i test pay vault item with paypal sandbox transaction?
transaction show up in my admin panel but my user test payvault item still empty.
And what are this pending transaction mean?
and how do i remove test sandbox transaction?
wbsaputra
Paid Member
 
Posts: 140
Joined: June 29th, 2010, 4:38 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » March 1st, 2011, 11:04 am

Pending means that it is not yet completed. Check the rror log for your game to see if you have any additional detail in there, and check your IPN log on PayPal to see if they have any additional details as well. Your transaction can end up in pending on PayPal for a number of different reasons, and it's very hard to guess without some sort of message from PayPal.

Have you enabled IPN on PayPal? Have you confirmed your account on PayPal? Did you set the sandbox variable to true when you called getBuyDirectInfo? Did you complete the transaction in the PayPal sandbox? Did you complete it using a PayPal sandbox test account?
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby wbsaputra » March 2nd, 2011, 8:38 am

Have you enabled IPN on PayPal? -> did i have to enabled ipn on sandbox profile? how about ipn url? is player io ipn url or my site retun ipn url?
Have you confirmed your account on PayPal? -> do i have confirmed? because is just sandbox account
Did you set the sandbox variable to true when you called getBuyDirectInfo? - yes
Did you complete the transaction in the PayPal sandbox? -> yes
Did you complete it using a PayPal sandbox test account? -> yes

Did i will be charged in my bill if im testing payvault item with paypal sandbox?
how can i delete test transaction?
wbsaputra
Paid Member
 
Posts: 140
Joined: June 29th, 2010, 4:38 pm

Re: Purchasing items with getBuyDirectInfo

Postby wbsaputra » March 2nd, 2011, 11:16 am

Hi, i finally got paypal working after spend 1 day around with paypal and recreate all sandbox account.
Yes paypal is really nasty hot box chocolate. :?
But returning url is not working, is because im testing in localhost? not in live session?
Just need some advice for updating user vault after succesfull transaction, i have to update player object and remove user payvault item. Did i have to create returning page with as3 snippet to update player objects?
can i use different connection with auth key and point to same player object table?
also did i will be charged if i test payvaul using paypal sandbox? because i really need test hundred times before.
thanks for help
wbsaputra
Paid Member
 
Posts: 140
Joined: June 29th, 2010, 4:38 pm

Re: Purchasing items with getBuyDirectInfo

Postby Henrik » March 3rd, 2011, 1:36 pm

wbsaputra wrote:But returning url is not working, is because im testing in localhost? not in live session?


Do you mean the landin url you get to after finishing the transaction? You should end up on a URL that starts with api.playerio.com/payvault/paypal/landing, are you redirected somewhere else? Or does that page not work for you?

wbsaputra wrote:Just need some advice for updating user vault after succesfull transaction, i have to update player object and remove user payvault item. Did i have to create returning page with as3 snippet to update player objects?
can i use different connection with auth key and point to same player object table?


First, do you really need to do this? It's just as easy to read a player's vault items as it is to read his playerobject.

Second, how do you connect with your players? Regular connect? Quickconnect? You can do it from the client, but you have to connect through regular connect, as that user, and on a secured connection that has the access rights to modify the vault. If your game is a multiplayer game, it's highly recommended that you do this in serverside code instead.

wbsaputra wrote:also did i will be charged if i test payvaul using paypal sandbox? because i really need test hundred times before.


The PayVault system makes no difference between test transactions and real transactions, regardless of which provider you are using. This means that test transactions will show up in the transaction log and revenue statistics, and also that you will be charged for test transactions. I suggest that you hold off on the full tests until you absolutely have to, for example you can use the give method in payvault to give a user an item so you don't have to complete an actual transaction before it appears in that user's vault.
Henrik
.IO
 
Posts: 1838
Joined: January 4th, 2010, 1:53 pm

Re: Purchasing items with getBuyDirectInfo

Postby wbsaputra » March 4th, 2011, 9:12 am

yes, i dont know whats wrong, seems returning url not working. here my code
client.payVault.getBuyDirectInfo(
"paypal",
{
currency:_itemcur, item_name:_itemname,
sandbox: true,
cpp_header_image:_appUrl+"/img/logo.png"
"return":"http://apps.facebook.com/mygames/packages/returning"
cancel_return:"http://apps.facebook.com/mygames/packages/cancel"
},
[{itemKey:_itemkey}],
//Success handler
function(info:Object):void{
//Open paypal in new window
navigateToURL(new URLRequest(info.paypalurl), "_blank")
},
//Error handler
function(e:PlayerIOError):void{
trace("Unable to buy item", e);
}
);

when i click return after succesfull payment i appears like this(same as azuanagames problem above, URL of the page that just goes into a loop with resend button)
Image

how to fix it? also seems my browser is bloking new window popup when redirecting to paypal.

Second, how do you connect with your players? Regular connect? Quickconnect? You can do it from the client, but you have to connect through regular connect, as that user, and on a secured connection that has the access rights to modify the vault. If your game is a multiplayer game, it's highly recommended that you do this in serverside code instead.


Im using oauth connect with facebook acces_token, but my problem is because im creating lobby system with multiplayer listroom method, so i have to update user object on lobby, that's before any player have connection for joining room, after successfull transaction player have to returning to lobby before joining any room. How can i show message to player is their transaction is successfull and their player object item is updated?

The PayVault system makes no difference between test transactions and real transactions, regardless of which provider you are using. This means that test transactions will show up in the transaction log and revenue statistics, and also that you will be charged for test transactions. I suggest that you hold off on the full tests until you absolutely have to, for example you can use the give method in payvault to give a user an item so you don't have to complete an actual transaction before it appears in that user's vault.


maybe you should consider to allow creating (just one) test user or master account for testing using payvault that will not be charged if make any transaction using that account :)
I'm a perfectionist, i have to test hundred times to make sure is working before goes live :D
playerio is great, last year i don't have any idea how to create multiplayer games, but now with playerio everything is clear and make it happen. thanks guys.
wbsaputra
Paid Member
 
Posts: 140
Joined: June 29th, 2010, 4:38 pm


Return to PayVault



cron