diff --git a/src/Client/TrustlyApiClient.cs b/src/Client/TrustlyApiClient.cs index 8868fd9..1236050 100644 --- a/src/Client/TrustlyApiClient.cs +++ b/src/Client/TrustlyApiClient.cs @@ -157,6 +157,16 @@ public WithdrawResponseData Withdraw(WithdrawRequestData request) return this.SendRequest(request, "Withdraw"); } + public VerifyAccountResponseData VerifyAccount(VerifyAccountRequestData request, string uuid = null) + { + return this.SendRequest(request, "VerifyAccount", uuid); + } + + public GetAccountTransactionsResponseData GetAccountTransactions(GetAccountTransactionsRequestData request, string uuid = null) + { + return this.SendRequest(request, "GetAccountTransactions", uuid); + } + /// /// Used internally to create a request package. /// You usually do not need to directly call this method unless you are creating a custom diff --git a/src/Domain/Requests/GetAccountTransactions.cs b/src/Domain/Requests/GetAccountTransactions.cs new file mode 100644 index 0000000..3febe8b --- /dev/null +++ b/src/Domain/Requests/GetAccountTransactions.cs @@ -0,0 +1,105 @@ +using System; +using Newtonsoft.Json; +using Trustly.Api.Domain.Base; + +namespace Trustly.Api.Domain.Requests +{ + public class GetAccountTransactionsRequestData : AbstractToTrustlyRequestParamsData + { + /// + /// The Action static value GetConsentURL. + /// + public string Action = "GetConsentURL"; + + /// + /// The notification URL to send callbacks. + /// + public string NotificationURL { get; set; } + + /// + /// The unique identifier for the end user. + /// + public string EndUserID { get; set; } + + /// + /// The unique message identifier for the request. + /// + public string MessageID { get; set; } + + /// + /// The ISO 3166-1-alpha-2 country code. + /// + public string Country { get; set; } + + /// + /// The locale in the format "language_REGION" (e.g., "sv_SE"). + /// + public string Locale { get; set; } + + /// + /// The URL to redirect the user on success. + /// + public string SuccessURL { get; set; } + + /// + /// The URL to redirect the user on failure. + /// + public string FailURL { get; set; } + } + + public class GetAccountTransactionsResponseData : AbstractResponseResultData + { + /// + /// The OrderID specified when calling the method. + /// + [JsonProperty("orderid")] + public string OrderID { get; set; } + + /// + /// The URL that should be loaded so that the end-user can complete the deposit. + /// + [JsonProperty("url")] + public string URL { get; set; } + } + + /// + /// Represents the attributes associated with the request. + /// + public class GetAccountTransactionsRequestAttributes : AbstractRequestParamsDataAttributes + { + /// + /// The IP address of the end user. + /// + public string IP { get; set; } + + /// + /// The mobile phone number of the end user. + /// + public string MobilePhone { get; set; } + + /// + /// The first name of the end user. + /// + public string Firstname { get; set; } + + /// + /// The last name of the end user. + /// + public string Lastname { get; set; } + + /// + /// The email address of the end user. + /// + public string Email { get; set; } + + /// + /// The national identification number of the end user. + /// + public string NationalIdentificationNumber { get; set; } + + /// + /// Indicates whether the date of birth is "1979-01-31". + /// + public string DateOfBirth { get; set; } + } +} \ No newline at end of file diff --git a/src/Domain/Requests/VerifyAccount.cs b/src/Domain/Requests/VerifyAccount.cs new file mode 100644 index 0000000..149cc7d --- /dev/null +++ b/src/Domain/Requests/VerifyAccount.cs @@ -0,0 +1,100 @@ +using System; +using Newtonsoft.Json; +using Trustly.Api.Domain.Base; + +namespace Trustly.Api.Domain.Requests +{ + public class VerifyAccountRequestData : AbstractToTrustlyRequestParamsData + { + /// + /// The notification URL to send callbacks. + /// + public string NotificationURL { get; set; } + + /// + /// The unique identifier for the end user. + /// + public string EndUserID { get; set; } + + /// + /// The unique message identifier for the request. + /// + public string MessageID { get; set; } + } + + public class VerifyAccountResponseData : AbstractResponseResultData + { + /// + /// The OrderID specified when calling the method. + /// + [JsonProperty("orderid")] + public string OrderID { get; set; } + + /// + /// The URL that should be loaded so that the end-user can complete the deposit. + /// + [JsonProperty("url")] + public string URL { get; set; } + } + + /// + /// Represents the attributes associated with the request. + /// + public class VerifyAccountRequestAttributes : AbstractRequestParamsDataAttributes + { + /// + /// The ISO 3166-1-alpha-2 country code. + /// + public string Country { get; set; } + + /// + /// The locale in the format "language_REGION" (e.g., "sv_SE"). + /// + public string Locale { get; set; } + + /// + /// The IP address of the end user. + /// + public string IP { get; set; } + + /// + /// The mobile phone number of the end user. + /// + public string MobilePhone { get; set; } + + /// + /// The first name of the end user. + /// + public string Firstname { get; set; } + + /// + /// The last name of the end user. + /// + public string Lastname { get; set; } + + /// + /// The email address of the end user. + /// + public string Email { get; set; } + + /// + /// The national identification number of the end user. + /// + public string NationalIdentificationNumber { get; set; } + + /// + /// Indicates whether the national identification number is unchangeable (1 = true, 0 = false). + /// + public int UnchangeableNationalIdentificationNumber { get; set; } + + /// + /// The URL to redirect the user on success. + /// + public string SuccessURL { get; set; } + + /// + /// The URL to redirect the user on failure. + /// + public string FailURL { get; set; } + } +} \ No newline at end of file diff --git a/src/Website/Controllers/GetAccountTransactionsController.cs b/src/Website/Controllers/GetAccountTransactionsController.cs new file mode 100644 index 0000000..1d61709 --- /dev/null +++ b/src/Website/Controllers/GetAccountTransactionsController.cs @@ -0,0 +1,70 @@ +// The MIT License (MIT) +// +// Copyright (c) 2017 Trustly Group AB +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using Microsoft.AspNetCore.Mvc; +using System; + +namespace Trustly.Website.Controllers +{ + [Route("GetAccountTransactions")] + public class GetAccountTransactionsController : AbstractBaseController + { + [HttpGet] + public ActionResult Index() + { + var request = new Api.Domain.Requests.GetAccountTransactionsRequestData() + { + NotificationURL = "https://localhost:52714/api/Notification", + EndUserID = "user@email.com", + MessageID = Guid.NewGuid().ToString(), + Locale = "en_GB", + SuccessURL = "https://localhost:52714/Success", + Country = "DE", + FailURL = "https://localhost:52714/Failed", + Attributes = new Api.Domain.Requests.GetAccountTransactionsRequestAttributes() + { + Firstname = "John", + Lastname = "Smith", + Email = "user@email.com", + MobilePhone = "070-1234567", + NationalIdentificationNumber = "010101-1234", + IP = "123.123.123.123", + DateOfBirth = "1979-01-31" + } + }; + + var response = this.Client.GetAccountTransactions(request); + + return View(new GetAccountTransactionsViewModel() + { + OrderID = response.OrderID, + URL = response.URL + }); + } + } + + public class GetAccountTransactionsViewModel + { + public string URL { get; set; } + public string OrderID { get; set; } + } +} \ No newline at end of file diff --git a/src/Website/Controllers/VerifyAccountController.cs b/src/Website/Controllers/VerifyAccountController.cs new file mode 100644 index 0000000..2c7e0fd --- /dev/null +++ b/src/Website/Controllers/VerifyAccountController.cs @@ -0,0 +1,70 @@ +// The MIT License (MIT) +// +// Copyright (c) 2017 Trustly Group AB +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using Microsoft.AspNetCore.Mvc; +using System; + +namespace Trustly.Website.Controllers +{ + [Route("VerifyAccount")] + public class VerifyAccountController : AbstractBaseController + { + [HttpGet] + public ActionResult Index() + { + var request = new Api.Domain.Requests.VerifyAccountRequestData() + { + NotificationURL = "https://localhost:52714/api/Notification", + EndUserID = "user@email.com", + MessageID = Guid.NewGuid().ToString(), + Attributes = new Api.Domain.Requests.VerifyAccountRequestAttributes() + { + Locale = "en_GB", + Firstname = "John", + Lastname = "Smith", + Email = "user@email.com", + MobilePhone = "070-1234567", + NationalIdentificationNumber = "010101-1234", + SuccessURL = "https://localhost:52714/Success", + Country = "DE", + IP = "123.123.123.123", + UnchangeableNationalIdentificationNumber = 1, + FailURL = "https://localhost:52714/Failed" + } + }; + + var response = this.Client.VerifyAccount(request); + + return View(new VerifyAccountViewModel() + { + OrderID = response.OrderID, + URL = response.URL + }); + } + } + + public class VerifyAccountViewModel + { + public string URL { get; set; } + public string OrderID { get; set; } + } +} \ No newline at end of file