-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/add-webpay-rest-support
- Loading branch information
Showing
29 changed files
with
654 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,3 +337,4 @@ coverage/ | |
opencover.xml | ||
|
||
.[Dd][Ss]_[Ss][Tt][Oo][Rr][Ee] | ||
.leu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.