Skip to content

Commit

Permalink
Release 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Ndambakuwa committed Nov 11, 2019
1 parent 52406cc commit 0867d3c
Show file tree
Hide file tree
Showing 576 changed files with 74,324 additions and 98,589 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Ref: https://gist.github.com/kmorcinek/2710267
# Download this file using PowerShell v3 under Windows with the following comand
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore

# User-specific files
*.suo
*.user
*.sln.docstates
./nuget

# Build results

Expand Down Expand Up @@ -132,7 +137,7 @@ AppData/
Generated_Code/

# Backup & report files from converting an old project file to a newer
# Visual Studio version.
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sudo: false
mono:
- latest
dotnet: 2.1.101
solution: Customweb.Wallee.sln
solution: Wallee.sln
script:
- dotnet restore
- /bin/sh ./build.sh
Expand Down
27 changes: 0 additions & 27 deletions Customweb.Wallee.sln

This file was deleted.

7 changes: 3 additions & 4 deletions LICENSE.txt → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -179,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2019 customweb GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
212 changes: 149 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,175 @@
[![Build Status](https://travis-ci.org/wallee-payment/wallee-csharp-sdk.svg?branch=master)](https://travis-ci.org/wallee-payment/wallee-csharp-sdk) [![NuGet Status](https://buildstats.info/nuget/Customweb.Wallee)](https://www.nuget.org/packages/Customweb.Wallee/1.0.6)
[![Build Status](https://travis-ci.org/wallee-payment/csharp-sdk.svg?branch=master)](https://travis-ci.org/wallee-payment/csharp-sdk)

# wallee-csharp-sdk
The C# SDK allows an easy integration of wallee into C# and .NET applications.
# wallee C# Library

To Install from the Nuget Package Manager Console:
The wallee C# library wraps around the wallee API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.

PM> Install-Package Customweb.Wallee

## Documentation
https://app-wallee.com/doc/api/web-service

## Usage
[wallee Web Service API](https://app-wallee.com/doc/api/web-service)

### Example

<a name="frameworks-supported"></a>
## Frameworks supported
- .NET 4.5 or later
- Windows Phone 7.1 (Mango)

<a name="dependencies"></a>
## Dependencies
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 11.0.2
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.3.0

The DLLs included in the package may not be the latest version. We recommend using [NuGet](https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
```
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
```

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742)

<a name="installation"></a>
## Installation
Run the following command to generate the DLL
- [Mac/Linux] `/bin/sh build.sh`
- [Windows] `build.bat`

Then include the DLL (under the `bin` folder) in the C# project, and use the namespaces:
```csharp
using System;
using Wallee.Service;
using Wallee.Client;
using Wallee.Model;
```
<a name="packaging"></a>
## Packaging

A `.nuspec` is included with the project. You can follow the Nuget quickstart to [create](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#create-the-package) and [publish](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package#publish-the-package) packages.

This `.nuspec` uses placeholders from the `.csproj`, so build the `.csproj` directly:

```
nuget pack -Build -OutputDirectory out Wallee.csproj
```

Then, publish to a [local feed](https://docs.microsoft.com/en-us/nuget/hosting-packages/local-feeds) or [other host](https://docs.microsoft.com/en-us/nuget/hosting-packages/overview) and consume the new package via Nuget as usual.

using Customweb.Wallee.Model;
using Customweb.Wallee.Client;
using Customweb.Wallee.Service;
<a name="getting-started"></a>
## Getting Started

```csharp
using System;
using System.Configuration;
using System.Collections.Generic;

namespace WalleeExample
using NUnit.Framework;

using Wallee.Model;
using Wallee.Service;
using Wallee.Client;

namespace Wallee.Test
{
internal class Program
/// <summary>
/// Class for testing TransactionService.
/// </summary>
[TestFixture]
public class TransactionPaymentPageServiceTest
{
public static void Main(string[] args)
private TransactionService transactionService;
private TransactionCreate transactionCreate;
private Configuration configuration;
private long spaceId;
private string applicationUserID;
private string authenticationKey;
private ApiResponse<Transaction> transaction;

/// <summary>
/// Setup before each unit test.
/// </summary>
[SetUp]
public void SetUpTest()
{
// Configuration.
const long spaceId = 405;
const string userId = "512";
const string secret = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";

Configuration configuration = Configuration.Builder()
.ApplicationUserID(userId)
.AuthenticationKey(secret)
.Build();

// Create API service instances.
var tokenService = new TokenService(configuration);
var transactionService = new TransactionService(configuration);

// Optionally create token for recurring payments.
var tokenCreate = new TokenCreate(ExternalId: Guid.NewGuid().ToString())
{
CustomerEmailAddress = "[email protected]",
TokenReference = "[email protected]",
CustomerId = new Random().Next().ToString(),
EnabledForOneClickPayment = true
};

var token = tokenService.Create(spaceId, tokenCreate);

// Create transaction.
var lineItem = new LineItemCreate
(
Name: "Red T-Shirt",
Sku: "red-t-shirt-1",
UniqueId: "2130",
Quantity: 1,
Type: LineItemType.PRODUCT,
AmountIncludingTax: 22.91m
);
this.spaceId = 405;
this.authenticationKey = "FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=";
this.applicationUserID = "512";
this.configuration = new Configuration(this.applicationUserID, this.authenticationKey);
this.transactionService = new TransactionService(configuration);
this.CreateTransaction();
}

var transactionCreate = new TransactionCreate
private void CreateTransaction() {

AddressCreate billingAddress = new AddressCreate();
billingAddress.Salutation = "Ms";
billingAddress.GivenName = "Good";
billingAddress.FamilyName = "Customer";
billingAddress.Gender = Gender.FEMALE;
billingAddress.Country = "CH";
billingAddress.City = "Winterthur";
billingAddress.PostCode = "8400";
billingAddress.DateOfBirth = new DateTime(1988, 4, 19);
billingAddress.OrganizationName = "Test GmbH";
billingAddress.MobilePhoneNumber = "+41791234567";
billingAddress.EmailAddress = "[email protected]";

LineItemCreate lineItem1 = new LineItemCreate(
name: "Item 1",
uniqueId: "unique-id-item-1",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal) 67.47
);
lineItem1.Sku = "item-1";
lineItem1.ShippingRequired = true;

this.transactionCreate = new TransactionCreate(new List<LineItemCreate>() { lineItem1 });
this.transactionCreate.BillingAddress = billingAddress;
this.transactionCreate.ShippingAddress = billingAddress;
this.transactionCreate.CustomerEmailAddress = billingAddress.EmailAddress;
this.transactionCreate.CustomerId = "cutomer-x";
this.transactionCreate.MerchantReference = Guid.NewGuid().ToString();
this.transactionCreate.InvoiceMerchantReference = "order-1";
this.transactionCreate.SuccessUrl = "http://localhost/success?orderId=1";
this.transactionCreate.FailedUrl = "http://localhost/failed?orderId=1";
this.transactionCreate.ShippingMethod = "Test Shipping";
this.transactionCreate.ChargeRetryEnabled = false;
this.transactionCreate.AllowedPaymentMethodConfigurations = new List<long?>() { 8656L };
this.transactionCreate.Language = "en-US";
this.transactionCreate.Currency = "CHF";

try
{
Currency = "EUR",
LineItems = new List<LineItemCreate>() { lineItem },
AutoConfirmationEnabled = true,
Token = token.Id
};

// Send create transaction request.
var transaction = transactionService.Create(spaceId, transactionCreate);
this.transaction = this.transactionService.CreateWithHttpInfo(
this.spaceId,
this.transactionCreate
);
} catch (ApiException e){
Assert.Fail("Failed to create transaction. Reason: " + e.Message + " Details: " + e.ErrorContent);
}

// Create payment page URL.
var redirectionUrl = transactionService.BuildPaymentPageUrl(spaceId, transaction.Id);
System.Console.WriteLine("Payment URL: " + redirectionUrl);
}

/// <summary>
/// Test transaction creation.
/// </summary>
[Test]
public void TestPaymentPageUrl() {
TransactionPaymentPageService transactionPaymentPageService = new TransactionPaymentPageService(this.configuration);
String paymentPageUrl = null;
try {
paymentPageUrl = transactionPaymentPageService.PaymentPageUrl(this.spaceId, this.transaction.Data.Id);
} catch (ApiException e) {
Console.WriteLine(e.ToString());
}
Console.WriteLine(paymentPageUrl);
Assert.IsTrue(paymentPageUrl.Contains("http"));
}
}
}
```

## License

Please see the [license file](https://github.com/wallee-payment/wallee-csharp-sdk/blob/master/LICENSE.txt) for more information.
Please see the [license file](https://github.com/wallee-payment/csharp-sdk/blob/master/LICENSE) for more information.
27 changes: 27 additions & 0 deletions Wallee.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wallee", "src\Wallee\Wallee.csproj", "{74CECBFB-1BB1-4300-98EA-C037485D399B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wallee.Test", "src\Wallee.Test\Wallee.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74CECBFB-1BB1-4300-98EA-C037485D399B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74CECBFB-1BB1-4300-98EA-C037485D399B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74CECBFB-1BB1-4300-98EA-C037485D399B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74CECBFB-1BB1-4300-98EA-C037485D399B}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
echo "[INFO] Restoring NuGet packages."
msbuild /t:restore

echo "[INFO] Building Customweb.Wallee.csproj."
msbuild src/Customweb.Wallee/Customweb.Wallee.csproj /t:pack /p:Configuration=Release /p:Platform="Any CPU" /p:GenerateDocumentation=true /p:DocumentationFile=Customweb.Wallee.xml
echo "[INFO] Building Wallee.csproj."
msbuild src/Wallee/Wallee.csproj /t:pack /p:Configuration=Release /p:Platform="Any CPU" /p:GenerateDocumentation=true /p:DocumentationFile=Wallee.xml

if [ $? -ne 0 ]
then
echo "[ERROR] Compilation failed with exit code $?."
exit 1
echo "[ERROR] Compilation failed with exit code $?."
exit 1
else
echo "[INFO] Compilation was successfully."
echo "[INFO] Compilation was successfully."
fi


echo "[INFO] Copying created NuGet package."
cp "src/Customweb.Wallee/bin/Any CPU/Release/Customweb.Wallee.1.0.6.nupkg" ./Customweb.Wallee.1.0.6.nupkg;
cp "src/Wallee/bin/Any CPU/Release/Wallee.2.0.0.nupkg" ./Wallee.2.0.0.nupkg;
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ wget -nc https://dist.nuget.org/win-x86-commandline/v4.5.1/nuget.exe;
mozroots --import --sync

echo "[INFO] Publishing NuGet package."
mono nuget.exe push Customweb.Wallee.1.0.6.nupkg -ApiKey $NUGET_API_KEY -Verbosity detailed -Source nuget.org
mono nuget.exe push Wallee.2.0.0.nupkg -ApiKey $NUGET_API_KEY -Verbosity detailed -Source nuget.org
Loading

0 comments on commit 0867d3c

Please sign in to comment.