From 98526d82d95313c5ceac5c1c416ec1dddb0a6d5a Mon Sep 17 00:00:00 2001 From: Savya Bikram Shah Date: Thu, 7 May 2026 18:10:17 +0545 Subject: [PATCH] feat: route FonepayClient through FonepayAsyncBridge; bump 0.2.0 --- .../CHANGELOG.md | 5 ++ .../Runtime/Core/FonepayClient.cs | 46 ++++++------------- .../package.json | 2 +- 3 files changed, 19 insertions(+), 34 deletions(-) diff --git a/Packages/com.darkmattergameproduction.fonepay-unity/CHANGELOG.md b/Packages/com.darkmattergameproduction.fonepay-unity/CHANGELOG.md index 9d156ad..fe48a97 100644 --- a/Packages/com.darkmattergameproduction.fonepay-unity/CHANGELOG.md +++ b/Packages/com.darkmattergameproduction.fonepay-unity/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.2.0] - 2026-05-07 + +### Changed +- All `FonepayClient` public methods now return `FonepayAsync` / `FonepayAsync` instead of `Task` / `Task`. Callers `await` the same way; UniTask users get native `UniTask` under `#if UNITASK_SUPPORT`. + ## [0.1.0] - 2026-05-07 ### Added diff --git a/Packages/com.darkmattergameproduction.fonepay-unity/Runtime/Core/FonepayClient.cs b/Packages/com.darkmattergameproduction.fonepay-unity/Runtime/Core/FonepayClient.cs index 7e5b4bc..2507877 100644 --- a/Packages/com.darkmattergameproduction.fonepay-unity/Runtime/Core/FonepayClient.cs +++ b/Packages/com.darkmattergameproduction.fonepay-unity/Runtime/Core/FonepayClient.cs @@ -4,10 +4,6 @@ using System.Threading.Tasks; namespace Darkmatter.Fonepay { - /// - /// Public facade. Auto-loads config + secrets via . - /// Caller never touches credentials. - /// public sealed class FonepayClient { private readonly FonepayApiClient _api; @@ -22,41 +18,25 @@ namespace Darkmatter.Fonepay _api = new FonepayApiClient(config, signer); } - /// - /// Request a new QR code. The returned URL is valid for 15 minutes. Call GetStatusAsync() to check if the QR code has been paid. - /// - /// - /// - /// - public Task PurchaseAsync(QrRequest req, CancellationToken ct = default) - => _api.PostQRAsync(req, ct); + public FonepayAsync PurchaseAsync(QrRequest req, CancellationToken ct = default) + => FonepayAsyncBridge.Wrap(_api.PostQRAsync(req, ct), ct); - /// - /// Check if a QR code has been paid. Call after PostQRAsync() to check if the QR code has been paid. Returns "PAID" if successful, "UNPAID" if not yet paid, or an error message if the PRN is invalid or expired. - /// - /// - /// - /// - public Task GetStatusAsync(string prn, CancellationToken ct = default) - => _api.GetStatusAsync(prn, ct); + public FonepayAsync GetStatusAsync(string prn, CancellationToken ct = default) + => FonepayAsyncBridge.Wrap(_api.GetStatusAsync(prn, ct), ct); - /// - /// Request a tax refund. Returns "REFUND_SUCCESS" if successful, or an error message if the PRN is invalid, expired, or not eligible for refund. - /// - /// - /// - /// - public Task PostTaxRefundAsync(TaxRefundRequest req, CancellationToken ct = default) - => _api.PostTaxRefundAsync(req, ct); + public FonepayAsync PostTaxRefundAsync(TaxRefundRequest req, CancellationToken ct = default) + => FonepayAsyncBridge.Wrap(_api.PostTaxRefundAsync(req, ct), ct); - /// - /// Connects to the QR websocket and awaits the terminal payment frame, then auto-disconnects. - /// Pass from . - /// - public async Task AwaitPaymentAsync( + public FonepayAsync AwaitPaymentAsync( string websocketUrl, Action onQrVerified = null, CancellationToken ct = default) + => FonepayAsyncBridge.Wrap(AwaitPaymentInternalAsync(websocketUrl, onQrVerified, ct), ct); + + private async Task AwaitPaymentInternalAsync( + string websocketUrl, + Action onQrVerified, + CancellationToken ct) { if (string.IsNullOrEmpty(websocketUrl)) throw new ArgumentException("Websocket URL required", nameof(websocketUrl)); diff --git a/Packages/com.darkmattergameproduction.fonepay-unity/package.json b/Packages/com.darkmattergameproduction.fonepay-unity/package.json index d916f9d..1c561a8 100644 --- a/Packages/com.darkmattergameproduction.fonepay-unity/package.json +++ b/Packages/com.darkmattergameproduction.fonepay-unity/package.json @@ -1,7 +1,7 @@ { "name": "com.darkmattergameproduction.fonepay-unity", "displayName": "Fonepay Unity", - "version": "0.1.0", + "version": "0.2.0", "unity": "6000.4", "unityRelease": "5f1", "description": "Fonepay payment integration for Unity. Generate Fonepay QR codes, await payment confirmation via websocket, and process tax refunds. Credentials managed via Tools > Fonepay > Settings.",