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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ All notable changes to this project will be documented in this file.
:warning: **BREAKING:** Changed SIPS platform URLs

### Changed
- Bumped interface version to 21R1 (IR_WS_2.35)
- Bumped interface version to 21R1 (IR_WS_2.46)

### Upgraded
- Update fasterxml/jackson to 2.12.1
Expand Down
63 changes: 51 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ This package provides a JAVA implementation for SIPS, a Worldline e-payments gat
> :warning: This library was written for SIPS 2.0 and is not compatible with SIPS 1.0

## Before you begin
This package contains a basic connector for SIPS, based on the **SIPS Paypage JSON API**.
This package contains a basic connector for SIPS, based on the **SIPS Paypage JSON API** and a very basic but extendable connector to the **SIPS Office JSON API**.
Please refer to the [documentation](https://documentation.sips.worldline.com) for a better understanding.

If you find field or functionality is missing, feel free to submit a PR or create an issue.

## Installing
## Payage API

### using Gradle
### Installing

#### using Gradle
```groovy

dependencies {
Expand All @@ -20,7 +22,7 @@ dependencies {

```

### using Maven
#### using Maven
```xml
<dependency>
<groupId>com.worldline.sips</groupId>
Expand All @@ -29,14 +31,14 @@ dependencies {
</dependency>
```

## Usage
### Usage
> :bulb: Currently this library only supports SIPS in pay page mode.

### Initialization
#### Initialization
First, create a client for the desired environment using your merchant ID, key version & secret key:
```java
PaypageClient paypageClient = new PaypageClient(
Environment.TEST,
SipsClient paypageClient = new SipsClient(
PaymentEnvironment.TEST,
"002001000000002",
1, // This shouldn't be hardcoded here...
"002001000000002_KEY1"); // ...and neither should this.
Expand All @@ -59,14 +61,14 @@ paymentRequest.setTransactionReference("My awesome transaction reference");

And initialize your session on the server:
```java
InitalizationResponse initializationResponse = paypageClient.initialize(paymentRequest);
InitalizationResponse initializationResponse = paypageClient.send(paymentRequest);
```

The `initializationResponse` you'll receive from the server contains all information needed to continue
handling your transaction. If your initialization was successful, your response will contain a
`RedirectionStatusCode.TRANSACTION_INITIALIZED`.

### Making the payment
#### Making the payment
In case your initialization was successful, you have to use the `redirectionUrl` received to perform a POST request
with both the `redirectionData` and `seal` as parameters. Since this should redirect the customer the SIPS
payment page, the cleanest example is a simple HTML form:
Expand All @@ -79,16 +81,53 @@ payment page, the cleanest example is a simple HTML form:
</form>
```

### Verifying the payment
#### Verifying the payment
When your customer is done, he will be able to return to your application. This is done
via a form, making a POST request to the `normalReturnUrl` provided during the initialization of your payment.
This POST request contains details on the payment. You can simply decode these responses, providing a `Map<String, String>`
of the parameters included in the received request to your `PaypageClient`:

```java
PaypageResponse paypageResponse = paypageClient.decodeResponse(mappedRequestParameters);
PaypageResponse paypageResponse = paypageClient.decodeResponse(PaypageResponse.class, mappedRequestParameters);
```

Alternatively if you don't have a client object when you need to verify the response, you can use the static method
of the SipsClient class (in this case you will have to provide your secret key):

```java
PaypageResponse paypageResponse = SipsClient.decodeResponse(PaypageResponse.class, mappedRequestParameters, sipsSecretKey)
```

> :warning: Since the customer is not always redirecting back (e.g. he closes the confirmation page), it's
a good practice to include an `automaticResponseUrl`. SIPS will always POST details on the transaction on this URL,
even if a customer doesn't redirect back to your application.

## Office API

### Installing

#### using Gradle
```groovy

dependencies {
implementation 'com.worldline.sips:office-sdk:1.4.3'
}

```

#### using Maven
```xml
<dependency>
<groupId>com.worldline.sips</groupId>
<artifactId>office-sdk</artifactId>
<version>1.4.3</version>
</dependency>
```
### Usage

The usage for sips office is the same as the payment API : create a SipsClient and send requests.

Example with the getWalletData call :
````java
GetWalletDataResponse response = sipsClient.send(new GetWalletDataRequest(merchantWalletId));
````
19 changes: 11 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ allprojects {
sourceCompatibility = 1.8

group 'com.worldline.sips'
version '1.4.4-SNAPSHOT'
version '1.4.5-SNAPSHOT'

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
Expand Down Expand Up @@ -59,18 +59,21 @@ allprojects {
}
repositories {
maven {
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def releasesRepoUrl = "https://nexus.kazan.myworldline.com/repository/rcs-store-releases"
def snapshotsRepoUrl = "https://nexus.kazan.myworldline.com/repository/rcs-store-snapshots"

url = project.hasProperty('release') ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username sonatypeUsername
password sonatypePassword
username= findProperty('nexusRepoUser')
password= findProperty('nexusRepoPass')
}
}
}
}

