Skip to content

Commit

Permalink
Merge pull request #135 from mercadopago/release/1.10.1
Browse files Browse the repository at this point in the history
Fixed payment.additional_info.items[].unit_price deserialization
  • Loading branch information
delias-silva authored Mar 12, 2021
2 parents c0777c3 + 2ccae6e commit 31f3e43
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ name: CI
# events but only for the master branch
on:
push:
branches: [ develop, master ]
branches: [ master-dotnet-framework ]
pull_request:
branches: [ develop, master ]
branches: [ master-dotnet-framework ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ First time using Mercado Pago? Create your [Mercado Pago account](https://www.me

**Using Package Manager**

`PM> Install-Package mercadopago-sdk -Version 1.10.0`
`PM> Install-Package mercadopago-sdk -Version 1.10.1`

**Using .Net CLI**

`> dotnet add package mercadopago-sdk --version 1.10.0`
`> dotnet add package mercadopago-sdk --version 1.10.1`

**Using Packet CLI**

`> paket add mercadopago-sdk --version 1.10.0`
`> paket add mercadopago-sdk --version 1.10.1`

Copy the access_token in the [credentials](https://www.mercadopago.com/mlb/account/credentials) section of the page and replace YOUR_ACCESS_TOKEN with it.

Expand Down
33 changes: 33 additions & 0 deletions px-dotnet/Common/StringDecimalConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using Newtonsoft.Json;

namespace MercadoPago.Common
{
public class StringDecimalConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return objectType == typeof(string);
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
string value = (string)reader.Value;
if (string.IsNullOrEmpty(value))
{
return null;
}
return Convert.ToDecimal(float.Parse(value, CultureInfo.InvariantCulture));
}

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
decimal? decimalValue = (decimal?)value;
if (decimalValue.HasValue)
{
writer.WriteValue(decimalValue.Value.ToString(CultureInfo.InvariantCulture));
}
}
}
}
6 changes: 5 additions & 1 deletion px-dotnet/DataStructures/AdvancedPayment/Item.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace MercadoPago.DataStructures.AdvancedPayment
using MercadoPago.Common;
using Newtonsoft.Json;

namespace MercadoPago.DataStructures.AdvancedPayment
{
/// <summary>
/// Purchased item
Expand Down Expand Up @@ -38,6 +41,7 @@ public class Item
/// <summary>
/// Item unit price
/// </summary>
[JsonConverter(typeof(StringDecimalConverter))]
public decimal? UnitPrice { get; set; }
}
}
5 changes: 4 additions & 1 deletion px-dotnet/DataStructures/Payment/Item.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MercadoPago.Common;
using Newtonsoft.Json;

namespace MercadoPago.DataStructures.Payment
{
/// <summary>
Expand Down Expand Up @@ -66,6 +68,7 @@ public int? Quantity {
/// <summary>
/// Unit price
/// </summary>
[JsonConverter(typeof(StringDecimalConverter))]
public decimal? UnitPrice
{
get { return _unit_price; }
Expand Down
5 changes: 3 additions & 2 deletions px-dotnet/MercadoPagoSDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PackageId>mercadopago-sdk</PackageId>
<PackageVersion>1.10.0</PackageVersion>
<PackageVersion>1.10.1</PackageVersion>
<Authors>MercadoPago</Authors>
<Description>MercadoPago SDK para .Net</Description>
<Owners>MercadoPago</Owners>
Expand All @@ -25,7 +25,7 @@
<Title>Mercado Pago SDK</Title>
<NeutralLanguage>es</NeutralLanguage>
<PackageTags>mercadopago</PackageTags>
<ReleaseVersion>1.10.0</ReleaseVersion>
<ReleaseVersion>1.10.1</ReleaseVersion>
<SynchReleaseVersion>false</SynchReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -240,6 +240,7 @@
<Compile Include="DataStructures\Payment\BankInfo.cs" />
<Compile Include="DataStructures\Payment\BankInfoCollector.cs" />
<Compile Include="DataStructures\Payment\BankInfoPayer.cs" />
<Compile Include="Common\StringDecimalConverter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
4 changes: 2 additions & 2 deletions px-dotnet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.10.0")]
[assembly: AssemblyFileVersion("1.10.0")]
[assembly: AssemblyVersion("1.10.1")]
[assembly: AssemblyFileVersion("1.10.1")]

0 comments on commit 31f3e43

Please sign in to comment.