Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/Client/TrustlyApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ public WithdrawResponseData Withdraw(WithdrawRequestData request)
return this.SendRequest<WithdrawRequestData, WithdrawResponseData>(request, "Withdraw");
}

public VerifyAccountResponseData VerifyAccount(VerifyAccountRequestData request, string uuid = null)
{
return this.SendRequest<VerifyAccountRequestData, VerifyAccountResponseData>(request, "VerifyAccount", uuid);
}

public GetAccountTransactionsResponseData GetAccountTransactions(GetAccountTransactionsRequestData request, string uuid = null)
{
return this.SendRequest<GetAccountTransactionsRequestData, GetAccountTransactionsResponseData>(request, "GetAccountTransactions", uuid);
}

/// <summary>
/// Used internally to create a request package.
/// You usually do not need to directly call this method unless you are creating a custom
Expand Down
105 changes: 105 additions & 0 deletions src/Domain/Requests/GetAccountTransactions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
using System;
using Newtonsoft.Json;
using Trustly.Api.Domain.Base;

namespace Trustly.Api.Domain.Requests
{
public class GetAccountTransactionsRequestData : AbstractToTrustlyRequestParamsData<GetAccountTransactionsRequestAttributes>
{
/// <summary>
/// The Action static value GetConsentURL.
/// </summary>
public string Action = "GetConsentURL";

/// <summary>
/// The notification URL to send callbacks.
/// </summary>
public string NotificationURL { get; set; }

/// <summary>
/// The unique identifier for the end user.
/// </summary>
public string EndUserID { get; set; }

/// <summary>
/// The unique message identifier for the request.
/// </summary>
public string MessageID { get; set; }

/// <summary>
/// The ISO 3166-1-alpha-2 country code.
/// </summary>
public string Country { get; set; }

/// <summary>
/// The locale in the format "language_REGION" (e.g., "sv_SE").
/// </summary>
public string Locale { get; set; }

/// <summary>
/// The URL to redirect the user on success.
/// </summary>
public string SuccessURL { get; set; }

/// <summary>
/// The URL to redirect the user on failure.
/// </summary>
public string FailURL { get; set; }
}

public class GetAccountTransactionsResponseData : AbstractResponseResultData
{
/// <summary>
/// The OrderID specified when calling the method.
/// </summary>
[JsonProperty("orderid")]
public string OrderID { get; set; }

/// <summary>
/// The URL that should be loaded so that the end-user can complete the deposit.
/// </summary>
[JsonProperty("url")]
public string URL { get; set; }
}

/// <summary>
/// Represents the attributes associated with the request.
/// </summary>
public class GetAccountTransactionsRequestAttributes : AbstractRequestParamsDataAttributes
{
/// <summary>
/// The IP address of the end user.
/// </summary>
public string IP { get; set; }

/// <summary>
/// The mobile phone number of the end user.
/// </summary>
public string MobilePhone { get; set; }

/// <summary>
/// The first name of the end user.
/// </summary>
public string Firstname { get; set; }

/// <summary>
/// The last name of the end user.
/// </summary>
public string Lastname { get; set; }

/// <summary>
/// The email address of the end user.
/// </summary>
public string Email { get; set; }

/// <summary>
/// The national identification number of the end user.
/// </summary>
public string NationalIdentificationNumber { get; set; }

/// <summary>
/// Indicates whether the date of birth is "1979-01-31".
/// </summary>
public string DateOfBirth { get; set; }
}
}
100 changes: 100 additions & 0 deletions src/Domain/Requests/VerifyAccount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using Newtonsoft.Json;
using Trustly.Api.Domain.Base;

namespace Trustly.Api.Domain.Requests
{
public class VerifyAccountRequestData : AbstractToTrustlyRequestParamsData<VerifyAccountRequestAttributes>
{
/// <summary>
/// The notification URL to send callbacks.
/// </summary>
public string NotificationURL { get; set; }

/// <summary>
/// The unique identifier for the end user.
/// </summary>
public string EndUserID { get; set; }

/// <summary>
/// The unique message identifier for the request.
/// </summary>
public string MessageID { get; set; }
}

public class VerifyAccountResponseData : AbstractResponseResultData
{
/// <summary>
/// The OrderID specified when calling the method.
/// </summary>
[JsonProperty("orderid")]
public string OrderID { get; set; }

/// <summary>
/// The URL that should be loaded so that the end-user can complete the deposit.
/// </summary>
[JsonProperty("url")]
public string URL { get; set; }
}

/// <summary>
/// Represents the attributes associated with the request.
/// </summary>
public class VerifyAccountRequestAttributes : AbstractRequestParamsDataAttributes
{
/// <summary>
/// The ISO 3166-1-alpha-2 country code.
/// </summary>
public string Country { get; set; }

/// <summary>
/// The locale in the format "language_REGION" (e.g., "sv_SE").
/// </summary>
public string Locale { get; set; }

/// <summary>
/// The IP address of the end user.
/// </summary>
public string IP { get; set; }

/// <summary>
/// The mobile phone number of the end user.
/// </summary>
public string MobilePhone { get; set; }

/// <summary>
/// The first name of the end user.
/// </summary>
public string Firstname { get; set; }

/// <summary>
/// The last name of the end user.
/// </summary>
public string Lastname { get; set; }

/// <summary>
/// The email address of the end user.
/// </summary>
public string Email { get; set; }

/// <summary>
/// The national identification number of the end user.
/// </summary>
public string NationalIdentificationNumber { get; set; }

/// <summary>
/// Indicates whether the national identification number is unchangeable (1 = true, 0 = false).
/// </summary>
public int UnchangeableNationalIdentificationNumber { get; set; }

/// <summary>
/// The URL to redirect the user on success.
/// </summary>
public string SuccessURL { get; set; }

/// <summary>
/// The URL to redirect the user on failure.
/// </summary>
public string FailURL { get; set; }
}
}
70 changes: 70 additions & 0 deletions src/Website/Controllers/GetAccountTransactionsController.cs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
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 = "[email protected]",
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; }
}
}
70 changes: 70 additions & 0 deletions src/Website/Controllers/VerifyAccountController.cs
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
MessageID = Guid.NewGuid().ToString(),
Attributes = new Api.Domain.Requests.VerifyAccountRequestAttributes()
{
Locale = "en_GB",
Firstname = "John",
Lastname = "Smith",
Email = "[email protected]",
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; }
}
}