Skip to content

Commit

Permalink
Merge branch 'master' into feat/add-webpay-rest-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfredo Fiebig authored Oct 20, 2020
2 parents f803f34 + 98b3cfe commit f701a29
Show file tree
Hide file tree
Showing 29 changed files with 654 additions and 126 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,4 @@ coverage/
opencover.xml

.[Dd][Ss]_[Ss][Tt][Oo][Rr][Ee]
.leu
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Todos los cambios notables a este proyecto serán documentados en este archivo.
El formato está basado en [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
y este proyecto adhiere a [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.4.0] - 2019-12-26

### Added

- Se agrega soporte para Oneclick Mall y Transacción Completa en sus versiones REST.


## [2.3.0] - 2019-11-12

### Added

- Se agregan las clases necesarias para conectarse al Websocket de Onepay. Estas clases pueden ser utilizadas independientes, pero estan especialmente diseñadas para ser utilizadas por el SDK de POSIntegrado

- Se agregan templates para crear Issues en Github.

## [2.2.1] - 2019-05-20

### Fixed
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,25 @@ La documentación relevante para usar este SDK es:
- Primeros pasos con [Webpay](https://www.transbankdevelopers.cl/documentacion/webpay) y [Onepay](https://www.transbankdevelopers.cl/documentacion/onepay).
- Referencia detallada sobre [Webpay](https://www.transbankdevelopers.cl/referencia/webpay) y [Onepay](https://www.transbankdevelopers.cl/referencia/onepay).

## Solución de problemas

### CryptographicException: Invalid algorithm specified

Si al intentar ejecutar el código en el que integras, se lanza una excepción similar a la siguiente:
```
System.Security.Cryptography.CryptographicException
HResult=0x80090008
Message=Invalid algorithm specified.
Source=<Cannot evaluate the exception source>
StackTrace:<Cannot evaluate the exception stack trace>
```
puedes solucionarlo agregando a tu código, antes de llamar a initTransaction, las siguientes líneas:

```csharp
AppContext.SetSwitch("Switch.System.Security.Cryptography.Xml.UseInsecureHashAlgorithms", true);
AppContext.SetSwitch("Switch.System.Security.Cryptography.Pkcs.UseInsecureHashAlgorithms", true);
```

## Información para contribuir y desarrollar este SDK

### Windows
Expand Down Expand Up @@ -112,8 +131,8 @@ Para generar una nueva versión, se debe crear un PR (con un título "Prepare re

En ese PR deben incluirse los siguientes cambios:

1. Modificar el archivo CHANGELOG.md para incluir una nueva entrada (al comienzo) para `X.Y.Z` que explique en español los cambios **de cara al usuario del SDK**.
2. Modificar el archivo `Transbank/Transbank.csproj` para que <`VersionPrefix`> sea `X.Y.{Z+1}` (de manera que los pre-releases que se generen después del release sean de la siguiente versión).
1. Modificar el archivo `CHANGELOG.md` para incluir una nueva entrada (al comienzo) para `X.Y.Z` que explique en español los cambios **de cara al usuario del SDK**.
2. Modificar [Transbank.csproj](./Transbank/Transbank.csproj) para que <`VersionPrefix`> sea `X.Y.{Z+1}` (de manera que los pre-releases que se generen después del release sean de la siguiente versión).

Luego de obtener aprobación del pull request, debe mezclarse a master e inmediatamente generar un release en GitHub con el tag `vX.Y.Z`. En la descripción del release debes poner lo mismo que agregaste al changelog.

Expand Down
22 changes: 22 additions & 0 deletions Transbank/Onepay/Exceptions/HttpHelperException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;


namespace Transbank.Onepay.Exceptions
{
public class HttpHelperException : TransbankException
{
public HttpHelperException() : base()
{
}

public HttpHelperException(string message)
: base(-1, message)
{
}

public HttpHelperException(string message, Exception innerException)
: base(-1, message, innerException)
{
}
}
}
22 changes: 22 additions & 0 deletions Transbank/Onepay/Exceptions/Sigv4UtilException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;


namespace Transbank.Onepay.Exceptions
{
public class Sigv4UtilException : TransbankException
{
public Sigv4UtilException() : base()
{
}

public Sigv4UtilException(string message)
: base(-1, message)
{
}

public Sigv4UtilException(string message, Exception innerException)
: base(-1, message, innerException)
{
}
}
}
25 changes: 25 additions & 0 deletions Transbank/Onepay/IOnepayPayment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MQTTnet;
using MQTTnet.Client;


namespace Transbank.Onepay
{
public interface IOnepayPayment
{
int Ticket { get; }
int Total { get; }
string ExternalUniqueNumber { get; }
string Occ { get; }
string Ott { get; }

void Connected();
void NewMessage(string payload);
void Disconnected();
}

}
14 changes: 14 additions & 0 deletions Transbank/Onepay/Model/WebSocketMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Transbank.Onepay.Model
{
public class WebsocketMessage
{
public string status;
public string description;

public override string ToString()
{
return "Status: " + status + "\n" +
"Description: " + description;
}
}
}
20 changes: 20 additions & 0 deletions Transbank/Onepay/Model/WebsocketCredentials.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Transbank.Onepay.Model
{
public class WebsocketCredentials
{
public string iotEndpoint;
public string region;
public string accessKey;
public string secretKey;
public string sessionToken;

public override string ToString()
{
return "Endpoint: " + iotEndpoint + "\n" +
"Region: " + region + "\n" +
"Acces Key: " + accessKey + "\n" +
"SecretKey: " + secretKey + "\n" +
"SessionToken: " + sessionToken;
}
}
}
39 changes: 39 additions & 0 deletions Transbank/Onepay/Utils/HttpHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Class based in https://github.com/aws-samples/aws-iot-core-dotnet-app-mqtt-over-websockets-sigv4
// subsequently modified.

using System;
using System.Text;
using Transbank.Onepay.Exceptions;

namespace Transbank.Onepay.Utils
{
public static class HttpHelper
{
// The Set of accepted and valid Url characters per RFC3986. Characters outside of this set will be encoded.
const string ValidUrlCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";

public static string UrlEncode(string data, bool isPath = false)
{

var encoded = new StringBuilder(data.Length * 2);

try
{
string unreservedChars = String.Concat(ValidUrlCharacters, (isPath ? "/:" : ""));

foreach (char symbol in Encoding.UTF8.GetBytes(data))
{
if (unreservedChars.IndexOf(symbol) != -1)
encoded.Append(symbol);
else
encoded.Append("%").Append(String.Format("{0:X2}", (int)symbol));
}
}
catch (Exception e)
{
throw new HttpHelperException("Unable to encode URL", e);
}
return encoded.ToString();
}
}
}
5 changes: 4 additions & 1 deletion Transbank/Onepay/Utils/IRequestBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Class based in https://github.com/aws-samples/aws-iot-core-dotnet-app-mqtt-over-websockets-sigv4
// subsequently modified.

using System;
using System.Collections.Generic;
using System.Text;
using Transbank.Onepay.Enums;
Expand Down
5 changes: 4 additions & 1 deletion Transbank/Onepay/Utils/ISignUtil.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Transbank.Onepay.Model;
// Class based in https://github.com/aws-samples/aws-iot-core-dotnet-app-mqtt-over-websockets-sigv4
// subsequently modified.

using Transbank.Onepay.Model;

namespace Transbank.Onepay.Utils
{
Expand Down
Loading

0 comments on commit f701a29

Please sign in to comment.