Skip to content

Commit 0a3d5b6

Browse files
authored
Merge pull request #14 from bprokopc/master
Use Flex Web Client SDK
2 parents db1e982 + 6c5dbf8 commit 0a3d5b6

6 files changed

Lines changed: 182 additions & 293 deletions

File tree

java/flex-sdk-spring-boot/pom.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@
5353
<dependency>
5454
<groupId>com.cybersource</groupId>
5555
<artifactId>flex-server-sdk</artifactId>
56-
<version>0.1.0</version>
56+
<version>0.1.1</version>
57+
</dependency>
58+
59+
<!-- Flex Web SDK -->
60+
<dependency>
61+
<groupId>org.webjars.npm</groupId>
62+
<artifactId>cybersource__flex-sdk-web</artifactId>
63+
<version>0.1.2</version>
5764
</dependency>
5865
</dependencies>
59-
</project>
66+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright (c) 2017 by CyberSource
3+
* Governing licence: https://github.com/CyberSource/cybersource-flex-samples/blob/master/LICENSE.md
4+
*/
5+
package com.cybersource.flex.application;
6+
7+
import com.cybersource.flex.sdk.FlexService;
8+
import com.cybersource.flex.sdk.FlexServiceFactory;
9+
import com.cybersource.flex.sdk.authentication.CGKCredentials;
10+
import com.cybersource.flex.sdk.exception.FlexException;
11+
import org.springframework.beans.factory.annotation.Value;
12+
import org.springframework.context.annotation.Bean;
13+
import org.springframework.context.annotation.Configuration;
14+
15+
@Configuration
16+
public class FlexConfigurationCGK {
17+
18+
@Value("${cgk.mid}")
19+
private String mid;
20+
@Value("${cgk.keyId}")
21+
private String keyId;
22+
@Value("${cgk.shared-secret}")
23+
private char[] sharedSecret;
24+
25+
@Bean
26+
public FlexService flexService() {
27+
try {
28+
CGKCredentials cgkCredentials = new CGKCredentials(CGKCredentials.Environment.CAS, mid, keyId, sharedSecret);
29+
return FlexServiceFactory.createInstance(cgkCredentials);
30+
} catch (FlexException flexException) {
31+
throw new RuntimeException("Error when configuring Flex Server SDK", flexException);
32+
}
33+
}
34+
35+
}

java/flex-sdk-spring-boot/src/main/java/com/cybersource/flex/application/FlexConfiguration.java renamed to java/flex-sdk-spring-boot/src/main/java/com/cybersource/flex/application/FlexConfigurationVDP.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
package com.cybersource.flex.application;
66

77
import com.cybersource.flex.sdk.FlexService;
8+
import com.cybersource.flex.sdk.FlexServiceFactory;
89
import com.cybersource.flex.sdk.authentication.VDPCredentials;
9-
import com.cybersource.flex.sdk.impl.FlexKeyServiceImpl;
1010
import org.springframework.beans.factory.annotation.Value;
1111
import org.springframework.context.annotation.Bean;
1212
import org.springframework.context.annotation.Configuration;
1313

14-
@Configuration
15-
public class FlexConfiguration {
14+
/**
15+
* Please uncomment Configuration annotation below to enable Visa Developer
16+
* Platform. You must also comment out Configuration annotation in corresponding
17+
* FlexConfigurationVDP.java to disable CGK.
18+
*/
19+
//@Configuration
20+
public class FlexConfigurationVDP {
1621

1722
@Value("${vdp.api-key}")
1823
private String apiKey;
@@ -22,7 +27,7 @@ public class FlexConfiguration {
2227
@Bean
2328
public FlexService flexService() {
2429
VDPCredentials vdpCredentials = new VDPCredentials(VDPCredentials.Environment.SANDBOX, apiKey, sharedSecret);
25-
return new FlexKeyServiceImpl(vdpCredentials);
30+
return FlexServiceFactory.createInstance(vdpCredentials);
2631
}
2732

2833
}

java/flex-sdk-spring-boot/src/main/resources/application.properties

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
# VISA Developer Platform credentials - https://developer.visa.com/
1+
# Cybersource GateKeeper credentials - https://developer.cybersource.com/
22
#
33
# This property file is for demonstartion purposes only.
44
# You MUST take proper precautions to protect your credentials, such as
55
# NEVER storing your credentials unencrypted with application code.
66
#
7-
vdp.api-key=_YOUR_APPLICATION_SPECIFIC_API_KEY_
8-
vdp.shared-secret=_YOUR_APPLICATION_SPECIFIC_SHARED_SECRET_
7+
cgk.mid=_YOUR_MID_
8+
cgk.keyId=_YOUR_HMAC_KEY_ID_
9+
cgk.shared-secret=_YOUR_SHARED_SECRET_
10+
11+
# VISA Developer Platform credentials - https://developer.visa.com/
12+
# To use the VDP you need to disable CGK properties above and edit FlexConfigurationVDP.java
13+
#vdp.api-key=_YOUR_APPLICATION_SPECIFIC_API_KEY_
14+
#vdp.shared-secret=_YOUR_APPLICATION_SPECIFIC_SHARED_SECRET_
915

1016
# Embedded Tomcat configuration properties
1117
#

java/flex-sdk-spring-boot/src/main/resources/public/flex.js

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)