This commit is contained in:
8
Assets/Samples.meta
Normal file
8
Assets/Samples.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5dff20c6950e54d71bfe971186191b01
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Samples/Fonepay Unity.meta
Normal file
8
Assets/Samples/Fonepay Unity.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b7e8dee7532643a181e55ce459fef09
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Samples/Fonepay Unity/0.2.0.meta
Normal file
8
Assets/Samples/Fonepay Unity/0.2.0.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8231582f6900a44d2a9868b5baad6101
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Samples/Fonepay Unity/0.2.0/.DS_Store
vendored
Normal file
BIN
Assets/Samples/Fonepay Unity/0.2.0/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 314c0fedd56f54fb893743926389db98
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Assets/Samples/Fonepay Unity/0.2.0/Example Payment Flow/.DS_Store
vendored
Normal file
BIN
Assets/Samples/Fonepay Unity/0.2.0/Example Payment Flow/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"displayName":"Example Sample",
|
||||||
|
"description": "Replace this string with your own description of the sample. Delete the Samples folder if not needed."
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Darkmatter.Fonepay.Samples
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Minimal end-to-end sample: request QR, render to Image, await payment,
|
||||||
|
/// support cancellation via a cancel button.
|
||||||
|
/// </summary>
|
||||||
|
public class SamplePayment : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Image qrImage;
|
||||||
|
[SerializeField] private GameObject successObject;
|
||||||
|
[SerializeField] private GameObject failedObject;
|
||||||
|
[SerializeField] private Button payButton;
|
||||||
|
[SerializeField] private Button cancelButton;
|
||||||
|
[SerializeField] private float amount = 1f;
|
||||||
|
|
||||||
|
private CancellationTokenSource _payCts;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
payButton.onClick.AddListener(() => InitiatePayment().Forget());
|
||||||
|
if (cancelButton != null)
|
||||||
|
cancelButton.onClick.AddListener(() => _payCts?.Cancel());
|
||||||
|
}
|
||||||
|
|
||||||
|
private async UniTask InitiatePayment()
|
||||||
|
{
|
||||||
|
if (_payCts != null) return;
|
||||||
|
|
||||||
|
payButton.interactable = false;
|
||||||
|
var fonepay = new FonepayClient();
|
||||||
|
var cts = CancellationTokenSource.CreateLinkedTokenSource(destroyCancellationToken);
|
||||||
|
_payCts = cts;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var qr = await fonepay.PurchaseAsync(
|
||||||
|
new QrRequest { amount = amount, remarks1 = "sample" },
|
||||||
|
cts.Token);
|
||||||
|
|
||||||
|
if (qr.qrCode != null)
|
||||||
|
{
|
||||||
|
qrImage.sprite = Sprite.Create(
|
||||||
|
qr.qrCode,
|
||||||
|
new Rect(0, 0, qr.qrCode.width, qr.qrCode.height),
|
||||||
|
new Vector2(0.5f, 0.5f));
|
||||||
|
qrImage.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var payment = await fonepay.AwaitPaymentAsync(
|
||||||
|
qr.thirdpartyQrWebSocketUrl,
|
||||||
|
onQrVerified: v => Debug.Log($"Fonepay QR verified: {v}"),
|
||||||
|
ct: cts.Token);
|
||||||
|
|
||||||
|
Debug.Log($"Payment frame: {JsonUtility.ToJson(payment)}");
|
||||||
|
ShowResult(payment.Outcome == PaymentOutcome.Complete);
|
||||||
|
}
|
||||||
|
catch (OperationCanceledException)
|
||||||
|
{
|
||||||
|
Debug.Log("Payment cancelled.");
|
||||||
|
ShowResult(false);
|
||||||
|
}
|
||||||
|
catch (FonepayError e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Fonepay API error {e.ErrorCode}: {e.Message}");
|
||||||
|
ShowResult(false);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException e)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Websocket closed early: {e.Message}");
|
||||||
|
ShowResult(false);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cts.Dispose();
|
||||||
|
if (_payCts == cts) _payCts = null;
|
||||||
|
if (this != null && payButton != null) payButton.interactable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ShowResult(bool ok)
|
||||||
|
{
|
||||||
|
if (qrImage != null)
|
||||||
|
{
|
||||||
|
qrImage.sprite = null;
|
||||||
|
qrImage.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
if (successObject != null) successObject.SetActive(ok);
|
||||||
|
if (failedObject != null) failedObject.SetActive(!ok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d53a9483205b945d69e846f2285560bd
|
||||||
@@ -151,9 +151,9 @@ RectTransform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 508689485}
|
m_Father: {fileID: 508689485}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 1}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: -140.79999}
|
m_AnchoredPosition: {x: 0, y: -69}
|
||||||
m_SizeDelta: {x: 200, y: 50}
|
m_SizeDelta: {x: 200, y: 50}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &454749
|
--- !u!114 &454749
|
||||||
@@ -388,7 +388,8 @@ RectTransform:
|
|||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 7.9915, y: 7.9915, z: 7.9915}
|
m_LocalScale: {x: 7.9915, y: 7.9915, z: 7.9915}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children:
|
||||||
|
- {fileID: 1350158650}
|
||||||
m_Father: {fileID: 508689485}
|
m_Father: {fileID: 508689485}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
@@ -445,6 +446,7 @@ GameObject:
|
|||||||
- component: {fileID: 508689485}
|
- component: {fileID: 508689485}
|
||||||
- component: {fileID: 508689487}
|
- component: {fileID: 508689487}
|
||||||
- component: {fileID: 508689486}
|
- component: {fileID: 508689486}
|
||||||
|
- component: {fileID: 508689488}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Image
|
m_Name: Image
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -514,6 +516,24 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 508689484}
|
m_GameObject: {fileID: 508689484}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &508689488
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 508689484}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d53a9483205b945d69e846f2285560bd, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Darkmatter.Fonepay.Samples.SamplePayment
|
||||||
|
qrImage: {fileID: 308706331}
|
||||||
|
successObject: {fileID: 454747}
|
||||||
|
failedObject: {fileID: 1400840764}
|
||||||
|
payButton: {fileID: 1002816889}
|
||||||
|
cancelButton: {fileID: 1350158652}
|
||||||
|
amount: 1
|
||||||
--- !u!1 &519420028
|
--- !u!1 &519420028
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -772,6 +792,140 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1002816887}
|
m_GameObject: {fileID: 1002816887}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &1350158649
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1350158650}
|
||||||
|
- component: {fileID: 1350158654}
|
||||||
|
- component: {fileID: 1350158653}
|
||||||
|
- component: {fileID: 1350158652}
|
||||||
|
- component: {fileID: 1350158651}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Cancel
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1350158650
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1350158649}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 0.18375774, y: 0.18375774, z: 0.18375774}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 1884838835}
|
||||||
|
m_Father: {fileID: 308706330}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -12.8}
|
||||||
|
m_SizeDelta: {x: 160, y: 30}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1350158651
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1350158649}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7d55618be80a043b0b467209e1a80cbb, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Assembly-CSharp::Darkmatter.Fonepay.Samples.SamplePayment
|
||||||
|
--- !u!114 &1350158652
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1350158649}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Button
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_WrapAround: 0
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 1
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 0}
|
||||||
|
m_PressedSprite: {fileID: 0}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 1
|
||||||
|
m_TargetGraphic: {fileID: 1350158653}
|
||||||
|
m_OnClick:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
--- !u!114 &1350158653
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1350158649}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Image
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_Type: 1
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1350158654
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1350158649}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1400840764
|
--- !u!1 &1400840764
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -804,9 +958,9 @@ RectTransform:
|
|||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 508689485}
|
m_Father: {fileID: 508689485}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
m_AnchorMin: {x: 0.5, y: 1}
|
||||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
m_AnchorMax: {x: 0.5, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: -140.8}
|
m_AnchoredPosition: {x: 0, y: -69}
|
||||||
m_SizeDelta: {x: 200, y: 50}
|
m_SizeDelta: {x: 200, y: 50}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!114 &1400840766
|
--- !u!114 &1400840766
|
||||||
@@ -1046,6 +1200,143 @@ CanvasRenderer:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1625398629}
|
m_GameObject: {fileID: 1625398629}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!1 &1884838834
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1884838835}
|
||||||
|
- component: {fileID: 1884838837}
|
||||||
|
- component: {fileID: 1884838836}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text (TMP)
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1884838835
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1884838834}
|
||||||
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1350158650}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1884838836
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1884838834}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshProUGUI
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_text: Cancel
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4281479730
|
||||||
|
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||||
|
m_enableVertexGradient: 0
|
||||||
|
m_colorMode: 3
|
||||||
|
m_fontColorGradient:
|
||||||
|
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_fontColorGradientPreset: {fileID: 0}
|
||||||
|
m_spriteAsset: {fileID: 0}
|
||||||
|
m_tintAllSprites: 0
|
||||||
|
m_StyleSheet: {fileID: 0}
|
||||||
|
m_TextStyleHashCode: -1183493901
|
||||||
|
m_overrideHtmlColors: 0
|
||||||
|
m_faceColor:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 4294967295
|
||||||
|
m_fontSize: 24
|
||||||
|
m_fontSizeBase: 24
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 2
|
||||||
|
m_VerticalAlignment: 512
|
||||||
|
m_textAlignment: 65535
|
||||||
|
m_characterSpacing: 0
|
||||||
|
m_characterHorizontalScale: 1
|
||||||
|
m_wordSpacing: 0
|
||||||
|
m_lineSpacing: 0
|
||||||
|
m_lineSpacingMax: 0
|
||||||
|
m_paragraphSpacing: 0
|
||||||
|
m_charWidthMaxAdj: 0
|
||||||
|
m_TextWrappingMode: 1
|
||||||
|
m_wordWrappingRatios: 0.4
|
||||||
|
m_overflowMode: 0
|
||||||
|
m_linkedTextComponent: {fileID: 0}
|
||||||
|
parentLinkedComponent: {fileID: 0}
|
||||||
|
m_enableKerning: 0
|
||||||
|
m_ActiveFontFeatures: 6e72656b
|
||||||
|
m_enableExtraPadding: 0
|
||||||
|
checkPaddingRequired: 0
|
||||||
|
m_isRichText: 1
|
||||||
|
m_EmojiFallbackSupport: 1
|
||||||
|
m_parseCtrlCharacters: 1
|
||||||
|
m_isOrthographic: 1
|
||||||
|
m_isCullingEnabled: 0
|
||||||
|
m_horizontalMapping: 0
|
||||||
|
m_verticalMapping: 0
|
||||||
|
m_uvLineOffset: 0
|
||||||
|
m_geometrySortingOrder: 0
|
||||||
|
m_IsTextObjectScaleStatic: 0
|
||||||
|
m_VertexBufferAutoSizeReduction: 0
|
||||||
|
m_useMaxVisibleDescender: 1
|
||||||
|
m_pageToDisplay: 1
|
||||||
|
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_isUsingLegacyAnimationComponent: 0
|
||||||
|
m_isVolumetricText: 0
|
||||||
|
m_hasFontAssetChanged: 0
|
||||||
|
m_baseMaterial: {fileID: 0}
|
||||||
|
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
--- !u!222 &1884838837
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1884838834}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1949324813
|
--- !u!1 &1949324813
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
BIN
Packages/.DS_Store
vendored
Normal file
BIN
Packages/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Packages/com.darkmattergameproduction.fonepay-unity/.DS_Store
vendored
Normal file
BIN
Packages/com.darkmattergameproduction.fonepay-unity/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
Packages/com.darkmattergameproduction.fonepay-unity/Samples~/.DS_Store
vendored
Normal file
BIN
Packages/com.darkmattergameproduction.fonepay-unity/Samples~/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65d000fc5ca9742ec882f227d68c7bd4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Packages/com.darkmattergameproduction.fonepay-unity/Samples~/Example/.DS_Store
vendored
Normal file
BIN
Packages/com.darkmattergameproduction.fonepay-unity/Samples~/Example/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -30,14 +30,18 @@ namespace Darkmatter.Fonepay.Samples
|
|||||||
|
|
||||||
private async UniTask InitiatePayment()
|
private async UniTask InitiatePayment()
|
||||||
{
|
{
|
||||||
|
if (_payCts != null) return;
|
||||||
|
|
||||||
|
payButton.interactable = false;
|
||||||
var fonepay = new FonepayClient();
|
var fonepay = new FonepayClient();
|
||||||
_payCts = CancellationTokenSource.CreateLinkedTokenSource(destroyCancellationToken);
|
var cts = CancellationTokenSource.CreateLinkedTokenSource(destroyCancellationToken);
|
||||||
|
_payCts = cts;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var qr = await fonepay.PurchaseAsync(
|
var qr = await fonepay.PurchaseAsync(
|
||||||
new QrRequest { amount = amount, remarks1 = "sample" },
|
new QrRequest { amount = amount, remarks1 = "sample" },
|
||||||
_payCts.Token);
|
cts.Token);
|
||||||
|
|
||||||
if (qr.qrCode != null)
|
if (qr.qrCode != null)
|
||||||
{
|
{
|
||||||
@@ -51,7 +55,7 @@ namespace Darkmatter.Fonepay.Samples
|
|||||||
var payment = await fonepay.AwaitPaymentAsync(
|
var payment = await fonepay.AwaitPaymentAsync(
|
||||||
qr.thirdpartyQrWebSocketUrl,
|
qr.thirdpartyQrWebSocketUrl,
|
||||||
onQrVerified: v => Debug.Log($"Fonepay QR verified: {v}"),
|
onQrVerified: v => Debug.Log($"Fonepay QR verified: {v}"),
|
||||||
ct: _payCts.Token);
|
ct: cts.Token);
|
||||||
|
|
||||||
Debug.Log($"Payment frame: {JsonUtility.ToJson(payment)}");
|
Debug.Log($"Payment frame: {JsonUtility.ToJson(payment)}");
|
||||||
ShowResult(payment.Outcome == PaymentOutcome.Complete);
|
ShowResult(payment.Outcome == PaymentOutcome.Complete);
|
||||||
@@ -73,14 +77,19 @@ namespace Darkmatter.Fonepay.Samples
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_payCts.Dispose();
|
cts.Dispose();
|
||||||
_payCts = null;
|
if (_payCts == cts) _payCts = null;
|
||||||
|
if (this != null && payButton != null) payButton.interactable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowResult(bool ok)
|
private void ShowResult(bool ok)
|
||||||
{
|
{
|
||||||
qrImage.gameObject.SetActive(false);
|
if (qrImage != null)
|
||||||
|
{
|
||||||
|
qrImage.sprite = null;
|
||||||
|
qrImage.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
if (successObject != null) successObject.SetActive(ok);
|
if (successObject != null) successObject.SetActive(ok);
|
||||||
if (failedObject != null) failedObject.SetActive(!ok);
|
if (failedObject != null) failedObject.SetActive(!ok);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d53a9483205b945d69e846f2285560bd
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -6,7 +6,7 @@ EditorBuildSettings:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/SampleScene.unity
|
path: Packages/com.darkmattergameproduction.fonepay-unity/Samples/Example/SampleScene.unity
|
||||||
guid: 8c9cfa26abfee488c85f1582747f6a02
|
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||||
m_configObjects:
|
m_configObjects:
|
||||||
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||||
|
|||||||
Reference in New Issue
Block a user