/// <inheritdoc /> public async Task RefreshBalanceAsync(IAgentContext agentContext, PaymentAddressRecord paymentAddress = null) { if (paymentAddress == null) { var provisioning = await provisioningService.GetProvisioningAsync(agentContext.Wallet); if (provisioning.DefaultPaymentAddressId == null) { throw new AriesFrameworkException(ErrorCode.RecordNotFound, "Default PaymentAddressRecord not found"); } paymentAddress = await recordService.GetAsync <PaymentAddressRecord>(agentContext.Wallet, provisioning.DefaultPaymentAddressId); } // Cache sources data in record for one hour var request = await IndyPayments.BuildGetPaymentSourcesAsync(agentContext.Wallet, null, paymentAddress.Address); var response = await IndyLedger.SubmitRequestAsync(await agentContext.Pool, request.Result); var sourcesJson = await IndyPayments.ParseGetPaymentSourcesAsync(paymentAddress.Method, response); var sources = sourcesJson.ToObject <IList <IndyPaymentInputSource> >(); paymentAddress.Sources = sources; paymentAddress.SourcesSyncedAt = DateTime.Now; await recordService.UpdateAsync(agentContext.Wallet, paymentAddress); }