首页 > 解决方案 > 如何在 unity3d webGL 中进行正确的 facebook 支付?

问题描述

我正在尝试制作统一的 webgl 游戏。我目前正在使用我自己的 python django 服务器。但我现在面临的问题很少。

首先,当客户端完成支付行为时,反复显示javascript错误。这是错误代码:

Invoking error handler due to
Uncaught abort(219) at Error
at jsStackTrace (lottery.wasm.framework.unityweb:8:22313)
at stackTrace [Object.stackTrace] (lottery.wasm.framework.unityweb:8:22484)
at Object.onAbort (https:/lottery-server.ntucorp.com/static/game/Build/UnityLoader.js:4:11047)
at abort ('lottery.wasm.framework.unityweb:8:521824')
at wasm-function[62206]:0x1143303
at wasm-function[25973]:0x9c45e6
at wasm-function[61403]:0x111d42f
at wasm-function[27992]:0xa2a9df
at wasm-function[50781]:0xeabcd7
at wasm-function[35699]:0xba8a56
at wasm-function[35698]:0xba8997
at wasm-function[35744]:0xbaa780
at wasm-function[26171]:0x9c9232
at wasm-function[35758]:0xbab0e3
at wasm-function[26171]:0x9c9232
at wasm-function[35768]:0xbab37e
at wasm-function[23663]:0x9815d2
at wasm-function[61943]:0x11424be
at dynCall_iiiii [Object.dynCall_iiiii] (lottery.wasm.framework.unityweb:8:494571)
at invoke_iiiii (lottery.wasm.framework.unityweb:8:362010)
at wasm-function[59810]:0x10db82f
at wasm-function[59101]:0x10b9e40
at wasm-function[4047]:0x197f91
at wasm-function[4046]:0x197ebf
at wasm-function[7537]:0x2c346b
at wasm-function[7534]:0x2c283b
at wasm-function[11356]:0x483dc2
at wasm-function[9973]:0x3cab31
at blob:https:/lottery-server.ntucorp.com/d6308b13-98d3-4a85-abfd-0c7db365fcfd:8:438788
at ccall [Object.ccall] (lottery.wasm.framework.unityweb:8:16382)
at SendMessage (lottery.wasm.framework.unityweb:8:9099)
at sendMessage [Object.sendMessage] (lottery.wasm.framework.unityweb:8:48724)
at uiCallback (lottery.wasm.framework.unityweb:8:50342)
at a.__wrapper.a.__wrapper (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:93:765)
at Object.cb (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:145:4420)
at c (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:145:10332)
at a.c.read (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:125:737)
at a._processor (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:127:283)
at a.b.enqueue (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:126:711)
at Object.u [as onMessage] (https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:143:2477)
at https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:136:2925
at https:/connect.facebook.net/en_US/sdk.js?hash=11641b2e4a5fab828e74fff5f206cf37&ua=modern_es6:50:208'''

我正在使用 Unity Facebook SDK,所以在统一 c# 脚本中我调用了这个函数。

FB.Canvas.Pay(
product_url,
quantity:1,
callback:ProductCallback
);

而且,无论如何它都会返回回调函数,而这个回调的响应就是this。

PayResponse:{"callback_id":"4","response":{"payment_id":1794879660642720,"amount":"2.99","currency":"USD","quantity":"1","request_id":"","status":"initiated","signed_request":"r4_00GLFbodYSMVeVGfFcfuzIr1HQKd9EYiO_OM0eXM.eyJhbGdvcml0aG0iOiJITUFDLVNIQTI1NiIsImFtb3VudCI6IjIuOTkiLCJjdXJyZW5jeSI6IlVTRCIsImlzc3VlZF9hdCI6MTU3ODA0MzI2OCwicGF5bWVudF9pZCI6MTc5NDg3OTY2MDY0MjcyMCwicXVhbnRpdHkiOiIxIiwicmVxdWVzdF9pZCI6IiIsInN0YXR1cyI6ImluaXRpYXRlZCJ9"}}

其次,我无法使 Facebook Unity SDK 可用,即 FB.Canvas.PayWithProductID。它只是不起作用,它只是省略了 javascript 错误(UnityLoader.js 错误,类似于我已经提到的错误),而且它也不提供回调。

同样在文档中,https://developers.facebook.com/docs/games_payments/payments_lite? locale=ko_KR 在这里它说正确的代码是 FB.PayWithProductID,但 Facebook SDK 没有任何 FB.PayWithProductID。它只有 FB**.Canvas.**PayWithProductID。

如何从 facebook 获得适当的回调?我无法获得任何类型的回调参数。我收到的只是事实 facebook 调用了我的回调 url,不包含任何 GET 参数。我只是返回 request.GET.get('hub.challenge'),但无论如何它仍然是 None。

为什么会这样?请帮忙。

标签: facebookunity3dfacebook-graph-api

解决方案


这是一个非常广泛的问题,因为它包含了很多内容。我建议将您的项目连接到 API,然后调用 Facebook 的 API 进行付款。这是文档:https ://developers.facebook.com/docs/graph-api/reference/v5.0/payment

我之所以这么说,是因为这里没有太多关于您如何以及从何处调用付款方式的上下文。您是否已经通过 API 执行此操作?或者您是否正在尝试从引擎本身实现这一目标?

这是关于如何从统一调用 API 的非常有用的指南: https ://www.red-gate.com/simple-talk/dotnet/c-programming/calling-restful-apis-unity3d/

我强烈建议您执行此 API 方面,因为它比通过引擎执行此操作更安全,如果您正在这样做的话。


推荐阅读