{
'filter': {
'fieldName': 'primaryAccount.name',
'operator': 'EQUALS',
'type': 'LEAF',
'value': 'test'
}
}
This document explains common aspects of all the REST services
. Use the index on the right side
to quickly navigate through the chapters. An overview over and introduction to the Rest services
can be found in the general documentation.
The REST service is based up on the following basic types. They are considered as primitives.
Long |
A long is a number consisting only of digits. It is has a size of 64 bit. |
Integer |
An integer is a number consisting only of digits. It is has a size of 32 bit. |
String |
A string consists of digits or chars. The size is not limited by definition. However the parameters and properties may specify explicitly a size. |
Boolean |
A boolean holds either |
Decimal |
A decimal is floating point number. We typically have 19 digits and 8 decimal places. |
Date |
A date defines a specific day. We represent dates as strings since |
DateTime |
A date defines a specific point in time. We represent dates as strings since |
Duration |
A duration defines a time span between to time points (e.g. one month). A duration is represented as a String in the duration format of ISO 8601 (e.g. P1M). |
Complex Object |
A complex object consists of a set of properties. Each property can have again a primitive type, a complex object or a collection. |
Collection |
A collection is a list of either primitives or a list of complex objects. A collection consists always of the same type. We do not mix types within a collection. |
Binary |
A binary contains data in a arbitrary format. The corresponding format is indicated along the type (e.g. text/csv) |
The API returns objects and allows to update those objects. This may lead to race conditions when the same object is
modified by multiple users or processes at the same time. Each potentially affected object contains a property version
. This version
is incremented whenever a change on it is applied. Before an update is applied on the object the version is verified
to be still the same. If this check fails the update fails. This version number is also updated when a change is applied through
the user interface. As a consequence to update a particular object the version
property has to be passed. This concept is also
known as optimistic locking.
The failure of an update should be handled depending on the context. Generally there are two options:
If a user was the trigger for the update let the user apply the update again. The latest version should be fetched and presented to the user to update the object again.
If an automated process is the trigger of the update the update should be wrapped within a loop which retries on a failure to update the object multiple times.
When a request leads to a conflict we return a 409
HTTP status.
For most entities there is a search operation. The search allows to fetch only particular entities. Means the returned entities are filtered by a query. The query is structured similar to a SQL query. Essentially there is a part which limits the result and there is a paging mechanism. The model definition Entity Query defines the whole query.
The filter object allows to formulate the restrictions. The expression is similar to the WHERE
part in an SQL statement. It is a recursive data
structure which allows to define AND
and OR
groups. Each group can have multiple restrictions on properties. The fieldName
can reference a
property or it can be a path to a property. As an example to get all application users which are linked with the account test
the following query
can be used:
{
'filter': {
'fieldName': 'primaryAccount.name',
'operator': 'EQUALS',
'type': 'LEAF',
'value': 'test'
}
}
Beside the restriction given through the filter
the query can also order the results by a fieldName
. As the fieldName
of the filter
the
fieldName
of the orderBys
can use the dot notation to order by a foreign property.
The paging can be realized by indicating the startingEntity
and the numberOfEntities
. The startingEntity
indicates the entity with which
the result should start. The numberOfEntities
controls how many results should be returned. The get the total count for a particular
filter
the count
operation can be used.
There are some limitation regarding the fields which can be used to filter results. Not all fields can be used for filtering and sorting. The fields
which are marked as virtual cannot be used for filtering and ordering. Additionally if the relationship between entities are implemented with a
reference consisting of a long
the relationship cannot be used for ordering and filtering.
Some properties may be language aware. As such the filtering and ordering will impact the result. As such it is recommended to provide a language to
make sure that the right results are returned. If no language is provided either the default language (en-US
) is used or the language we may detect
within the HTTP request.
The description of the API in this document is intended to be used when the API is integrated without using a software development kit (SDK) and it is intended to be used as a reference to understand each single service.
To simplify the integration we provide the API definition also in a machine readable format. The service description is written in Swagger
. It can
be found under Swagger. The Swagger documentation may provide more details about how to use the provided JSON
file.
Swagger
uses tags
to group operations together and each operation is uniquely identified by an operationId
. The Swagger
specification
is not strict enough to generate meaningful client code. As such we introduce the following conventions:
Each operation will be tagged exactly with one tag. This tag correspond to the service name. It is always in camel case.
Each operationId
starts with the operation tag followed by a underscore (_
) and an operation name. This operation name
is unique per service. Means each tag will contain exactly one such operation name and not more. This operation name is also in camel case.
We recommend to create a class per service (tag) and each such service class can hold all operations of this particular tag. The operation name
can be used as the method name of the operation within the class. Client languages which are not object oriented may use the whole operationId
as
the identifier. We ensure that the operationId
is stable over time.
We provide software development kits (SDK) for several programming languages. Those SDK reduce your effort to integrate our services. All available SDKs including documentation can be accessed via our Github Repository.
There are objects which contain meta data. Meta data properties allow to store arbitrary data along the object. The data provided is not changed or touched by our system. However it can be accessed as any other property of the object. The data can be accessed over the web service API, but also within templates etc. The meta data property is a key / value store.
There are some limits what can be stored and how it can be stored:
Per object no more than 25
key / value pairs can be provided.
A key cannot be longer as 40
chars.
A value cannot be longer as 512
chars.
The key can only contain alphabetic chars, numeric chars and underscores. The key cannot starts with
an underscore or a number. The regex against we validate the key is: [a-zA-Z]{1}[a-zA-Z0-9_]{0,39}
The value can contain any printable UTF-8 char including line breaks. However stop chars etc. are not permitted. The value can also contain HTML tags.
In order to use the REST services
you will have to properly authenticate in the web service API.
In order to authenticate a request we use a MAC authentication algorithm. How this authentication
algorithm has to be implemented - in case you do not use our libraries - is described in details here.
The MAC authentication requires four custom HTTP headers
to be sent with each request:
x-mac-version
: To indicate the algorithm version. For the current this will always be the single digit 1.
x-mac-userid
: The user ID (an unsigned integer) formatted as a decimal number.
x-mac-timestamp
: The time formated as unix timestamp.
x-mac-value
: The actual MAC value (a 64 byte value calculated as explained below) encoded in Base64 (with padding, using
the standard alphabet) as defined in section 4 of RFC 4648.
Note
|
Splitting the Base64 string into whitespace separated chunks is accepted but not recommended.
|
Below you will find an example for the generation of a MAC value with example inputs including examples in some programming languages as guidelines.
To get the x-mac-userid
you will first have to create an application user in your account. In order
to do this navigate to Account > Users > Application Users and create your application user.
Once an application user is created you will see its ID in the corresponding column of the application user list. This
value should be used for the x-mac-userid
. In the image below it would be the userid 4
.
Important
|
When you create a new user you will be displayed an application_user_key . This key represents the
32 byte authentication key encoded with Base-64.
You should write that key down as it is used to sign the requests.
For security reasons, the key will not be shown again! In case you loose the key, you will not be able to
continue using that key. However you can create at any time a new key and deactivate the old one. The number
of active keys a user can have is limited.
|
The x-mac-timestamp
is an unsigned integer (formatted as a decimal number)
representing the number of seconds since midnight 1970‑01‑01. (See also
UNIX Time Stamp in Wikipedia.)
The time in the request is needed to prevent relay attacks. In order to use the API you have to make sure that your server has set an accurate system time. We do currently allow a maximum of 600 seconds difference between our server time and your calculated time stamp.
The following example code demonstrates how to generated a time stamp using PHP:
<?php
// Assigns the current timestamp to the timestamp variable:
$timestamp = time();
?>
After you collected all the data you have to calculate the x-mac-value
using the following input:
Algorithm Version: The same fixed string as defined above in x-mac-version
header.
User ID: The user ID as used for the x-mac-userid
header.
Time stamp: The same string representing the current time as used for the x-mac-timestamp
header.
Method: The name of the HTTP method used for the request (as a string). This is normally one of the
HTTP standard methods GET
, HEAD
, POST
, PUT
, DELETE
, TRACE
, CONNECT
.
Note: These values are case-sensitive; the standard methods are always uppercase.
Path: The path component of the requested URL, including any query string (example see below).
To calculate the MAC, the strings from these items are concatenated into a single string (the authentication
message
) using the vertical bar |
; (U+007C) as a separator.
This string is then encoded to a sequence of bytes using the UTF-8 encoding (without any byte order mark) according to RFC 3629. These bytes form the message which will be authenticated by the MAC which we generate.
Apart from the message bytes, the HMAC-SHA512 algorithm requires a secret key.
In our case this is a sequence of exactly 32 bytes which you received in Base-64 encoding as
the application_user_key
when you created your application user (see above for more details).
With this key you apply the HMAC-SHA512 algorithm to the message bytes and will receive
a 64 byte MAC value as the result. This MAC value, again encoded in Base-64 code, will then be the value of x-mac-value
header.
For a better understanding you will find an abstract illustration of the MAC calculation below in various programming languages.
In order to illustrate the above we created an example calculation with the following input values to generate an payment page displayed in an iframe. We will guide you through the implementation first a low level implementation. However, you find further down some concrete implementation in various programming languages based on the example values below.
x-mac-version
header: 1
x-mac-userid
header: 2481632
x-mac-timestamp
header: 1425387916
Method: GET
Path: /api/transaction/read?spaceId=12&id=1
Authentication-Key: OWOMg2gnaSx1nukAM6SN2vxedfY1yLPONvcTKbhDv7I=
Concatenating items 1. through 5. with |
as the separator we get the following string:
1|2481632|1425387916|GET|/api/transaction/read?spaceId=12&id=1
Which, encoded with UTF-8, results in our Authentication Message (shown as a sequence of 95 bytes in hex):
0x31, 0x7c, 0x32, 0x34, 0x38, 0x31, 0x36, 0x33, 0x32, 0x7c, 0x31, 0x34, 0x32, 0x35, 0x33, 0x38,
0x37, 0x39, 0x31, 0x36, 0x7c, 0x47, 0x45, 0x54, 0x7c, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x72,
0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x72, 0x65, 0x61, 0x64, 0x3f, 0x73,
0x70, 0x61, 0x63, 0x65, 0x49, 0x64, 0x3d, 0x31, 0x32, 0x26, 0x69, 0x64, 0x3d, 0x31
Decoding the Authentication-Key into a sequence of 32 bytes gives:
0x39, 0x63, 0x8c, 0x83, 0x68, 0x27, 0x69, 0x2c, 0x75, 0x9e, 0xe9, 0x00, 0x33, 0xa4, 0x8d, 0xda,
0xfc, 0x5e, 0x75, 0xf6, 0x35, 0xc8, 0xb3, 0xce, 0x36, 0xf7, 0x13, 0x29, 0xb8, 0x43, 0xbf, 0xb2
Now we apply the HMAC-SHA512 function with the Authentication-Key as the key and the Authentication Message as the message and get the following 64 bytes sequence as the resulting MAC value:
0xb7, 0x3e, 0xd1, 0xa9, 0x10, 0x47, 0xf0, 0x61, 0x30, 0xdb, 0xdb, 0x63, 0xdb, 0xfc, 0x7b, 0xea,
0x8a, 0x4a, 0x9a, 0x56, 0xed, 0x86, 0x40, 0x85, 0x24, 0xba, 0xa2, 0xc2, 0x42, 0x88, 0x51, 0x90,
0x4a, 0x88, 0xcd, 0x47, 0x68, 0x77, 0xa2, 0xb0, 0x2f, 0xc8, 0x43, 0x36, 0x84, 0x80, 0x20, 0xcc,
0x83, 0x40, 0x88, 0xd2, 0x4b, 0xc9, 0x74, 0xf0, 0x26, 0x6d, 0x2d, 0x75, 0xa3, 0x1c, 0xf3, 0xe1,
The above sequence encoded in Base-64 finally gives the string which should be used as the value
of the x-mac-value
header:
tz7RqRBH8GEw29tj2/x76opKmlbthgSFJLqiwkKIUQlKiM1HaHeisC/IQzaEgALMgwSI0kvJdPAmbS11oxzz4Q==
To create an authentication in PHP use the example below as an illustration on how to create the x-mac-value
.
<?php
$decodedSecret = base64_decode("OWOMg2gnaSx1nukAM6SN2vxedfY1yLPONvcTKbhDv7I=");
echo base64_encode(hash_hmac("sha512", "1|2481632|1425387916|GET|/api/transaction/read?spaceId=12&id=1", $decodedSecret, true));
?>
To create an authentication in Java use the example below as an illustration on how to create the x-mac-value
.
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public class Test {
public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeyException {
String securedData =
"1|2481632|1425387916|GET|/api/transaction/read?spaceId=12&id=1";
String secret = "OWOMg2gnaSx1nukAM6SN2vxedfY1yLPONvcTKbhDv7I=";
byte[] decodedSecret = Base64.getDecoder().decode(secret);
Mac mac = Mac.getInstance("HmacSHA512");
mac.init(new SecretKeySpec(decodedSecret, "HmacSHA512"));
byte[] bytes = mac.doFinal(securedData.getBytes(StandardCharsets.UTF_8));
System.out.println(new String(Base64.getEncoder().encode(bytes), StandardCharsets.UTF_8));
}
}
To create an authentication in Python use the example below as an illustration on how to create the x-mac-value
.
import hashlib
import hmac
import base64
def sign(secret, userId, method, path, timestamp):
data = "1|" + str(userId) + "|"+str(timestamp)+"|" + method + "|" + path
return hmac.new(base64.b64decode(secret), data, hashlib.sha512).digest().encode("base64").replace('\n', '')
print sign("OWOMg2gnaSx1nukAM6SN2vxedfY1yLPONvcTKbhDv7I=", "2481632", "GET", "/api/transaction/read?spaceId=12&id=1", 1425387916)
The following diagram illustrates the calculation of the complete algorithm described above:
In some cases it helps when you can attach to each request an ID to trace the request through different systems. By adding
the HTTP header x-wallee-logtoken
you can send a request token which is added to our logs and we can trace it when you
get in contact with us. The log token should contain a unique ID per request.
In this section all services are described. Each service is responsible for handling one particular entity.
A service consists of different operations. Each operation may accept a set of query parameter
and
depending on the request method a body message
. The query parameter need to be append to the request
URL according to the RFC 3986. The body message has to be sent within the body of the HTTP request.
Below there is a complete HTTP request for a notional service SomeService
.
POST /api/SomeService/operationName?queryParameter1=valueOfQueryParameter1&queryParameter2=value2 HTTP/1.0
x-mac-version: 1
x-mac-userid: 12313
x-mac-timestamp: 1471016771
x-mac-value: (hash-calculated as described in the previous section)
{"some-property": "some-value", "other-value": 123}
The service will return a response. Depending on the response code the body may contain some JSON
object. Each
service states what kind of responses can be expected.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Deletes the entity with the given id.
Searches for the entities as specified by the given query.
Creates the entity with the given properties.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Deletes the entity with the given id.
The web app service allows to manage the installation of web apps.
This operation returns true when the app is installed in given space. The web app is implied by the client ID resp. user ID that is been used to invoke this operation.
This operation uninstalls the web app from the provided space. The web app is implied by the client ID resp. user ID that is been used to invoke this operation.
This operation confirms the app installation. This method has to be invoked after the user returns to the web app. The request of the user will contain the code as a request parameter. The web app is implied by the client ID resp. user ID that is been used to invoke this operation.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Deletes the entity with the given id.
Creates the entity with the given properties.
Deletes the entity with the given id.
Creates the entity with the given properties.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Returns all documents that are attached to a debt collection case.
Counts the number of items in the database as restricted by the given filter.
This operation will mark a debt collection case as prepared and allow the collection process to proceed.
This operation will mark a debt collection case as reviewed and allow the collection process to proceed.
Closes the debt collection case, meaning no further money can be collected.
Attach an additional supporting document to the case.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Deletes the entity with the given id.
Adds a new collected amount to the case, creating a new payment receipt.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
This operation returns all countries.
This operation returns all states for a given country.
This operation returns all states of all countries.
This operation returns all currencies.
This operation returns all languages.
GET /api/language/all HTTP/1.1
Host: hub.emetec.net
Content-Type: application/json;charset=utf-8
X-Mac-Version: 1
X-Mac-Userid: <:YOUR_USER_ID>
X-Mac-Timestamp: <:UNIX_TIMESTAMP>
X-Mac-Value: <:CALCULATED_MAC_VALUE>
$client = new \Wallee\Sdk\ApiClient(<:YOUR_USER_ID>, <:YOUR_API_KEY>);
$service = new \Wallee\Sdk\Service\LanguageService($client);
$result = $service->languageAllGet();
Reads the entity with the given 'id' and returns it.
This operation returns all legal organization forms for a given country.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Sends the payment link of the charge flow level with the given 'id'.
This operation cancels the charge flow that is linked with the transaction indicated by the given ID.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
This operation allows to fetch the payment page URL that is been applied on the charge flow linked with the provided transaction. The operation might return an empty result when no payment page is needed or can be invoked.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
This operation marks the delivery indication as suitable.
This operation marks the delivery indication as not suitable.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
The payment link service allows to manage payment links via the web service API.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
Pins the comment to the top.
Deletes the comment with the given id.
Creates the comment with the given properties.
Returns all comments of the given refund.
Reads the comment with the given 'id' and returns it.
This updates the comment with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the comment.
Unpins the comment from the top.
Reads the entity with the given 'id' and returns it.
This operation allows to mark a refund as failed which is in state MANUAL_CHECK.
Returns the PDF document for the refund with given id.
Returns the PDF document for the refund with given id and the given target media type.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
This operation creates and executes a refund of a particular transaction.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\AddressCreate;
use Wallee\Sdk\Model\LineItemCreate;
use Wallee\Sdk\Model\LineItemType;
use Wallee\Sdk\Model\RefundCreate;
use Wallee\Sdk\Model\RefundState;
use Wallee\Sdk\Model\RefundType;
use Wallee\Sdk\Model\TransactionCreate;
use Wallee\Sdk\Model\TransactionState;
use Wallee\Sdk\Service\RefundService;
use Wallee\Sdk\Service\TransactionService;
// credentials
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
// Services
$apiClient = new ApiClient($userId, $secret);
$transactionService = new TransactionService($apiClient);
$refundService = new RefundService($apiClient);
// line item
$lineItem = new LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(LineItemType::PRODUCT);
// Customer Billing Address
$billingAddress = new AddressCreate();
$billingAddress->setCity('Winterthur');
$billingAddress->setCountry('CH');
$billingAddress->setEmailAddress('[email protected]');
$billingAddress->setFamilyName('Customer');
$billingAddress->setGivenName('Good');
$billingAddress->setPostCode('8400');
$billingAddress->setPostalState('ZH');
$billingAddress->setOrganizationName('Test GmbH');
$billingAddress->setPhoneNumber('+41791234567');
$billingAddress->setSalutation('Ms');
// Transaction payload
$transactionPayload = new TransactionCreate();
$transactionPayload->setCurrency('CHF');
$transactionPayload->setLineItems([$lineItem]);
$transactionPayload->setAutoConfirmationEnabled(true);
$transactionPayload->setBillingAddress($billingAddress);
$transactionPayload->setShippingAddress($billingAddress);
$transactionPayload->setFailedUrl('https://YOUR.SITE/transaction?state=fail');
$transactionPayload->setSuccessUrl('https://YOUR.SITE/transaction?state=success');
// Create a transaction
$transaction = $transactionService->create($spaceId, $transactionPayload);
$transaction = $transactionService->processWithoutUserInteraction($spaceId, $transaction->getId());
// Fetch the transaction you would like to refund
$transaction = $this->transactionService->read($this->spaceId, $transaction->getId());
if (in_array($transaction->getState(), [TransactionState::FULFILL])) {
// Refund payload
$refundPayload = new RefundCreate();
$refundPayload->setAmount($transaction->getAuthorizationAmount());
$refundPayload->setTransaction($transaction->getId());
$refundPayload->setMerchantReference($transaction->getMerchantReference());
$refundPayload->setExternalId($transaction->getId());
$refundPayload->setType(RefundType::MERCHANT_INITIATED_ONLINE);
$refund = $refundService->refund($this->spaceId, $refundPayload);
if(in_array($refund->getState(), [RefundState::SUCCESSFUL])){
// refund successful
}
}
package com.wallee.sdk.test;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.*;
import com.wallee.sdk.service.*;
import java.math.BigDecimal;
/**
* API tests for RefundService
*/
public class RefundServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private RefundService refundService;
private TransactionCompletionService transactionCompletionService;
private TransactionService transactionService;
// Models
private TransactionCreate transactionPayload;
public RefundServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.refundService = new RefundService(this.apiClient);
this.transactionCompletionService = new TransactionCompletionService(this.apiClient);
this.transactionService = new TransactionService(this.apiClient);
}
/**
* Get transaction payload
*
* @return TransactionCreate
*/
private TransactionCreate getTransactionPayload() {
if (this.transactionPayload == null) {
// Line item
LineItemCreate lineItem = new LineItemCreate();
lineItem.name("Red T-Shirt")
.uniqueId("5412")
.type(LineItemType.PRODUCT)
.quantity(BigDecimal.valueOf(1))
.amountIncludingTax(BigDecimal.valueOf(29.95))
.sku("red-t-shirt-123");
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate();
billingAddress.city("Winterthur")
.country("CH")
.emailAddress("[email protected]")
.familyName("Customer")
.givenName("Good")
.postcode("8400")
.postalState("ZH")
.organizationName("Test GmbH")
.mobilePhoneNumber("+41791234567")
.salutation("Ms");
this.transactionPayload = new TransactionCreate();
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
this.transactionPayload.setBillingAddress(billingAddress);
this.transactionPayload.setShippingAddress(billingAddress);
this.transactionPayload.addLineItemsItem(lineItem);
}
return this.transactionPayload;
}
/**
* Get refund payload
*
* @param transaction
* @return
*/
private RefundCreate getRefundPayload(Transaction transaction) {
RefundCreate refundPayload = new RefundCreate();
refundPayload.amount(transaction.getAuthorizationAmount())
.transaction(transaction.getId())
.merchantReference(transaction.getMerchantReference())
.externalId(transaction.getId().toString())
.type(RefundType.MERCHANT_INITIATED_ONLINE);
return refundPayload;
}
/**
* create
*
* This operation creates and executes a refund of a particular transaction.
*/
public void refund() {
try {
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
transaction = this.transactionService.processWithoutUserInteraction(this.spaceId, transaction.getId());
for (int i = 1; i <= 5; i++) {
if (
transaction.getState() == TransactionState.FULFILL ||
transaction.getState() == TransactionState.FAILED
) {
break;
}
try {
Thread.sleep(i * 30);
} catch (InterruptedException e) {
System.err.println(e.getMessage());
}
transaction = this.transactionService.read(this.spaceId, transaction.getId());
}
if (transaction.getState() == TransactionState.FULFILL) {
TransactionCompletion transactionCompletion = this.transactionCompletionService.completeOffline(this.spaceId, transaction.getId());
transaction = this.transactionService.read(transaction.getLinkedSpaceId(), transactionCompletion.getLinkedTransaction());
Refund refund = this.refundService.refund(this.spaceId, getRefundPayload(transaction));
// expect refund.getState() to equal RefundState.SUCCESSFUL
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using Wallee.Model;
using Wallee.Service;
using Wallee.Client;
namespace Wallee.RefundServiceExample
{
/// <summary>
/// Class for RefundServiceExample
/// </summary>
public class RefundServiceExample
{
private readonly long SpaceId = <:YOUR_SPACE_ID>;
private readonly string ApplicationUserID = <:YOUR_USER_ID>;
private readonly string AuthenticationKey = <:YOUR_USER_SECRET>;
private Configuration Configuration;
private RefundService RefundService;
private Transaction Transaction;
private TransactionCompletionService TransactionCompletionService;
private TransactionCreate TransactionPayload;
private TransactionService TransactionService;
/// <summary>
/// RefundServiceExample
/// </summary>
public RefundServiceExample()
{
this.Configuration = new Configuration(this.ApplicationUserID, this.AuthenticationKey);
this.RefundService = new RefundService(this.Configuration);
this.TransactionCompletionService = new TransactionCompletionService(this.Configuration);
this.TransactionService = new TransactionService(this.Configuration);
}
// <summary>
// Get transaction payload
// <summary>
private TransactionCreate GetTransactionPayload()
{
if (this.TransactionPayload == null)
{
// Line item
LineItemCreate lineItem1 = new LineItemCreate(
name: "Red T-Shirt",
uniqueId: "5412",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal)29.95
)
{
Sku = "red-t-shirt-123"
};
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate
{
City = "Winterthur",
Country = "CH",
EmailAddress = "[email protected]",
FamilyName = "Customer",
GivenName = "Good",
Postcode = "8400",
PostalState = "ZH",
OrganizationName = "Test GmbH",
MobilePhoneNumber = "+41791234567",
Salutation = "Ms"
};
this.TransactionPayload = new TransactionCreate(new List<LineItemCreate>() { lineItem1 })
{
Currency = "CHF",
AutoConfirmationEnabled = true,
BillingAddress = billingAddress,
ShippingAddress = billingAddress,
Language = "en-US"
};
}
return this.TransactionPayload;
}
/// <summary>
/// Create Transaction
/// </summary>
private Transaction GetTransaction()
{
return this.TransactionService.Create(this.SpaceId, this.GetTransactionPayload());
}
// <summary>
// Get refund payload
// <summary>
private RefundCreate GetRefundPayload(Transaction transaction)
{
RefundCreate refundPayload = new RefundCreate(transaction.Id.ToString(), RefundType.MERCHANT_INITIATED_ONLINE)
{
Amount = transaction.AuthorizationAmount,
Transaction = transaction.Id,
MerchantReference = transaction.MerchantReference
};
return refundPayload;
}
/// <summary>
/// Refund
/// </summary>
public void Refund()
{
this.Transaction = this.GetTransaction();
Transaction transaction = this.TransactionService.ProcessWithoutUserInteraction(this.SpaceId, this.Transaction.Id);
TransactionState[] TransactionStates = {
TransactionState.FAILED,
TransactionState.FULFILL
};
for (var i = 1; i <= 5; i++) {
if (Array.Exists(TransactionStates, element => element == transaction.State)){
break;
}
System.Threading.Thread.Sleep(i * 30); // keep waiting for the transaction to transition to FULFILL or FAIL
transaction = this.TransactionService.Read(this.SpaceId, transaction.Id);
}
if (transaction.State == TransactionState.FULFILL){
TransactionCompletion transactionCompletion = this.TransactionCompletionService.CompleteOffline(this.SpaceId, transaction.Id);
transaction = this.TransactionService.Read(this.SpaceId, transactionCompletion.LinkedTransaction); // fetch the latest transaction data
RefundCreate refundPayload = this.GetRefundPayload(transaction);
Refund refund = this.RefundService.Refund(this.SpaceId, refundPayload);
}
}
}
}
'use strict';
import { Wallee } from 'wallee';
import http = require("http");
// config
let config: { space_id: number, user_id: number, api_secret: string } = {
space_id: <:YOUR_SPACE_ID>,
user_id: <:YOUR_USER_ID>,
api_secret: <:YOUR_USER_SECRET>
};
// Services
let refundService: Wallee.api.RefundService = new Wallee.api.RefundService(config);
let transactionCompletionService: Wallee.api.TransactionCompletionService = new Wallee.api.TransactionCompletionService(config);
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);
// Models
let transactionPayload: Wallee.model.TransactionCreate;
/**
* Get transaction payload
*/
function getTransactionPayload(): Wallee.model.TransactionCreate {
if (!transactionPayload) {
// Line item
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name = 'Red T-Shirt';
lineItem.uniqueId = '5412';
lineItem.type = Wallee.model.LineItemType.PRODUCT;
lineItem.quantity = 1;
lineItem.amountIncludingTax = 29.95;
lineItem.sku = 'red-t-shirt-123';
// Customer Billing Address
let billingAddress: Wallee.model.AddressCreate = new Wallee.model.AddressCreate();
billingAddress.city = "Winterthur";
billingAddress.country = "CH";
billingAddress.emailAddress = "[email protected]";
billingAddress.familyName = "Customer";
billingAddress.givenName = "Good";
billingAddress.postcode = "8400";
billingAddress.postalState = "ZH";
billingAddress.organizationName = "Test GmbH";
billingAddress.mobilePhoneNumber = "+41791234567";
billingAddress.salutation = "Ms";
// Payload
transactionPayload = new Wallee.model.TransactionCreate();
transactionPayload.lineItems = [lineItem];
transactionPayload.autoConfirmationEnabled = true;
transactionPayload.currency = 'CHF';
transactionPayload.billingAddress = billingAddress;
transactionPayload.shippingAddress = billingAddress;
}
return transactionPayload;
}
/**
* Get refund payload
*/
function getRefundPayload(transaction: Wallee.model.Transaction): Wallee.model.RefundCreate {
let refundPayload: Wallee.model.RefundCreate = new Wallee.model.RefundCreate();
refundPayload.externalId = <string><any>transaction.id;
refundPayload.type = Wallee.model.RefundType.MERCHANT_INITIATED_ONLINE;
refundPayload.amount = transaction.authorizationAmount;
refundPayload.transaction = transaction.id;
refundPayload.merchantReference = transaction.merchantReference;
return refundPayload;
}
// Refund a transaction
let transaction: Wallee.model.Transaction;
let refund: Wallee.model.Refund;
transactionService.create(config.space_id, getTransactionPayload())
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionService.processWithoutUserInteraction(config.space_id, <number>transaction.id);
})
.delay(15000)
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionCompletionService.completeOffline(config.space_id, <number>transaction.id)
.then((response1: { response: http.IncomingMessage, body: Wallee.model.TransactionCompletion }) => {
return transactionService.read(config.space_id, <number>transaction.id);
});
}).then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return refundService.refund(config.space_id, getRefundPayload(transaction));
}).done((response: { response: http.IncomingMessage, body: Wallee.model.Refund }) => {
refund = response.body;
// expect refund.state to equal Wallee.model.RefundState.SUCCESSFUL
});
This operation allows to mark a refund as successful which is in state MANUAL_CHECK.
This operation processes the given transaction by using the token associated with the transaction.
Deletes the entity with the given id.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
This operation creates a token for the given transaction and fills it with the stored payment information of the transaction. The payment information for the transaction will be filled in immediately, if payment information is missing, an exception will be thrown.
Counts the number of items in the database as restricted by the given filter.
This operation creates a token for the given transaction. The transaction payment information will be populated asynchronously as soon as all data becomes available.
This operation checks if the given transaction can be used to create a token out of it.
Reads the entity with the given 'id' and returns it.
This operation creates a transaction which allows the updating of the provided token.
Searches for the entities as specified by the given query.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Returns the token version which is currently active given by the token id. In case no token version is active the method will return null.
Reads the entity with the given 'id' and returns it.
This updates the comment with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the comment.
Reads the comment with the given 'id' and returns it.
Pins the comment to the top.
Deletes the comment with the given id.
Unpins the comment from the top.
Returns all comments of the transaction.
Creates the comment with the given properties.
Counts the number of items in the database as restricted by the given filter.
This operation completes the transaction online. The completion is forwarded to the processor. This implies that the processor may take some actions based on the completion.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\AddressCreate;
use Wallee\Sdk\Model\LineItemCreate;
use Wallee\Sdk\Model\LineItemType;
use Wallee\Sdk\Model\TransactionCompletionState;
use Wallee\Sdk\Model\TransactionCreate;
use Wallee\Sdk\Model\TransactionState;
use Wallee\Sdk\Service\TransactionCompletionService;
use Wallee\Sdk\Service\TransactionService;
// credentials
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
// Services
$apiClient = new ApiClient($userId, $secret);
$transactionCompletionService = new TransactionCompletionService($apiClient);
$transactionService = new TransactionService($apiClient);
// line item
$lineItem = new LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(LineItemType::PRODUCT);
// Customer Billing Address
$billingAddress = new AddressCreate();
$billingAddress->setCity('Winterthur');
$billingAddress->setCountry('CH');
$billingAddress->setEmailAddress('[email protected]');
$billingAddress->setFamilyName('Customer');
$billingAddress->setGivenName('Good');
$billingAddress->setPostCode('8400');
$billingAddress->setPostalState('ZH');
$billingAddress->setOrganizationName('Test GmbH');
$billingAddress->setPhoneNumber('+41791234567');
$billingAddress->setSalutation('Ms');
// Transaction payload
$transactionPayload = new TransactionCreate();
$transactionPayload->setCurrency('CHF');
$transactionPayload->setLineItems([$lineItem]);
$transactionPayload->setAutoConfirmationEnabled(true);
$transactionPayload->setBillingAddress($billingAddress);
$transactionPayload->setShippingAddress($billingAddress);
$transactionPayload->setFailedUrl('https://YOUR.SITE/transaction?state=fail');
$transactionPayload->setSuccessUrl('https://YOUR.SITE/transaction?state=success');
// Create a transaction
$transaction = $transactionService->create($spaceId, $transactionPayload);
$transaction = $transactionService->processWithoutUserInteraction($spaceId, $transaction->getId());
// Complete a transaction offline
$transactionCompletion = $this->transactionCompletionService->completeOnline($this->spaceId, $transaction->getId());
if(in_array($transactionCompletion->getState(), [TransactionCompletionState::SUCCESSFUL])){
// completion successful
}
package com.wallee.sdk.test;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.*;
import com.wallee.sdk.service.*;
import java.math.BigDecimal;
/**
* API tests for TransactionCompletionService
*/
public class TransactionCompletionServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private TransactionCompletionService transactionCompletionService;
private TransactionService transactionService;
// Models
private TransactionCreate transactionPayload;
public TransactionCompletionServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.transactionCompletionService = new TransactionCompletionService(this.apiClient);
this.transactionService = new TransactionService(this.apiClient);
}
/**
* Get transaction payload
*
* @return TransactionCreate
*/
private TransactionCreate getTransactionPayload() {
if (this.transactionPayload == null) {
// Line item
LineItemCreate lineItem = new LineItemCreate();
lineItem.name("Red T-Shirt")
.uniqueId("5412")
.type(LineItemType.PRODUCT)
.quantity(BigDecimal.valueOf(1))
.amountIncludingTax(BigDecimal.valueOf(29.95))
.sku("red-t-shirt-123");
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate();
billingAddress.city("Winterthur")
.country("CH")
.emailAddress("[email protected]")
.familyName("Customer")
.givenName("Good")
.postcode("8400")
.postalState("ZH")
.organizationName("Test GmbH")
.mobilePhoneNumber("+41791234567")
.salutation("Ms");
this.transactionPayload = new TransactionCreate();
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
this.transactionPayload.setBillingAddress(billingAddress);
this.transactionPayload.setShippingAddress(billingAddress);
this.transactionPayload.addLineItemsItem(lineItem);
}
return this.transactionPayload;
}
/**
* completeOnline
*
* This operation completes the transaction online. The completion is forwarded to the processor. This implies that the processor may take some actions based on the completion.
*/
public void completeOnline() {
try {
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
transaction = this.transactionService.processWithoutUserInteraction(this.spaceId, transaction.getId());
TransactionCompletion transactionCompletion = this.transactionCompletionService.completeOnline(this.spaceId, transaction.getId());
TransactionCompletionState[] TransactionCompletionStates = {
TransactionCompletionState.SUCCESSFUL,
TransactionCompletionState.PENDING
};
// expect transactionCompletion.getState() to be in TransactionCompletionStates
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using Wallee.Model;
using Wallee.Service;
using Wallee.Client;
namespace Wallee.TransactionCompletionServiceExample
{
/// <summary>
/// Class for TransactionCompletionServiceExample
/// </summary>
public class TransactionCompletionServiceExample
{
private readonly long SpaceId = <:YOUR_SPACE_ID>;
private readonly string ApplicationUserID = <:YOUR_USER_ID>;
private readonly string AuthenticationKey = <:YOUR_USER_SECRET>;
private TransactionCompletionService TransactionCompletionService;
private TransactionService TransactionService;
/// <summary>
/// TransactionCompletionServiceExample
/// </summary>
public TransactionCompletionServiceExample()
{
Configuration configuration = new Configuration(this.ApplicationUserID, this.AuthenticationKey);
this.TransactionCompletionService = new TransactionCompletionService(configuration);
this.TransactionService = new TransactionService(configuration);
}
// <summary>
// Get transaction payload
// <summary>
private TransactionCreate GetTransactionPayload()
{
// Line item
LineItemCreate lineItem1 = new LineItemCreate(
name: "Red T-Shirt",
uniqueId: "5412",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal)29.95
)
{
Sku = "red-t-shirt-123"
};
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate
{
City = "Winterthur",
Country = "CH",
EmailAddress = "[email protected]",
FamilyName = "Customer",
GivenName = "Good",
Postcode = "8400",
PostalState = "ZH",
OrganizationName = "Test GmbH",
MobilePhoneNumber = "+41791234567",
Salutation = "Ms"
};
TransactionCreate transactionPayload = new TransactionCreate(new List<LineItemCreate>() { lineItem1 })
{
Currency = "CHF",
AutoConfirmationEnabled = true,
BillingAddress = billingAddress,
ShippingAddress = billingAddress,
Language = "en-US"
};
return transactionPayload;
}
/// <summary>
/// CompleteOnline
/// </summary>
public void CompleteOnline()
{
Transaction transaction = this.TransactionService.Create(this.SpaceId, this.GetTransactionPayload());
transaction = this.TransactionService.ProcessWithoutUserInteraction(this.SpaceId, transaction.Id);
TransactionCompletion transactionCompletion = this.TransactionCompletionService.CompleteOnline(this.SpaceId, transaction.Id);
}
}
}
'use strict';
import { Wallee } from 'wallee';
import http = require("http");
// config
let config: { space_id: number, user_id: number, api_secret: string } = {
space_id: <:YOUR_SPACE_ID>,
user_id: <:YOUR_USER_ID>,
api_secret: <:YOUR_USER_SECRET>
};
// Services
let transactionCompletionService: Wallee.api.TransactionCompletionService = new Wallee.api.TransactionCompletionService(config);
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);
// Models
let transactionPayload: Wallee.model.TransactionCreate;
/**
* Get transaction payload
*/
function getTransactionPayload(): Wallee.model.TransactionCreate {
if (!transactionPayload) {
// Line item
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name = 'Red T-Shirt';
lineItem.uniqueId = '5412';
lineItem.type = Wallee.model.LineItemType.PRODUCT;
lineItem.quantity = 1;
lineItem.amountIncludingTax = 29.95;
lineItem.sku = 'red-t-shirt-123';
// Customer Billing Address
let billingAddress: Wallee.model.AddressCreate = new Wallee.model.AddressCreate();
billingAddress.city = "Winterthur";
billingAddress.country = "CH";
billingAddress.emailAddress = "[email protected]";
billingAddress.familyName = "Customer";
billingAddress.givenName = "Good";
billingAddress.postcode = "8400";
billingAddress.postalState = "ZH";
billingAddress.organizationName = "Test GmbH";
billingAddress.mobilePhoneNumber = "+41791234567";
billingAddress.salutation = "Ms";
// Payload
transactionPayload = new Wallee.model.TransactionCreate();
transactionPayload.lineItems = [lineItem];
transactionPayload.autoConfirmationEnabled = true;
transactionPayload.currency = 'CHF';
transactionPayload.billingAddress = billingAddress;
transactionPayload.shippingAddress = billingAddress;
}
return transactionPayload;
}
// Complete a transaction online
let transaction: Wallee.model.Transaction;
let transactionCompletion: Wallee.model.TransactionCompletion;
transactionService.create(config.space_id, getTransactionPayload())
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionService.processWithoutUserInteraction(config.space_id, <number>transaction.id);
})
.delay(7500)
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionCompletionService.completeOnline(config.space_id, <number>transaction.id);
})
.delay(7500)
.done((response: { response: http.IncomingMessage, body: Wallee.model.TransactionCompletion }) => {
transactionCompletion = response.body;
// expect transactionCompletion.state to equal Wallee.model.TransactionCompletionState.SUCCESSFUL
});
This operation can be used to partially complete the transaction offline. The completion is not forwarded to the processor. This implies the processor does not do anything. This method is only here to fix manually the transaction state.
Searches for the entities as specified by the given query.
This operation can be used to partially complete the transaction online. The completion is forwarded to the processor. This implies that the processor may take some actions based on the completion.
Reads the entity with the given 'id' and returns it.
This operation completes the transaction offline. The completion is not forwarded to the processor. This implies the processor does not do anything. This method is only here to fix manually the transaction state.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\AddressCreate;
use Wallee\Sdk\Model\LineItemCreate;
use Wallee\Sdk\Model\LineItemType;
use Wallee\Sdk\Model\TransactionCompletionState;
use Wallee\Sdk\Model\TransactionCreate;
use Wallee\Sdk\Model\TransactionState;
use Wallee\Sdk\Service\TransactionCompletionService;
use Wallee\Sdk\Service\TransactionService;
// credentials
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
// Services
$apiClient = new ApiClient($userId, $secret);
$transactionCompletionService = new TransactionCompletionService($apiClient);
$transactionService = new TransactionService($apiClient);
// line item
$lineItem = new LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(LineItemType::PRODUCT);
// Customer Billing Address
$billingAddress = new AddressCreate();
$billingAddress->setCity('Winterthur');
$billingAddress->setCountry('CH');
$billingAddress->setEmailAddress('[email protected]');
$billingAddress->setFamilyName('Customer');
$billingAddress->setGivenName('Good');
$billingAddress->setPostCode('8400');
$billingAddress->setPostalState('ZH');
$billingAddress->setOrganizationName('Test GmbH');
$billingAddress->setPhoneNumber('+41791234567');
$billingAddress->setSalutation('Ms');
// Transaction payload
$transactionPayload = new TransactionCreate();
$transactionPayload->setCurrency('CHF');
$transactionPayload->setLineItems([$lineItem]);
$transactionPayload->setAutoConfirmationEnabled(true);
$transactionPayload->setBillingAddress($billingAddress);
$transactionPayload->setShippingAddress($billingAddress);
$transactionPayload->setFailedUrl('https://YOUR.SITE/transaction?state=fail');
$transactionPayload->setSuccessUrl('https://YOUR.SITE/transaction?state=success');
// Create a transaction
$transaction = $transactionService->create($spaceId, $transactionPayload);
$transaction = $transactionService->processWithoutUserInteraction($spaceId, $transaction->getId());
// Complete a transaction offline
$transactionCompletion = $this->transactionCompletionService->completeOffline($this->spaceId, $transaction->getId());
if(in_array($transactionCompletion->getState(), [TransactionCompletionState::SUCCESSFUL])){
// completion successful
}
package com.wallee.sdk.test;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.*;
import com.wallee.sdk.service.*;
import java.math.BigDecimal;
/**
* API tests for TransactionCompletionService
*/
public class TransactionCompletionServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private TransactionCompletionService transactionCompletionService;
private TransactionService transactionService;
// Models
private TransactionCreate transactionPayload;
public TransactionCompletionServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.transactionCompletionService = new TransactionCompletionService(this.apiClient);
this.transactionService = new TransactionService(this.apiClient);
}
/**
* Get transaction payload
*
* @return TransactionCreate
*/
private TransactionCreate getTransactionPayload() {
if (this.transactionPayload == null) {
// Line item
LineItemCreate lineItem = new LineItemCreate();
lineItem.name("Red T-Shirt")
.uniqueId("5412")
.type(LineItemType.PRODUCT)
.quantity(BigDecimal.valueOf(1))
.amountIncludingTax(BigDecimal.valueOf(29.95))
.sku("red-t-shirt-123");
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate();
billingAddress.city("Winterthur")
.country("CH")
.emailAddress("[email protected]")
.familyName("Customer")
.givenName("Good")
.postcode("8400")
.postalState("ZH")
.organizationName("Test GmbH")
.mobilePhoneNumber("+41791234567")
.salutation("Ms");
this.transactionPayload = new TransactionCreate();
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
this.transactionPayload.setBillingAddress(billingAddress);
this.transactionPayload.setShippingAddress(billingAddress);
this.transactionPayload.addLineItemsItem(lineItem);
}
return this.transactionPayload;
}
/**
* completeOffline
*
* This operation completes the transaction offline. The completion is not forwarded to the processor. This implies the processor does not do anything. This method is only here to fix manually the transaction state.
*/
public void completeOffline() {
try {
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
transaction = this.transactionService.processWithoutUserInteraction(this.spaceId, transaction.getId());
TransactionCompletion transactionCompletion = this.transactionCompletionService.completeOffline(this.spaceId, transaction.getId());
TransactionCompletionState[] TransactionCompletionStates = {
TransactionCompletionState.SUCCESSFUL,
TransactionCompletionState.PENDING
};
// expect transactionCompletion.getState() to be in TransactionCompletionStates
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using Wallee.Model;
using Wallee.Service;
using Wallee.Client;
namespace Wallee.TransactionCompletionServiceExample
{
/// <summary>
/// Class for TransactionCompletionServiceExample
/// </summary>
public class TransactionCompletionServiceExample
{
private readonly long SpaceId = <:YOUR_SPACE_ID>;
private readonly string ApplicationUserID = <:YOUR_USER_ID>;
private readonly string AuthenticationKey = <:YOUR_USER_SECRET>;
private TransactionCompletionService TransactionCompletionService;
private TransactionService TransactionService;
/// <summary>
/// TransactionCompletionServiceExample
/// </summary>
public TransactionCompletionServiceExample()
{
Configuration configuration = new Configuration(this.ApplicationUserID, this.AuthenticationKey);
this.TransactionCompletionService = new TransactionCompletionService(configuration);
this.TransactionService = new TransactionService(configuration);
}
// <summary>
// Get transaction payload
// <summary>
private TransactionCreate GetTransactionPayload()
{
// Line item
LineItemCreate lineItem1 = new LineItemCreate(
name: "Red T-Shirt",
uniqueId: "5412",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal)29.95
)
{
Sku = "red-t-shirt-123"
};
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate
{
City = "Winterthur",
Country = "CH",
EmailAddress = "[email protected]",
FamilyName = "Customer",
GivenName = "Good",
Postcode = "8400",
PostalState = "ZH",
OrganizationName = "Test GmbH",
MobilePhoneNumber = "+41791234567",
Salutation = "Ms"
};
TransactionCreate transactionPayload = new TransactionCreate(new List<LineItemCreate>() { lineItem1 })
{
Currency = "CHF",
AutoConfirmationEnabled = true,
BillingAddress = billingAddress,
ShippingAddress = billingAddress,
Language = "en-US"
};
return transactionPayload;
}
/// <summary>
/// CompleteOffline
/// </summary>
public void CompleteOffline()
{
Transaction transaction = this.TransactionService.Create(this.SpaceId, this.GetTransactionPayload());
transaction = this.TransactionService.ProcessWithoutUserInteraction(this.SpaceId, transaction.Id);
TransactionCompletion transactionCompletion = this.TransactionCompletionService.CompleteOffline(this.SpaceId, transaction.Id);
}
}
}
'use strict';
import { Wallee } from 'wallee';
import http = require("http");
// config
let config: { space_id: number, user_id: number, api_secret: string } = {
space_id: <:YOUR_SPACE_ID>,
user_id: <:YOUR_USER_ID>,
api_secret: <:YOUR_USER_SECRET>
};
// Services
let transactionCompletionService: Wallee.api.TransactionCompletionService = new Wallee.api.TransactionCompletionService(config);
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);
// Models
let transactionPayload: Wallee.model.TransactionCreate;
/**
* Get transaction payload
*/
function getTransactionPayload(): Wallee.model.TransactionCreate {
if (!transactionPayload) {
// Line item
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name = 'Red T-Shirt';
lineItem.uniqueId = '5412';
lineItem.type = Wallee.model.LineItemType.PRODUCT;
lineItem.quantity = 1;
lineItem.amountIncludingTax = 29.95;
lineItem.sku = 'red-t-shirt-123';
// Customer Billing Address
let billingAddress: Wallee.model.AddressCreate = new Wallee.model.AddressCreate();
billingAddress.city = "Winterthur";
billingAddress.country = "CH";
billingAddress.emailAddress = "[email protected]";
billingAddress.familyName = "Customer";
billingAddress.givenName = "Good";
billingAddress.postcode = "8400";
billingAddress.postalState = "ZH";
billingAddress.organizationName = "Test GmbH";
billingAddress.mobilePhoneNumber = "+41791234567";
billingAddress.salutation = "Ms";
// Payload
transactionPayload = new Wallee.model.TransactionCreate();
transactionPayload.lineItems = [lineItem];
transactionPayload.autoConfirmationEnabled = true;
transactionPayload.currency = 'CHF';
transactionPayload.billingAddress = billingAddress;
transactionPayload.shippingAddress = billingAddress;
}
return transactionPayload;
}
// Complete a transaction offline
let transaction: Wallee.model.Transaction;
let transactionCompletion: Wallee.model.TransactionCompletion;
transactionService.create(config.space_id, getTransactionPayload())
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionService.processWithoutUserInteraction(config.space_id, <number>transaction.id);
})
.delay(7500)
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
transaction = response.body;
return transactionCompletionService.completeOffline(config.space_id, <number>transaction.id);
})
.delay(7500)
.done((response: { response: http.IncomingMessage, body: Wallee.model.TransactionCompletion }) => {
transactionCompletion = response.body;
// expect transactionCompletion.state to equal Wallee.model.TransactionCompletionState.SUCCESSFUL
});
This operation creates the URL which can be used to embed the JavaScript for handling the iFrame checkout flow.
Pins the comment to the top.
Deletes the comment with the given id.
Unpins the comment from the top.
Returns all comments of the given transaction invoice.
Creates the comment with the given properties.
Reads the comment with the given 'id' and returns it.
This updates the comment with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the comment.
Replaces the transaction invoice with given id with the replacement and returns the new transaction invoice.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Returns the PDF document for the transaction invoice with given id and target media type id.
Returns the PDF document for the transaction invoice with given id.
Returns whether the transaction invoice with the given id can be replaced.
Marks the transaction invoice with the given id as paid.
Marks the transaction invoice with the given id as derecognized.
This operation creates the URL which can be used to embed the JavaScript for handling the Lightbox checkout flow.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\AddressCreate;
use Wallee\Sdk\Model\LineItemCreate;
use Wallee\Sdk\Model\LineItemType;
use Wallee\Sdk\Model\TransactionCreate;
use Wallee\Sdk\Service\TransactionLightboxService;
use Wallee\Sdk\Service\TransactionService;
// credentials
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
// Services
$apiClient = new ApiClient($userId, $secret);
$transactionLightboxService = new TransactionLightboxService($apiClient);
$transactionService = new TransactionService($apiClient);
// line item
$lineItem = new LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(LineItemType::PRODUCT);
// Customer Billing Address
$billingAddress = new AddressCreate();
$billingAddress->setCity('Winterthur');
$billingAddress->setCountry('CH');
$billingAddress->setEmailAddress('[email protected]');
$billingAddress->setFamilyName('Customer');
$billingAddress->setGivenName('Good');
$billingAddress->setPostCode('8400');
$billingAddress->setPostalState('ZH');
$billingAddress->setOrganizationName('Test GmbH');
$billingAddress->setPhoneNumber('+41791234567');
$billingAddress->setSalutation('Ms');
// Transaction payload
$transactionPayload = new TransactionCreate();
$transactionPayload->setCurrency('CHF');
$transactionPayload->setLineItems([$lineItem]);
$transactionPayload->setAutoConfirmationEnabled(true);
$transactionPayload->setBillingAddress($billingAddress);
$transactionPayload->setShippingAddress($billingAddress);
$transactionPayload->setFailedUrl('https://YOUR.SITE/transaction?state=fail');
$transactionPayload->setSuccessUrl('https://YOUR.SITE/transaction?state=success');
$transaction = $transactionService->create($spaceId, $transactionPayload);
$javascriptUrl = $transactionLightboxService->javascriptUrl($spaceId, $transaction->getId());
package com.wallee.sdk.test;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.*;
import com.wallee.sdk.service.*;
import java.math.BigDecimal;
/**
* API tests for TransactionLightboxService
*/
public class TransactionLightboxServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private TransactionLightboxService transactionLightboxService;
private TransactionService transactionService;
// Models
private TransactionCreate transactionPayload;
public TransactionLightboxServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.transactionLightboxService = new TransactionLightboxService(this.apiClient);
this.transactionService = new TransactionService(this.apiClient);
}
/**
* Get transaction payload
*
* @return TransactionCreate
*/
private TransactionCreate getTransactionPayload() {
if (this.transactionPayload == null) {
// Line item
LineItemCreate lineItem = new LineItemCreate();
lineItem.name("Red T-Shirt")
.uniqueId("5412")
.type(LineItemType.PRODUCT)
.quantity(BigDecimal.valueOf(1))
.amountIncludingTax(BigDecimal.valueOf(29.95))
.sku("red-t-shirt-123");
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate();
billingAddress.city("Winterthur")
.country("CH")
.emailAddress("[email protected]")
.familyName("Customer")
.givenName("Good")
.postcode("8400")
.postalState("ZH")
.organizationName("Test GmbH")
.mobilePhoneNumber("+41791234567")
.salutation("Ms");
this.transactionPayload = new TransactionCreate();
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
this.transactionPayload.setBillingAddress(billingAddress);
this.transactionPayload.setShippingAddress(billingAddress);
this.transactionPayload.addLineItemsItem(lineItem);
}
return this.transactionPayload;
}
/**
* Build JavaScript URL
*
* This operation creates the URL which can be used to embed the JavaScript for handling the Lightbox checkout flow.
*/
public void javascriptUrl() {
try {
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
String javascriptUrl = this.transactionLightboxService.javascriptUrl(spaceId, transaction.getId());
// expect javascriptUrl to be a URL beginning with https://
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using Wallee.Model;
using Wallee.Service;
using Wallee.Client;
namespace Wallee.TransactionLightboxServiceExample
{
/// <summary>
/// Class for TransactionLightboxServiceExample
/// </summary>
public class TransactionLightboxServiceExample
{
private readonly long SpaceId = <:YOUR_SPACE_ID>;
private readonly string ApplicationUserID = <:YOUR_USER_ID>;
private readonly string AuthenticationKey = <:YOUR_USER_SECRET>;
private Configuration Configuration;
private TransactionLightboxService TransactionLightboxService;
private TransactionCreate TransactionPayload;
private TransactionService TransactionService;
/// <summary>
/// Class for TransactionLightboxServiceExample
/// </summary>
public TransactionLightboxServiceExample()
{
this.Configuration = new Configuration(this.ApplicationUserID, this.AuthenticationKey);
this.TransactionLightboxService = new TransactionLightboxService(this.Configuration);
this.TransactionService = new TransactionService(this.Configuration);
}
// <summary>
// Get transaction payload
// <summary>
private TransactionCreate GetTransactionPayload()
{
if (this.TransactionPayload == null)
{
// Line item
LineItemCreate lineItem1 = new LineItemCreate(
name: "Red T-Shirt",
uniqueId: "5412",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal)29.95
)
{
Sku = "red-t-shirt-123"
};
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate
{
City = "Winterthur",
Country = "CH",
EmailAddress = "[email protected]",
FamilyName = "Customer",
GivenName = "Good",
Postcode = "8400",
PostalState = "ZH",
OrganizationName = "Test GmbH",
MobilePhoneNumber = "+41791234567",
Salutation = "Ms"
};
this.TransactionPayload = new TransactionCreate(new List<LineItemCreate>() { lineItem1 })
{
Currency = "CHF",
AutoConfirmationEnabled = true,
BillingAddress = billingAddress,
ShippingAddress = billingAddress,
Language = "en-US"
};
}
return this.TransactionPayload;
}
/// <summary>
/// JavascriptUrl
/// </summary>
public void JavascriptUrl()
{
Transaction transaction = this.TransactionService.Create(this.SpaceId, this.GetTransactionPayload());
var response = TransactionLightboxService.JavascriptUrl(this.SpaceId, transaction.Id);
}
}
}
'use strict';
import { Wallee } from 'wallee';
import http = require("http");
// config
let config: { space_id: number, user_id: number, api_secret: string } = {
space_id: <:YOUR_SPACE_ID>,
user_id: <:YOUR_USER_ID>,
api_secret: <:YOUR_USER_SECRET>
};
// Services
let transactionLightboxService: Wallee.api.TransactionLightboxService = new Wallee.api.TransactionLightboxService(config);
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);
// Models
let transactionPayload: Wallee.model.TransactionCreate;
/**
* Get transaction payload
*/
function getTransactionPayload(): Wallee.model.TransactionCreate {
if (!transactionPayload) {
// Line item
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name = 'Red T-Shirt';
lineItem.uniqueId = '5412';
lineItem.type = Wallee.model.LineItemType.PRODUCT;
lineItem.quantity = 1;
lineItem.amountIncludingTax = 29.95;
lineItem.sku = 'red-t-shirt-123';
// Customer Billing Address
let billingAddress: Wallee.model.AddressCreate = new Wallee.model.AddressCreate();
billingAddress.city = "Winterthur";
billingAddress.country = "CH";
billingAddress.emailAddress = "[email protected]";
billingAddress.familyName = "Customer";
billingAddress.givenName = "Good";
billingAddress.postcode = "8400";
billingAddress.postalState = "ZH";
billingAddress.organizationName = "Test GmbH";
billingAddress.mobilePhoneNumber = "+41791234567";
billingAddress.salutation = "Ms";
// Payload
transactionPayload = new Wallee.model.TransactionCreate();
transactionPayload.lineItems = [lineItem];
transactionPayload.autoConfirmationEnabled = true;
transactionPayload.currency = 'CHF';
transactionPayload.billingAddress = billingAddress;
transactionPayload.shippingAddress = billingAddress;
}
return transactionPayload;
}
// Fetch lightbox javascript url
transactionService.create(config.space_id, getTransactionPayload())
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
let transaction: Wallee.model.Transaction = response.body;
return transactionLightboxService.javascriptUrl(config.space_id, <number>transaction.id);
})
.done((response: { response: http.IncomingMessage, body: string }) => {
let javascriptUrl: string = response.body;
// expect javascriptUrl to be a string
// expect javascriptUrl to include https://
});
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
This operation applies a line item version on a particular transaction.
This operation builds the URL which is used to load the payment form within a WebView on a mobile device. This operation is typically called through the mobile SDK.
This operation creates the URL to which the user should be redirected to when the payment page should be used.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\AddressCreate;
use Wallee\Sdk\Model\LineItemCreate;
use Wallee\Sdk\Model\LineItemType;
use Wallee\Sdk\Model\TransactionCreate;
use Wallee\Sdk\Service\TransactionPaymentPageService;
use Wallee\Sdk\Service\TransactionService;
// credentials
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
// Services
$apiClient = new ApiClient($userId, $secret);
$transactionPaymentPageService = new TransactionPaymentPageService($apiClient);
$transactionService = new TransactionService($apiClient);
// line item
$lineItem = new LineItemCreate();
$lineItem->setName('Red T-Shirt');
$lineItem->setUniqueId('5412');
$lineItem->setSku('red-t-shirt-123');
$lineItem->setQuantity(1);
$lineItem->setAmountIncludingTax(29.95);
$lineItem->setType(LineItemType::PRODUCT);
// Customer Billing Address
$billingAddress = new AddressCreate();
$billingAddress->setCity('Winterthur');
$billingAddress->setCountry('CH');
$billingAddress->setEmailAddress('[email protected]');
$billingAddress->setFamilyName('Customer');
$billingAddress->setGivenName('Good');
$billingAddress->setPostCode('8400');
$billingAddress->setPostalState('ZH');
$billingAddress->setOrganizationName('Test GmbH');
$billingAddress->setPhoneNumber('+41791234567');
$billingAddress->setSalutation('Ms');
// Transaction payload
$transactionPayload = new TransactionCreate();
$transactionPayload->setCurrency('CHF');
$transactionPayload->setLineItems([$lineItem]);
$transactionPayload->setAutoConfirmationEnabled(true);
$transactionPayload->setBillingAddress($billingAddress);
$transactionPayload->setShippingAddress($billingAddress);
$transactionPayload->setFailedUrl('https://YOUR.SITE/transaction?state=fail');
$transactionPayload->setSuccessUrl('https://YOUR.SITE/transaction?state=success');
$transaction = $transactionService->create($spaceId, $transactionPayload);
$paymentPageUrl = $transactionPaymentPageService->paymentPageUrl($spaceId, $transaction->getId());
header('Location: '. $paymentPageUrl);
package com.wallee.sdk.test;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.*;
import com.wallee.sdk.service.*;
import java.math.BigDecimal;
/**
* API tests for TransactionPaymentPageService
*/
public class TransactionPaymentPageServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private TransactionPaymentPageService transactionPaymentPageService;
private TransactionService transactionService;
// Models
private TransactionCreate transactionPayload;
public TransactionPaymentPageServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.transactionPaymentPageService = new TransactionPaymentPageService(this.apiClient);
this.transactionService = new TransactionService(this.apiClient);
}
/**
* Get transaction payload
*
* @return TransactionCreate
*/
private TransactionCreate getTransactionPayload() {
if (this.transactionPayload == null) {
// Line item
LineItemCreate lineItem = new LineItemCreate();
lineItem.name("Red T-Shirt")
.uniqueId("5412")
.type(LineItemType.PRODUCT)
.quantity(BigDecimal.valueOf(1))
.amountIncludingTax(BigDecimal.valueOf(29.95))
.sku("red-t-shirt-123");
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate();
billingAddress.city("Winterthur")
.country("CH")
.emailAddress("[email protected]")
.familyName("Customer")
.givenName("Good")
.postcode("8400")
.postalState("ZH")
.organizationName("Test GmbH")
.mobilePhoneNumber("+41791234567")
.salutation("Ms");
this.transactionPayload = new TransactionCreate();
this.transactionPayload.autoConfirmationEnabled(true).currency("CHF").language("en-US");
this.transactionPayload.setBillingAddress(billingAddress);
this.transactionPayload.setShippingAddress(billingAddress);
this.transactionPayload.addLineItemsItem(lineItem);
}
return this.transactionPayload;
}
/**
* Build Payment Page URL
*
* This operation creates the URL to which the user should be redirected to when the payment page should be used.
*
*/
public void paymentPageUrl() {
try {
Transaction transaction = this.transactionService.create(this.spaceId, this.getTransactionPayload());
String paymentPageUrl = this.transactionPaymentPageService.paymentPageUrl(spaceId, transaction.getId());
// expect paymentPageUrl to be a URL beginning with https://
} catch (Exception e) {
e.printStackTrace();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using Wallee.Model;
using Wallee.Service;
using Wallee.Client;
namespace Wallee.TransactionPaymentPageServiceExample
{
/// <summary>
/// TransactionPaymentPageServiceExample
/// </summary>
public class TransactionPaymentPageServiceExample
{
private readonly long SpaceId = <:YOUR_SPACE_ID>;
private readonly string ApplicationUserID = <:YOUR_USER_ID>;
private readonly string AuthenticationKey = <:YOUR_USER_SECRET>;
private Configuration Configuration;
private TransactionPaymentPageService TransactionPaymentPageService;
private TransactionCreate TransactionPayload;
private TransactionService TransactionService;
/// <summary>
/// TransactionPaymentPageServiceExample
/// </summary>
public TransactionPaymentPageServiceExample()
{
this.Configuration = new Configuration(this.ApplicationUserID, this.AuthenticationKey);
this.TransactionPaymentPageService = new TransactionPaymentPageService(this.Configuration);
this.TransactionService = new TransactionService(this.Configuration);
}
// <summary>
// Get transaction payload
// <summary>
private TransactionCreate GetTransactionPayload()
{
if (this.TransactionPayload == null)
{
// Line item
LineItemCreate lineItem1 = new LineItemCreate(
name: "Red T-Shirt",
uniqueId: "5412",
type: LineItemType.PRODUCT,
quantity: 1,
amountIncludingTax: (decimal)29.95
)
{
Sku = "red-t-shirt-123"
};
// Customer Billind Address
AddressCreate billingAddress = new AddressCreate
{
City = "Winterthur",
Country = "CH",
EmailAddress = "[email protected]",
FamilyName = "Customer",
GivenName = "Good",
Postcode = "8400",
PostalState = "ZH",
OrganizationName = "Test GmbH",
MobilePhoneNumber = "+41791234567",
Salutation = "Ms"
};
this.TransactionPayload = new TransactionCreate(new List<LineItemCreate>() { lineItem1 })
{
Currency = "CHF",
AutoConfirmationEnabled = true,
BillingAddress = billingAddress,
ShippingAddress = billingAddress,
Language = "en-US"
};
}
return this.TransactionPayload;
}
/// <summary>
/// PaymentPageUrl
/// </summary>
public void PaymentPageUrl()
{
Transaction transaction = this.TransactionService.Create(this.SpaceId, this.GetTransactionPayload());
var response = TransactionPaymentPageService.PaymentPageUrl(this.SpaceId, transaction.Id);
}
}
}
'use strict';
import { Wallee } from 'wallee';
import http = require("http");
// config
let config: { space_id: number, user_id: number, api_secret: string } = {
space_id: <:YOUR_SPACE_ID>,
user_id: <:YOUR_USER_ID>,
api_secret: <:YOUR_USER_SECRET>
};
// Services
let transactionPaymentPageService: Wallee.api.TransactionPaymentPageService = new Wallee.api.TransactionPaymentPageService(config);
let transactionService: Wallee.api.TransactionService = new Wallee.api.TransactionService(config);
// Models
let transactionPayload: Wallee.model.TransactionCreate;
/**
* Get transaction payload
*/
function getTransactionPayload(): Wallee.model.TransactionCreate {
if (!transactionPayload) {
// Line item
let lineItem: Wallee.model.LineItemCreate = new Wallee.model.LineItemCreate();
lineItem.name = 'Red T-Shirt';
lineItem.uniqueId = '5412';
lineItem.type = Wallee.model.LineItemType.PRODUCT;
lineItem.quantity = 1;
lineItem.amountIncludingTax = 29.95;
lineItem.sku = 'red-t-shirt-123';
// Customer Billing Address
let billingAddress: Wallee.model.AddressCreate = new Wallee.model.AddressCreate();
billingAddress.city = "Winterthur";
billingAddress.country = "CH";
billingAddress.emailAddress = "[email protected]";
billingAddress.familyName = "Customer";
billingAddress.givenName = "Good";
billingAddress.postcode = "8400";
billingAddress.postalState = "ZH";
billingAddress.organizationName = "Test GmbH";
billingAddress.mobilePhoneNumber = "+41791234567";
billingAddress.salutation = "Ms";
// Payload
transactionPayload = new Wallee.model.TransactionCreate();
transactionPayload.lineItems = [lineItem];
transactionPayload.autoConfirmationEnabled = true;
transactionPayload.currency = 'CHF';
transactionPayload.billingAddress = billingAddress;
transactionPayload.shippingAddress = billingAddress;
}
return transactionPayload;
}
// Fetch Payment Page Url
transactionService.create(config.space_id, getTransactionPayload())
.then((response: { response: http.IncomingMessage, body: Wallee.model.Transaction }) => {
let transaction: Wallee.model.Transaction = response.body;
return transactionPaymentPageService.paymentPageUrl(config.space_id, <number>transaction.id);
})
.done((response: { response: http.IncomingMessage, body: string }) => {
let paymentPageUrl: string = response.body;
// expect paymentPageUrl to be a string
// expect paymentPageUrl to include https://
});
This operation assigns the given token to the transaction and process it. This method will return an URL where the customer has to be redirect to complete the transaction.
Counts the number of items in the database as restricted by the given filter.
This operation allows to get the payment method configurations which can be used with the provided transaction.
This operation removes the given token.
Creates the entity with the given properties.
POST /api/transaction/create?spaceId={YOUR_SPACE_ID} HTTP/1.1
Host: hub.emetec.net
Content-Type: application/json;charset=utf-8
X-Mac-Version: 1
X-Mac-Userid: {YOUR_USER_ID}
X-Mac-Timestamp: {UNIX_TIMESTAMP}
X-Mac-Value: {CALCULATED_MAC_VALUE}
{
"billingAddress": {
"city": "Winterthur",
"commercialRegisterNumber": "",
"country": "CH",
"dateOfBirth": "",
"emailAddress": "[email protected]",
"familyName": "Test",
"gender": "",
"givenName": "Sam",
"mobilePhoneNumber": "",
"organisationName": "Test Company Ltd",
"phoneNumber": "",
"postcode": "8400",
"salesTaxNumber": "",
"salutation": "",
"socialSecurityNumber": "",
"state": "",
"street": "Sample Street 47"
},
"currency": "EUR",
"language": "en-US",
"lineItems": [{
"amountIncludingTax": "11.87",
"name": "Sample Product",
"quantity": "1",
"shippingRequired": "true",
"sku": "sample-123",
"type": "PRODUCT",
"uniqueId": "sample-123",
"attributes": {
"test1": {
"label": "My Test Label",
"value": "Test Attribute Value"
},
"c2": {
"label": "My Test Label 2",
"value": "Test Attribute Value"
}
}
}],
"metaData": {
"sampleKey": "Some value",
"additionalDataItem": "Other value"
},
"merchantReference": "DEV-2630",
"shippingAddress": {
"city": "Winterthur",
"commercialRegisterNumber": "",
"country": "CH",
"dateOfBirth": "",
"emailAddress": "[email protected]",
"familyName": "Test",
"gender": "",
"givenName": "Sam",
"mobilePhoneNumber": "",
"organisationName": "Test Company Ltd",
"phoneNumber": "",
"postcode": "8400",
"salesTaxNumber": "",
"salutation": "",
"socialSecurityNumber": "",
"state": "",
"street": "Sample Street 47"
}
}
Reads the transaction with the given 'id' and returns it. This method uses the credentials to authenticate and identify the transaction.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Returns the packing slip for the transaction with given id.
This operation returns the token version objects which references the tokens usable as one-click payment tokens for the provided transaction.
This operation allows to get the payment method configurations which can be used with the provided transaction.
This operation allows to create transaction credentials to delegate temporarily the access to the web service API for this particular transaction.
This operation processes the transaction without requiring that the customer is present. Means this operation applies strategies to process the transaction without a direct interaction with the buyer. This operation is suitable for recurring transactions.
Exports the transactions into a CSV file. The file will contain the properties defined in the request.
Returns the PDF document for the transaction invoice with given id.
Searches for the entities as specified by the given query.
The confirm operation marks the transaction as confirmed. Once the transaction is confirmed no more changes can be applied.
POST /api/transaction/confirm?spaceId={YOUR_SPACE_ID} HTTP/1.1
Host: hub.emetec.net
Content-Type: application/json;charset=utf-8
X-Mac-Version: 1
X-Mac-Userid: {YOUR_USER_ID}
X-Mac-Timestamp: {UNIX_TIMESTAMP}
X-Mac-Value: {CALCULATED_MAC_VALUE}
{
"id": 109891
}
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
This operation voids the transaction offline. The void is not forwarded to the processor. This implies the processor does not do anything. This method is only here to fix manually the transaction state.
Reads the entity with the given 'id' and returns it.
This operation voids the transaction online. The void is forwarded to the processor. This implies that the processor may take some actions based on the void.
Reads the entity with the given 'id' and returns it.
This operation allows to update a Shopify recurring order.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Creates the entity with the given properties.
This operation allows to update a Shopify subscription addresses.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
This operation allows to terminate a Shopify subscription.
This operation allows to create a Shopify subscription.
This operation allows to update a Shopify subscription.
Counts the number of items in the database as restricted by the given filter.
This operation allows to reactivate a suspended Shopify subscription.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
This operation allows to suspend a Shopify subscription.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Counts the number of items in the database as restricted by the given filter.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Deletes the entity with the given id.
Searches for the entities as specified by the given query.
Creates the entity with the given properties.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
This operation allows to discard a scheduled charge.
The create operation creates a new subscription charge.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Deletes the entity with the given id.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
This operation creates a new metric usage report.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Deletes the entity with the given id.
Creates the entity with the given properties.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Deletes the entity with the given id.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Reads the entity with the given 'id' and returns it.
The create operation creates a new product retirement.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
The create operation creates a new product version retirement.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
Creates the entity with the given properties.
This operation activates a new product version.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
The initialize operation initializes a subscription when the subscriber is present. The method will initialize a transaction which has to be completed by using the transaction service.
Reads the entity with the given 'id' and returns it.
This operation allows to terminate a subscription.
The create operation creates a new subscription and a corresponding subscription version.
This operation allows to search for subscription invoices.
Counts the number of items in the database as restricted by the given filter.
The initialize operation initializes a subscription. This method uses charge flows to carry out the transaction.
This operation allows to update the subscription.
The update product version operation updates the product version of the subscription to the latest active product version.
This operation allows to apply changes on a subscription.
The create operation creates a new subscription suspension.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
The create operation creates a new subscription suspension.
Counts the number of items in the database as restricted by the given filter.
Searches for the entities as specified by the given query.
Reads the entity with the given 'id' and returns it.
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Counts the number of items in the database as restricted by the given filter.
The create operation creates a new subscription ledger entry.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Creates the application user with the given properties.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Counts the number of items in the database as restricted by the given filter.
Exports the human users into a CSV file. The file will contain the properties defined in the request.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Reads the entity with the given 'id' and returns it.
Creates the entity with the given properties.
This operation returns all entities which are available.
Reads the entity with the given 'id' and returns it.
List all the roles that are assigned to the given user in the given account.
This operation removes the specified user account role.
This operation grants the role to the given user with in the given account.
This operation grants the given role to the user in the given space.
This operation removes the specified user space role.
List all the roles that are assigned to the given user in the given space.
Reads the entity with the given 'id' and returns it.
Counts the number of items in the database as restricted by the given filter.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Creates the entity with the given properties.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\CreationEntityState;
use Wallee\Sdk\Model\TransactionState;
use Wallee\Sdk\Model\WebhookUrlCreate;
use Wallee\Sdk\Model\WebhookListenerCreate;
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
$apiClient = new ApiClient($userId, $secret);
$data = [
// Transaction entity id
'id' => '1472041829003',
'name' => 'Shopname::WebHook::Transaction',
'states' => [
TransactionState::DECLINE,
TransactionState::FULFILL
],
'notifyEveryChange' => false,
];
// Create webhook Url
$webHookName = 'Shopname: Webhook name';
$webHookUrl = 'https://yourdomain.com/webhook/action';
$entity = (new WebhookUrlCreate())
->setName($webHookName)
->setUrl($webHookUrl)
->setState(CreationEntityState::ACTIVE);
$webHookUrl = $apiClient->getWebhookUrlService()->create($spaceId, $entity);
// Create a transaction webhook for transactions
// Transaction state flow is documented here: https://app-wallee.com/en/doc/payment/transaction-process
$entity = (new WebhookListenerCreate())
->setName($data['name'])
->setEntity($data['id'])
->setNotifyEveryChange($data['notifyEveryChange'])
->setState(CreationEntityState::CREATE)
->setEntityStates($data['states'])
->setUrl($webhookUrl->getId());
$apiClient->getWebhookListenerService()->create($spaceId, $entity);
package com.wallee.walleesdk;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.WebhookListener;
import com.wallee.sdk.model.WebhookListenerCreate;
import com.wallee.sdk.model.WebhookUrl;
import com.wallee.sdk.model.WebhookUrlCreate;
import com.wallee.sdk.service.WebhookListenerService;
import com.wallee.sdk.service.WebhookUrlService;
import org.junit.Test;
import java.util.List;
/**
* API tests for TransactionPaymentPageService
*/
public class WebhookListenerServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private WebhookUrlService webhookUrlService;
private WebhookListenerService webhookListenerService;
// Models
private WebhookUrlCreate webhookUrlPayload;
private WebhookListenerCreate webhookListenerPayload;
public WebhookListenerServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.webhookUrlService = new WebhookUrlService(this.apiClient);
this.webhookListenerService = new WebhookListenerService(this.apiClient);
}
/**
* Get webhook url payload
*
* @return WebHookUrlCreate
*/
private WebhookUrlCreate getWebhookUrlPayload() {
if (this.webhookUrlPayload == null) {
// Web url
WebhookUrlCreate urlCreate = new WebhookUrlCreate();
urlCreate
.name("Transaction webhook url")
.url("http://transactions.callback-url.com");
this.webhookUrlPayload = urlCreate;
}
return this.webhookUrlPayload;
}
/**
* Get webhook listener payload.
* This specific example is for transactions.
* Transaction state flow is documented here: <a href="https://app-wallee.com/en/doc/payment/transaction-process">Transactions</a>
*
* @param webhookUrlId - id of an existing webhook url
* @return WebhookListener create
*/
private WebhookListenerCreate getWebhookListenerPayload(Long webhookUrlId) {
if (this.webhookListenerPayload == null) {
// Webhook listener
WebhookListenerCreate listenerCreate = new WebhookListenerCreate();
listenerCreate
.url(webhookUrlId)
// Transaction entity ID
.entity(1472041829003L)
.name("Transaction webhook listener")
.entityStates(List.of("FULFILL", "DECLINE"))
.notifyEveryChange(false);
this.webhookListenerPayload = listenerCreate;
}
return this.webhookListenerPayload;
}
/**
* create
*
*
* This operation creates a listener entity, that will listen for state changes.
*/
public void create() {
try {
final WebhookUrl webhookUrl = this.webhookUrlService.create(spaceId, getWebhookUrlPayload());
final WebhookListener webhookListener = this.webhookListenerService.create(spaceId, getWebhookListenerPayload(webhookUrl.getId()));
// expect webhookListener.getId() to not be null
} catch (Exception e) {
e.printStackTrace();
}
}
}
Reads the entity with the given 'id' and returns it.
Searches for the entities as specified by the given query.
Deletes the entity with the given id.
Counts the number of items in the database as restricted by the given filter.
Creates the entity with the given properties.
use Wallee\Sdk\ApiClient;
use Wallee\Sdk\Model\CreationEntityState;
use Wallee\Sdk\Model\WebhookUrlCreate;
$spaceId = <:YOUR_SPACE_ID>;
$userId = <:YOUR_USER_ID>;
$secret = <:YOUR_USER_SECRET>;
$apiClient = new ApiClient($userId, $secret);
// Create webhook Url
$webHookName = 'Shopname: Webhook name';
$webHookUrl = 'https://yourdomain.com/webhook/action';
$entity = (new WebhookUrlCreate())
->setName($webHookName)
->setUrl($webHookUrl)
->setState(CreationEntityState::ACTIVE);
$apiClient->getWebhookUrlService()->create($spaceId, $entity);
package com.wallee.walleesdk;
import com.wallee.sdk.ApiClient;
import com.wallee.sdk.model.WebhookUrl;
import com.wallee.sdk.model.WebhookUrlCreate;
import com.wallee.sdk.service.WebhookUrlService;
/**
* API tests for WebhookUrlService
*/
public class WebhookUrlServiceTest {
// Credentials
private Long spaceId = <:YOUR_SPACE_ID>;
private Long applicationUserId = <:YOUR_USER_ID>;
private String authenticationKey = <:YOUR_USER_SECRET>;
// Services
private ApiClient apiClient;
private WebhookUrlService webhookUrlService;
// Models
private WebhookUrlCreate webhookUrlPayload;
public WebhookUrlServiceTest() {
this.apiClient = new ApiClient(applicationUserId, authenticationKey);
this.webhookUrlService = new WebhookUrlService(this.apiClient);
}
/**
* Get webhook url payload
*
* @return WebhookUrlCreate
*/
private WebhookUrlCreate getWebhookUrlPayload() {
if (this.webhookUrlPayload == null) {
// Webhook url
WebhookUrlCreate urlCreate = new WebhookUrlCreate();
urlCreate
.name("Transaction webhook url")
.url("http://transactions.callback-url.com");
this.webhookUrlPayload = urlCreate;
}
return this.webhookUrlPayload;
}
/**
* create
*
*
* This operation creates a webhook url entity, that will be used for posting.
*/
public void create() {
try {
final WebhookUrl webhookUrl = this.webhookUrlService.create(spaceId, getWebhookUrlPayload());
// expect webhookUrl.getUrl() to be a URL beginning with https://
} catch (Exception e) {
e.printStackTrace();
}
}
}
Reads the entity with the given 'id' and returns it.
This updates the entity with the given properties. Only those properties which should be updated can be provided. The 'id' and 'version' are required to identify the entity.
The service may return complex objects those objects are defined within this section.
Models may have references between each other. A reference means an object points to another object. Depending on the reference we serialize the referenced object directly or we only serialize the primary key (long) of the referenced object. This means depending on the use case the actual object needs to be loaded with the according service. In this case we indicate this by defining the type as a long and we provide a link to the actual model we reference.
The debt collection case represents a try to collect the money from the debtor.
The debt collection case source represents the origin of the case. It allows to understand where the amount receivable is coming from.
The debt collection receipt source represents the origin of a particular part of the collected amount. It allows to understand from where the amount is coming from, e.g. if it was added manually or in some other way.
The debt collector connects to an external service to process debt collection cases and directs the debt collection process.
A condition controls under which circumstances a collector configuration is applied to a debt collection case.
The debt collector configuration defines the behavior of the collection process for a particular collector.
A document template contains the customizations for a particular document template type.
The entity property export request contains the information required to create an export of a list of entities.
The entity query allows to search for specific entities by providing filters. This is similar to a SQL query.
The query filter allows to restrict the entities which are returned.
The filter type defines how the filter is interpreted. Depending of the type different properties are relevant on the filter itself.
The 'order by' allows to order the returned entities.
An error that is returned as the result of a bad user request or a misconfiguration.
The type of Client Errors which can be returned by a service.
This error is thrown when something unexpected happens on our side.
A manual task requires the manual intervention of a human.
The manual task type indicates what kind of manual task is required to be executed by the human.
The address handling mode controls if the address is required and how it is enforced to be provided.
A condition allows you to define a criteria that a transaction must fulfill in order for a connector configuration to be considered for processing the payment.
A payment information hash is calculated based on the information entered by the user. The same input leads to the same hash. The hash is collision free.
The payment link defines an URL to automatically create transactions.
The payment method configuration builds the base to connect with different payment method connectors.
Payment processors handle the connection to third part companies (payment service providers) that technically manage payment transactions and therefore process payments.
The primary risk taker will have the main loss when one party of the contract does not fulfill the contractual duties.
The refund represents a credit back to the customer. It can be issued by the merchant or by the customer (reversal).
The tokenization mode controls how the tokenization of payment information is applied on the transaction.
The transaction invoice represents the invoice document for a particular transaction.
A Shopify Integration allows to connect a Shopify shop.
A metric represents the usage of a resource that can be measured.
The metric usage is the actual usage of a metric for a particular subscription as collected by an external application.
The product component reference links components from different product versions, which makes it possible to carry out migrations.
A subscriber represents everyone who is subscribed to a product.
The subscription change request allows to change a subscription.
The subscription charge represents a single charge carried out for a particular subscription.
The component reference configuration adjusts the product component for a particular subscription.
The subscription create request holds all the data required to create a new subscription.
The subscription ledger entry represents a single change on the subscription balance.
The subscription metric type identifies the type of the metric.
A subscription product represents a product to which a subscriber can subscribe to. A product defines how much the subscription costs and in what cycles the subscribe is charged.
The confirmation response provides details about the installation of the web app.
The webhook encryption public key is used to verify the webhook content signature.
The webhook identity represents a set of keys that will be used to sign the webhook messages.