Skip to content

Commit

Permalink
Fix Pay By Link
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwok He Chu committed Aug 10, 2023
1 parent 7806c64 commit 34fb3c7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions paybylink-example/Services/LinksService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LinksService(IPaymentLinksService paymentLinksService, IPaymentLinkReposi

public async Task<PaymentLinkResponse> CreatePaymentLinkAsync(string reference, long amount, bool isReusable, CancellationToken cancellationToken)
{
var createPayByLinkRequest = new CreatePaymentLinkRequest(
var createPayByLinkRequest = new PaymentLinkRequest(
merchantAccount: _merchantAccount, // Required.
amount: new Amount("EUR", amount), // Required, value in minor units.
reference: reference, // Required, use for example: new Guid().
Expand All @@ -55,8 +55,8 @@ public async Task<PaymentLinkResponse> CreatePaymentLinkAsync(string reference,
id: response.Id,
reference: response.Reference, response.Url,
expiresAt: DateTime.Parse(response.ExpiresAt),
status: response.Status.ToString(),
isReusable: response.Reusable
status: response.Status.ToString(),
isReusable: response.Reusable.HasValue ? response.Reusable.Value : false
);
_logger.LogInformation($"Response from API:\n{response}\n");
return response;
Expand All @@ -75,16 +75,15 @@ public async Task<ConcurrentDictionary<string, PaymentLinkModel>> GetAndUpdatePa
{
try
{
var response =
await _paymentLinksService.GetPaymentLinkAsync(kvp.Value.Id, cancellationToken: cancellationToken);
PaymentLinkResponse response = await _paymentLinksService.GetPaymentLinkAsync(kvp.Value.Id, cancellationToken: cancellationToken);

// Update each individual link.
_paymentLinkRepository.Upsert(
id: response.Id,
reference: response.Reference, response.Url,
expiresAt: DateTime.Parse(response.ExpiresAt),
status: response.Status.ToString(),
isReusable: response.Reusable
isReusable: response.Reusable.HasValue ? response.Reusable.Value : false
);
}
catch (Adyen.HttpClient.HttpClientException e)
Expand Down

0 comments on commit 34fb3c7

Please sign in to comment.