signing {
sign publishing.publications.maven
}
//
// signing {
// sign publishing.publications.maven
// }

javadoc {
if (JavaVersion.current().isJava9Compatible()) {
Expand Down
6 changes: 6 additions & 0 deletions office-sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
implementation project(':sdk-common')
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.1.2'
}
18 changes: 18 additions & 0 deletions office-sdk/src/main/java/com/worldline/sips/api/WalletRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.worldline.sips.api;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.worldline.sips.SIPSRequest;
import com.worldline.sips.api.configuration.OfficeConfiguration;

public abstract class WalletRequest<R extends WalletResponse> extends SIPSRequest<R> {
private static final String INTERFACE_VERSION = OfficeConfiguration.INTERFACE_VERSION;

public WalletRequest(String endpoint) {
super("wallet/" + endpoint);
}

@JsonInclude
public String getInterfaceVersion() {
return INTERFACE_VERSION;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.worldline.sips.api;

import com.worldline.sips.SIPSResponse;
import com.worldline.sips.api.model.data.NamedWalletResponseCode;
import com.worldline.sips.api.model.data.WalletResponseCode;


public abstract class WalletResponse extends SIPSResponse {

private String errorFieldName;
private WalletResponseCode walletResponseCode;

/**
* Available if walletResponseCode is {@link NamedWalletResponseCode#FORMAT_ERROR} or
* {@link NamedWalletResponseCode#INVALID_DATA}
* @return the error
*/
public String getErrorFieldName() {
return errorFieldName;
}

public WalletResponseCode getWalletResponseCode() {
return walletResponseCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.worldline.sips.api.configuration;

/**
* Container for global configuration values
*/
public class OfficeConfiguration {
/**
* The targeted version of the API
*/
public static final String INTERFACE_VERSION = "WR_WS_2.42";

private OfficeConfiguration() {
// Nothing to see here
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.worldline.sips.api.configuration;

import com.worldline.sips.model.SipsEnvironment;

import java.net.URI;

public enum OfficeEnvironment implements SipsEnvironment {
TEST("https://office-server.test.sips-services.com"),
PROD("https://office-server.sips-services.com");

private final String url;
private final URI uri;

OfficeEnvironment(String url) {
this.url = url + "/rs-services/v2";
this.uri = URI.create(url);
}

public String getUrl() {
return url;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.worldline.sips.api.model.data;

import com.fasterxml.jackson.annotation.JsonValue;

public enum NamedWalletResponseCode implements WalletResponseCode {
/**
* Successful operation
*/
SUCCESS("00"),
/**
* Invalid Merchant contract
*/
INVALID_MERCHANT("03"),
/**
* Invalid data, verify the request
*/
INVALID_DATA("12"),
/**
* Wallet / payment mean unknown by WL Sips
*/
UNKNOWN_WALLET("25"),
FORMAT_ERROR("30"),

FRAUD_SUSPECTED("34"),
/**
* MerchantId not allowed to access this wallet service
*/
NOT_ALLOWED("40"),
/**
* Duplicated wallet / payment mean
*/
ALREADY_PRESENT("94"),
/**
* Temporary problem at the WL Sips server level
*/
INTERNAL_TEMPORARY_PROBLEM("99");

private final String code;

NamedWalletResponseCode(String code) {
this.code = code;
}

@Override
@JsonValue
public String getCode() {
return code;
}

@Override
public String toString() {
return code;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.worldline.sips.api.model.data;

import com.fasterxml.jackson.annotation.JsonValue;

public class UnknownResponseCode implements WalletResponseCode {

private final String responseCode;

public UnknownResponseCode(String responseCode) {
this.responseCode = responseCode;
}

@Override
@JsonValue
public String getCode() {
return responseCode;
}

@Override
public String toString() {
return responseCode;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.worldline.sips.api.model.data;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.worldline.sips.model.PaymentMeanBrand;
import java.time.YearMonth;

@JsonIgnoreProperties(ignoreUnknown = true)
public class WalletPaymentMeanData {
private String paymentMeanData;
private String paymentMeanId;
private String maskedPan;
private YearMonth panExpiryDate;
private String paymentMeanAlias;
private PaymentMeanBrand paymentMeanBrand;
private String[] paymentMeanCoBadgingBrandList;
private String[] transactionActors;

public String getPaymentMeanId() {
return paymentMeanId;
}

public String getMaskedPan() {
return maskedPan;
}

public YearMonth getPanExpiryDate() {
return panExpiryDate;
}

public String getPaymentMeanAlias() {
return paymentMeanAlias;
}

public PaymentMeanBrand getPaymentMeanBrand() {
return paymentMeanBrand;
}

public String[] getPaymentMeanCoBadgingBrandList() {
return paymentMeanCoBadgingBrandList;
}

public String getPaymentMeanData() {
return paymentMeanData;
}

public String[] getTransactionActors() {
return transactionActors;
}

}
Loading