Skip to content

Commit c7e350a

Browse files
authored
Merge pull request #11 from dlmelendez/rel/2.0.1
#10 fix AccessToken createdDate bug, v2.0.1
2 parents b03bcd9 + 29076b0 commit c7e350a

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

PayPalCheckoutSdk/Core/AccessToken.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ namespace PayPalCheckoutSdk.Core
66
{
77
[DataContract]
88
public class AccessToken
9-
{
9+
{
10+
private DateTime _createDate;
11+
private int expiresIn;
12+
1013
[DataMember(Name = "access_token")]
1114
[JsonPropertyName("access_token")]
1215
public string? Token { get; set; }
@@ -17,10 +20,24 @@ public class AccessToken
1720

1821
[DataMember(Name = "expires_in")]
1922
[JsonPropertyName("expires_in")]
20-
public int ExpiresIn { get; set; }
21-
22-
private readonly DateTime _createDate;
23+
public int ExpiresIn
24+
{
25+
get => expiresIn;
26+
set
27+
{
28+
expiresIn = value;
29+
//Fixes a bug where an implicit cast does not set the _createdDate
30+
if (_createDate == DateTime.MinValue)
31+
{
32+
_createDate = DateTime.UtcNow;
33+
}
34+
}
35+
}
2336

37+
/// <summary>
38+
/// This constructor sometimes does not set the _createdDate
39+
/// because the HttpClient does an implicit cast for the result and does not create a new instance of this object
40+
/// </summary>
2441
public AccessToken()
2542
{
2643
_createDate = DateTime.UtcNow;

PayPalCheckoutSdk/PayPalCheckoutSdk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
55
<LangVersion>11.0</LangVersion>
6-
<Version>2.0.0</Version>
6+
<Version>2.0.1</Version>
77
<Nullable>enable</Nullable>
88
<Owners>David Melendez</Owners>
99
<RepositoryType>git</RepositoryType>

Samples/Samples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net6.0</TargetFramework>
6-
<PackageVersion>2.0.0</PackageVersion>
6+
<PackageVersion>2.0.1</PackageVersion>
77
</PropertyGroup>
88

99
<ItemGroup>

Test/Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
5-
<PackageVersion>2.0.0</PackageVersion>
5+
<PackageVersion>2.0.1</PackageVersion>
66
<IsPackable>false</IsPackable>
77
<UserSecretsId>4dbe0d9e-0d79-4e71-b5dd-44b90dbe3ee9</UserSecretsId>
88
</PropertyGroup>

0 commit comments

Comments
 (0)