Search code examples
c#paypalunity-game-enginepaypal-sandboxsandbox

Making Test Requests from Unity3D


I am creating my shop system for my game, and I'll use paypal as method of payment, and I have all finished logic, but I need to test calls to verify purchases, I researched and paypal provides a method to this "Sandbox accounts" which allows simulating a virtual PayPal accounts up here all right, now the problem is that my system is a little different to the example of the tutorial on how to use the sandbox calls account:Test Calls Tutorial

I am using this to send the payment information to paypal from my game:

 public void DoPayment(PaypalItem _item)
    {
        //string itemName, string itemNumber, double price, string userName
        if (!HasInfo)
        {
            Debug.Log("Dont have Info get");
            return;
        }

        StringBuilder url = new StringBuilder();

        string mod_price = string.Format("{0:0.00}", _item._price).ToString().Replace(",", ".");

        url.Append(serverURL + "?cmd=_xclick&currency_code=" + this.Currency.ToString() + "&business=" + this.Email);
        url.Append("&amount=" + mod_price);

        url.AppendFormat("&item_name={0}", _item._itemName);
        url.AppendFormat("&item_number={0}", _item._itemNumber);
        url.AppendFormat("&custom={0}", _item._customer);
        url.AppendFormat("&notify_url={0}", this.NotifyUrl);

        if (!ReturnUrl.Equals(string.Empty))
        {
            url.AppendFormat("&return={0}", this.ReturnUrl);
        }
        else if (!CancelUrl.Equals(string.Empty))
        {
            url.AppendFormat("&cancel_return={0}", this.CancelUrl);
        }
        Application.OpenURL(url.ToString());
    }

the question is which part I need to modify to make the call to the sandbox account?

any help would be greatly appreciated.


Solution

  • It should work if you change the serverURL parameter to "https://www.sandbox.paypal.com", as denoted on the documentation available at https://developer.paypal.com/webapps/developer/docs/classic/lifecycle/sb_overview/ .