question

Zachary Paladino avatar image
Zachary Paladino asked

PayPal Return Link Parameters and HTML5 Implementation

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,

  • Store the current purchase PlayFab OrderId in local storage to check on run for confirmation of purchase (unless cache clear)
  • Window communication from the payment page to the original window to fire off the confirmation of purchase (Only works if the original window is still there and the user did not copy and paste the confirmation link)
  • The confirmation page offers a login so that we can recover the payment and confirm the order (but that only works if we have the order number from PlayFab in the return link parameters)
  • Maybe something with CloudScript? But, I am not as familiar with that yet and I am open to suggestions

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!)

Player DataCloudScriptPlayer Inventory
2 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.

Seth Du avatar image Seth Du ♦ commented ·

I will dig into it and will discuss with the team.

1 Like 1 ·
Zachary Paladino avatar image Zachary Paladino Seth Du ♦ commented ·

Thank you!

0 Likes 0 ·

1 Answer

·
Seth Du avatar image
Seth Du answered

I have confirmed with our team and the PlayFab invoice ID equals to the Playfab order ID

6 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.

Zachary Paladino avatar image Zachary Paladino commented ·

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.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Zachary Paladino commented ·

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);
		}
	}
}
1 Like 1 ·
Zachary Paladino avatar image Zachary Paladino Seth Du ♦ commented ·

Ah! This is what I was missing! Thanks! Is there any way you could add this to the PayPal documentation @SethDu Thanks!

0 Likes 0 ·
Show more comments
Zachary Paladino avatar image Zachary Paladino Zachary Paladino commented ·

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"]}}
0 Likes 0 ·
Zachary Paladino avatar image Zachary Paladino Zachary Paladino commented ·

@SethDu Sorry forgot to tag you so you would see!

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.