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 Sep 12, 2019
1 parent 8ecc04e commit e40040e
Show file tree
Hide file tree
Showing 108 changed files with 8,780 additions and 7,777 deletions.
127 changes: 56 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
[![Build Status](https://travis-ci.org/wallee-payment/typescript-sdk.svg?branch=master)](https://travis-ci.org/wallee-payment/typescript-sdk)

# wallee
TypeScript SDK
# wallee TypeScript Library

The wallee TypeScript library wraps around the wallee API. This library facilitates your interaction with various services such as transactions, accounts, and subscriptions.


## Documentation

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

## Requirements

- npm 6+

## Installation

## Getting Started
Run the command below to install the wallee NPM package.
## NPM install (recommended)
```sh
npm i wallee
npm install wallee
```

Now you can use the typescript integration.
## Usage
The library needs to be configured with your account's space id, user id, and secret key which are available in your [wallee
account dashboard](https://app-wallee.com/account/select). Set `space_id`, `user_id`, and `api_secret` to their values.

### Configuring a Service

```typescript
'use strict';
import { Wallee } from 'wallee';

let macVersion: number = 1;
let spaceId: number = 405;
let userId: number = 512;
let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

let config = {
mac_version: macVersion,
space_id: spaceId,
user_id: userId,
api_secret: apiSecret
}

// Transaction Service
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);

```

### TypeScript integration
To get stated with sending transactions please review the example below:

```typescript
'use strict';
Expand All @@ -27,19 +59,19 @@ let userId: number = 512;
let apiSecret: string = 'FKrO76r5VwJtBrqZawBspljbBNOxp5veKQQkOnZxucQ=';

let config = {
mac_version: macVersion,
space_id: spaceId,
user_id: userId,
api_secret: apiSecret
mac_version: macVersion,
space_id: spaceId,
user_id: userId,
api_secret: apiSecret
}

// Get Transaction
// Transaction Service
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);

// Get PaymentMethod Service
let paymentMethodService: Wallee.api.PaymentMethodService = new Wallee.api.PaymentMethodService(config);
// TransactionPaymentPage Service
let transactionPaymentPageService: Wallee.api.TransactionPaymentPageService = new Wallee.api.TransactionPaymentPageService(config);

// default line item for tests
// LineItem of type PRODUCT
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name='Red T-Shirt';
lineItem.uniqueId='5412';
Expand All @@ -48,69 +80,22 @@ lineItem.quantity=1;
lineItem.amountIncludingTax=3.50;
lineItem.type=Wallee.model.LineItemType.PRODUCT;

// default transaction for tests
// Transaction
let transaction: Wallee.model.TransactionCreate = new Wallee.model.TransactionCreate();
transaction.lineItems=[lineItem];
transaction.autoConfirmationEnabled=true;
transaction.currency='EUR';

// Count the number of the transactions by id
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: Wallee.model.Transaction = response.body;
let entityQueryFilter: Wallee.model.EntityQueryFilter = new Wallee.model.EntityQueryFilter();
entityQueryFilter.fieldName = 'id';
entityQueryFilter.value = transactionCreate.id;
entityQueryFilter.type = Wallee.model.EntityQueryFilterType.LEAF;
entityQueryFilter.operator = Wallee.model.CriteriaOperator.EQUALS;
transactionService.transactionServiceCount(spaceId, entityQueryFilter).then(function (response) {
let transactionCount: number = response.body;
// expect transactionCount to equal 1
});
});


transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: Wallee.model.Transaction = response.body;
// expect transactionCreate.state to equal Wallee.model.TransactionState.PENDING
});

// Fetch an existing transaction by id
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
transactionService.create(spaceId, transaction).then(function (response) {
let transactionCreate: Wallee.model.Transaction = response.body;
transactionService.transactionServiceRead(spaceId, <number>transactionCreate.id).then(function (response) {
let transactionRead = response.body;
// expect transactionRead.state to equal Wallee.model.TransactionState.PENDING
});
});


// search for a transaction by id
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: Wallee.model.Transaction = response.body;
let entityQueryFilter: Wallee.model.EntityQueryFilter = new Wallee.model.EntityQueryFilter();
entityQueryFilter.fieldName = 'id';
entityQueryFilter.value = transactionCreate.id;
entityQueryFilter.type = Wallee.model.EntityQueryFilterType.LEAF;
entityQueryFilter.operator = Wallee.model.CriteriaOperator.EQUALS;
let entityQuery = new Wallee.model.EntityQuery();
entityQuery.filter = entityQueryFilter;
transactionService.transactionServiceSearch(spaceId, entityQuery).then(function (response) {
let transactionSearch = response.body;
transactionSearch.forEach(function (entry) {
// expect entry.state to equal Wallee.model.TransactionState.PENDING
});
});
});

// Edit transaction language
transactionService.transactionServiceCreate(spaceId, getTransaction()).then(function (response) {
let transactionCreate: Wallee.model.Transaction = response.body;
transactionCreate.language = 'en-US';
transactionService.transactionServiceUpdate(spaceId, <Wallee.model.TransactionPending> transactionCreate).then(function (response) {
let transactionUpdate: Wallee.model.Transaction = response.body;
// expect transactionUpdate.language to equal 'en-US'
transactionPaymentPageService.paymentPageUrl(spaceId, <number> transactionCreate.id).then(function (response) {
let pageUrl: string = response.body;
// window.location.href = pageUrl;
});
});

```

## License

Please see the [license file](https://github.com/wallee-payment/typescript-sdk/blob/master/LICENSE) for more information.
Loading

0 comments on commit e40040e

Please sign in to comment.