question

hadrienbruley avatar image
hadrienbruley asked

Problems with PayForPurchase in UNITY

Hi,

I have a problem with my PayForPurchase call :

Even if all my request params seems good, the PayForPurchase return the "InvalidParams" Error

here is my code :

        public static void StartBundlePurchase ( string itemID )
        {
            if (_catalog.ContainsKey(itemID) == false)
            {
                Debug.LogError("Bundle not found !");
                return ;
            }
            Debug.Log("PlayFab: start Bundle purchase : " + itemID);

            StartPurchaseRequest request = new StartPurchaseRequest();
            request.CatalogVersion = _settings.catalogVersion;
            request.Items = new List<ItemPurchaseRequest>();
            ItemPurchaseRequest item = new ItemPurchaseRequest();
            item.ItemId = itemID;
            item.Quantity = 1;
            request.Items.Add(item);
            PlayFabClientAPI.StartPurchase(request, OnBundleStartPurchaseSuccess, OnBundleStartPurchaseError);
            
        }

        private static void OnBundleStartPurchaseSuccess ( StartPurchaseResult result )
        {
            Debug.Log("PlayFab: Bundle purchase started");
            foreach (PaymentOption paymentOption in result.PaymentOptions)
            {
                Debug.Log("Provider name : " + paymentOption.ProviderName + ", currency : " + paymentOption.Currency + ", price : " + paymentOption.Price + ", store credit : " + paymentOption.StoreCredit);
            }
            _currentOrderId = result.OrderId;

            PayForPurchase(result.OrderId, result.PaymentOptions[0]);
        }

        private static void OnBundleStartPurchaseError ( PlayFabError error )
        {
            if (error.ErrorCode != 0)
            {
                Debug.LogError("PlayFab: Fail to start Bundle purchase - error code : " + error.ErrorCode + ",\nerror messsage : " + error.ErrorMessage);
            }
        }

        public static void PayForPurchase ( string orderId, PaymentOption paymentOption )
        {
            Debug.Log("PlayFab: Pay for purchase : " + orderId + " in : " + paymentOption.Currency + " with : " + paymentOption.ProviderName);
            PayForPurchaseRequest request = new PayForPurchaseRequest();
            request.OrderId = orderId;
            request.ProviderName = paymentOption.ProviderName;
            request.Currency = paymentOption.Currency;
            PlayFabClientAPI.PayForPurchase(request, OnBundlePayForPurchaseSuccess, OnBundlePayForPurchaseError);
        }

        private static void OnBundlePayForPurchaseSuccess ( PayForPurchaseResult result )
        {
            Debug.Log("PlayFab: Bundle pay for purchase");
            XsollaSDKStatic.CreatePaymentForm(result.ProviderToken, OnXsollaPaymentDone, OnXsollaPaymentError, true);
            _currentOrderId = null;
        }

We are using Xsolla and all the setup of Xsolla may be completed.

I have 2 payment providers : "Xsolla" and "Test".

When I try with Test I have a "ServiceUnavailable" Error instead of "InvalidParams".

Hope you can help me.

Regards

apis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Yes, sorry for the confusion - the "Test" payment provider is for our internal testing. We have a bug open to remove that from the list for titles.

For the issue you're seeing, what is the complete error response, including the errorDetails?

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

hadrienbruley avatar image hadrienbruley commented ·

Hi Brendan,

The error message is : Invalid input parameters

and there is no error details the dictionary is empty.

0 Likes 0 ·
brendan avatar image brendan hadrienbruley commented ·

Can you please send us a Netmon or Wireshark capture showing this? It should not be possible for errorDetails to be null on an Invalid Input Parameters error response.

0 Likes 0 ·
hadrienbruley avatar image hadrienbruley commented ·

Here my wireshark capture of the loading + buying process

playfabcapture.zip

0 Likes 0 ·
playfabcapture.zip (20.9 KiB)
brendan avatar image brendan hadrienbruley commented ·

Unfortunately, that's still encrypted traffic, so I can't actually see the details. Can you have a look at this guide on SSL (https://wiki.wireshark.org/SSL), and get a capture that has the decrypted packets? Alternately, if you can reproduce this in Postman, that may be easier - you could then just copy/paste the calls and responses and send that to us.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.