Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class FacebookPay : MonoBehaviour{
public string ProductURL;
public int Quantity;
void OnMouseDown()
{
#if !UNITY_EDITOR
FB.Canvas.Pay(product: ProductURL,
action: "purchaseitem",
quantity: 1,
callback: PayCallback);
#else
MockResponse();
#endif
}
void MockResponse()
{
Invoke("GiveItem",1.5f);
}
void PayCallback(FBResult result)
{
if (result != null)
{
var response = Json.Deserialize(result.Text) as Dictionary<string, object>;
if(Convert.ToString(response["status"]) == "completed")
{
GiveItem();
}
else
{
// Payment Failed
}
}
}
void GiveItem()
{
// Implement your give item here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.