Hello!
I have a few questions on a PayPal implementation that I am doing for an HTML5 application. I am following the non-receipt payment processing flow and it is working like a charm. I just have a few questions on the PayPal return link and PlayFab Payment Confirmation steps.
The parameters that are returned from PayPal are as follows,
orderId: PayPal invoice number
playfabId: PlayFab User ID
The first question I have is should that orderId be the PayPal invoice number? Or should it be the PlayFab OrderId that is associated to the purchase? If it is supposed to be the PayPal orderId am I missing an API call where you can pass the PayPal invoice number and a PlayFab User Id to Confirm a purchase?
The reason I ask is if the payment is severed (computer crash, browser cache/local storage clear, etc) how can we recover that payment since ConfirmPurchase needs the PlayFab OrderId not the PayPal invoice. Are there any best practices for implementing PayPal IAP on an HTML5 application? My initial thoughts are,
I would really like to keep my payment confirmation page static and not have to spin up an application stack for it.
Thanks for taking the time to read this and please let me know any further questions or insight you may need.
(Sorry for the double post this I don't know why it combined my drafts!)
Answer by SethDu · Jul 26, 2019 at 07:18 AM
I have confirmed with our team and the PlayFab invoice ID equals to the Playfab order ID
I am still seeing a different order ID return in the return link. Here is the payload from playfab PayForPurchase Return
{"code":200,"status":"OK","data":{"OrderId":"4907FC9BFC822B66","Status":"Init","VCAmount":{"GC":10},"PurchaseCurrency":"RM","PurchasePrice":1,"CreditApplied":0,"ProviderData":"EC-6WM01362BC8385748","PurchaseConfirmationPageURL":"https://www.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=EC-6WM01362BC8385748","VirtualCurrency":{"CC":150,"GC":70}}}
Here is the full return link that comes back.
https://lab.ag.com/playfab-api/src/payment.html?orderId=5262452436492233574&playfabId=52EFB16BD591EF79
That orderId matches with the PayPal invoice number but _not_ the PlayFab OrderId. When I send the invoice number via ConfirmPurchase I get a Int padding error for the ID that was given.
Here is the payload back from ConfirmPurchase (I am using the JavascriptSDK)
{"code":400,"status":"BadRequest","error":"InvalidParams","errorCode":1000,"errorMessage":"Invalid input parameters","errorDetails":{"OrderId":["must fit within the range of UInt64"]}}
@SethDu Sorry forgot to tag you so you would see!
It is the same number but with different format, we have checked the source code and PlayFab stores a hexadecimal order ID while PayPal uses decimal. If you want to store/cache order IDs, do a conversion before use it.
You may confirm it via simple C# codes:
using System; using System.Globalization; namespace ConsoleApp1 { class Program { static void Main(string[] args) { ulong reqOrderId = ToUint64("4907FC9BFC822B66"); Console.WriteLine(reqOrderId); Console.ReadLine(); } public static ulong ToUint64(string value) { return ulong.Parse(value, NumberStyles.HexNumber); } } }
Ah! This is what I was missing! Thanks! Is there any way you could add this to the PayPal documentation @SethDu Thanks!