feat: route FonepayClient through FonepayAsyncBridge; bump 0.2.0

This commit is contained in:
Savya Bikram Shah
2026-05-07 18:10:17 +05:45
parent 270d6a69ae
commit 6b8815051d
3 changed files with 19 additions and 34 deletions

View File

@@ -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<T>` / `FonepayAsync` instead of `Task<T>` / `Task`. Callers `await` the same way; UniTask users get native `UniTask` under `#if UNITASK_SUPPORT`.
## [0.1.0] - 2026-05-07
### Added

View File

@@ -4,10 +4,6 @@ using System.Threading.Tasks;
namespace Darkmatter.Fonepay
{
/// <summary>
/// Public facade. Auto-loads config + secrets via <see cref="FonepayConfig.Load"/>.
/// Caller never touches credentials.
/// </summary>
public sealed class FonepayClient
{
private readonly FonepayApiClient _api;
@@ -22,41 +18,25 @@ namespace Darkmatter.Fonepay
_api = new FonepayApiClient(config, signer);
}
/// <summary>
/// Request a new QR code. The returned URL is valid for 15 minutes. Call GetStatusAsync() to check if the QR code has been paid.
/// </summary>
/// <param name="req"></param>
/// <param name="ct"></param>
/// <returns></returns>
public Task<QrResult> PurchaseAsync(QrRequest req, CancellationToken ct = default)
=> _api.PostQRAsync(req, ct);
public FonepayAsync<QrResult> PurchaseAsync(QrRequest req, CancellationToken ct = default)
=> FonepayAsyncBridge.Wrap(_api.PostQRAsync(req, ct), ct);
/// <summary>
/// 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.
/// </summary>
/// <param name="prn"></param>
/// <param name="ct"></param>
/// <returns></returns>
public Task<QrResult> GetStatusAsync(string prn, CancellationToken ct = default)
=> _api.GetStatusAsync(prn, ct);
public FonepayAsync<QrResult> GetStatusAsync(string prn, CancellationToken ct = default)
=> FonepayAsyncBridge.Wrap(_api.GetStatusAsync(prn, ct), ct);
/// <summary>
/// Request a tax refund. Returns "REFUND_SUCCESS" if successful, or an error message if the PRN is invalid, expired, or not eligible for refund.
/// </summary>
/// <param name="req"></param>
/// <param name="ct"></param>
/// <returns></returns>
public Task<TaxRefundResponse> PostTaxRefundAsync(TaxRefundRequest req, CancellationToken ct = default)
=> _api.PostTaxRefundAsync(req, ct);
public FonepayAsync<TaxRefundResponse> PostTaxRefundAsync(TaxRefundRequest req, CancellationToken ct = default)
=> FonepayAsyncBridge.Wrap(_api.PostTaxRefundAsync(req, ct), ct);
/// <summary>
/// Connects to the QR websocket and awaits the terminal payment frame, then auto-disconnects.
/// Pass <see cref="QrResult.thirdpartyQrWebSocketUrl"/> from <see cref="PurchaseAsync"/>.
/// </summary>
public async Task<QRPaymentStatus> AwaitPaymentAsync(
public FonepayAsync<QRPaymentStatus> AwaitPaymentAsync(
string websocketUrl,
Action<bool> onQrVerified = null,
CancellationToken ct = default)
=> FonepayAsyncBridge.Wrap(AwaitPaymentInternalAsync(websocketUrl, onQrVerified, ct), ct);
private async Task<QRPaymentStatus> AwaitPaymentInternalAsync(
string websocketUrl,
Action<bool> onQrVerified,
CancellationToken ct)
{
if (string.IsNullOrEmpty(websocketUrl))
throw new ArgumentException("Websocket URL required", nameof(websocketUrl));

View File

@@ -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.",