sample fixes

This commit is contained in:
Savya Bikram Shah
2026-05-07 18:44:59 +05:45
parent 4fe63fc575
commit cca555f3e9
8 changed files with 1594 additions and 6 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
Samples~/.DS_Store vendored Normal file

Binary file not shown.

8
Samples~/Example.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 65d000fc5ca9742ec882f227d68c7bd4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

BIN
Samples~/Example/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -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);
} }

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: d53a9483205b945d69e846f2285560bd

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8c9cfa26abfee488c85f1582747f6a02
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: