sample fixes
This commit is contained in:
BIN
Samples~/.DS_Store
vendored
Normal file
BIN
Samples~/.DS_Store
vendored
Normal file
Binary file not shown.
8
Samples~/Example.meta
Normal file
8
Samples~/Example.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65d000fc5ca9742ec882f227d68c7bd4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
BIN
Samples~/Example/.DS_Store
vendored
Normal file
BIN
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)
|
||||||
{
|
{
|
||||||
|
if (qrImage != null)
|
||||||
|
{
|
||||||
|
qrImage.sprite = null;
|
||||||
qrImage.gameObject.SetActive(false);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
2
Samples~/Example/SamplePayment.cs.meta
Normal file
2
Samples~/Example/SamplePayment.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d53a9483205b945d69e846f2285560bd
|
||||||
1562
Samples~/Example/SampleScene.unity
Normal file
1562
Samples~/Example/SampleScene.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Samples~/Example/SampleScene.unity.meta
Normal file
7
Samples~/Example/SampleScene.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Reference in New Issue
Block a user