Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker/Docker-compose support #27

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
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
80 changes: 61 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,82 @@
## Flex Token API
# CyberSource Flex Samples (Java)

### Introduction
This repository provides simple examples demonstrating usage of the CyberSource Flex SDK using either a headless JavaScript call (jsp-flexjs) or a fully customizable hosted field/microform which is incorporated into your checkout page. For more details on Secure Acceptance Flex visit our Developer Guide at https://developer.cybersource.com/api/developer-guides/dita-flex/SAFlexibleToken.html

Storing your customer’s card data can dramatically increase your repeat-custom conversion rate, but can also add additional risk and [PCI DSS](https://www.pcisecuritystandards.org/pci_security/) overhead. You can mitigate these costs by tokenizing card data. CyberSource will store your customer’s card data within secure Visa data centers, replacing it with a token that only you can use.
## Usage

Secure Acceptance Flexible Token is a secure method for Tokenizing card data, that leaves you in total control of the customer experience. Your customer’s card number is encrypted on their own device, for example inside a browser or native app, and sent directly to CyberSource. This means card data bypasses your systems altogether. This can help you qualify for [SAQ A](https://www.pcisecuritystandards.org/documents/Understanding_SAQs_PCI_DSS_v3.pdf) based PCI DSS assessments for web based integrations, and [SAQ A-EP](https://www.pcisecuritystandards.org/documents/Understanding_SAQs_PCI_DSS_v3.pdf) for native app integrations.
1. Clone or download this repository.
2. Update webapp/WEB-INF/credentials.properties with your [CyberSource sandbox credentials](https://ebc2test.cybersource.com).
3. Run ```mvn package``` in the sample you want to try (jsp-microform or jsp-flexjs).
4. Copy the output WAR file to your web server directory.

You are in total control of the look and feel, with the ability to seamlessly blend the solution in to your existing checkout flow, on web or in-app.
## Requirements
* Java 1.8 or later
* Tomcat web server

On-device encryption helps to protect your customers from attacks on network middleware such as app accelerators, DLPs, CDNs, and malicious hotspots.
**_NOTE: We also have samples for Flex available in .NET, PHP & Node.js _**


## Run with Docker
1. Clone or download this repository.
2. Update src/main/webapp/WEB-INF/credentials.properties with your [CyberSource sandbox credentials](https://ebc2test.cybersource.com).
3. Run ```docker-compose run jsp-microform-build``` and/or ```docker-compose run jsp-flexjs-build```
4. Run ```docker-compose up web``` and access http://localhost:8080/flexjs and/or http://localhost:8080/microform

The token can be used in lieu of actual card data in server-side requests for other CyberSource services, such as [Payer Authentication](http://apps.cybersource.com/library/documentation/dev_guides/Payer_Authentication_SO_API/Payer_Authentication_SO_API.pdf), [Decision Manager](https://www.cybersource.com/products/fraud_management/), [Tax Services](http://apps.cybersource.com/library/documentation/dev_guides/Tax_SO_API/Tax_SO_API.pdf), and [Card Payments](http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/Credit_Cards_SO_API.pdf).
## API Reference
While these examples use the JavaScript libraries which we recommend as the most convenient option, you can try out the APIs behind the JavaScript SDKs by visiting our API Reference at https://developer.cybersource.com/api/reference/api-reference.html

Secure Acceptance Flexible Token is a JSON based RESTful service, consisting of two resources: **keys** and **tokens**.
## Background on PCI-DSS

#### Keys
Storing your customer’s card data can dramatically increase your repeat-customer conversion rate, but can also add additional risk and [PCI DSS](https://www.pcisecuritystandards.org/pci_security/) overhead. You can mitigate these costs by tokenizing card data. CyberSource will store your customer’s card data within secure Visa data centers, replacing it with a token that only you can use.

Create a transaction specific public key to encrypt the card data on your customer's device (a browser or a native app). This is an authenticated request from your server to CyberSource, when rendering your payment form or control.
Secure Acceptance Flexible Token is a secure method for Tokenizing card data, that leaves you in total control of the customer experience. Your customer’s card number is encrypted on their own device - for example inside a browser or native app - and sent directly to CyberSource. This means card data bypasses your systems altogether. This can help you qualify for [SAQ A](https://www.pcisecuritystandards.org/documents/Understanding_SAQs_PCI_DSS_v3.pdf) based PCI DSS assessments for web-based integrations, and [SAQ A-EP](https://www.pcisecuritystandards.org/documents/Understanding_SAQs_PCI_DSS_v3.pdf) for native app integrations.

You are in total control of the look and feel, with the ability to seamlessly blend the solution in to your existing checkout flow, on web or in-app.

On-device encryption helps to protect your customers from attacks on network middleware such as app accelerators, DLPs, CDNs, and malicious hotspots.

We provide a [Java SDK](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.cybersource%22%20AND%20a%3A%22flex-server-sdk%22) to simplify this, or you [call the Flexible Token API directly](http://apps.cybersource.com/library/documentation/dev_guides/hosted_flex/0_2_0/html/custom-server-integration/). SDKs for other languages will be available in future.
The token can be used in lieu of actual card data in server-side requests for other CyberSource services, for example to make a payment, using our REST APIs: https://developer.cybersource.com/api/reference/api-reference.html

## Samples

#### Tokens
### JavaScript (Flex API) Sample

Create a token using the encrypted card data.
This sample demonstrates how your checkout form can remain exactly as it is today, with the only addition of a JavaScript call to tokenize the customer's credit card information. This happens directly between their browser and CyberSource, replacing the provided data with a secure PCI-compliant token. This can then be sent to your server along with the other non-PCI order data. This can help achieve PCI-DSS SAQ A-EP level compliance for your application.

For web based solutions use our Hosted JS library to replace the card number input field with a CyberSource ‘microform’ iframe. This microform can be styled to look and behave like a regular input field on your site, using CSS and event listeners.
### Microform Sample

For native application or IoT integrations, use the API integration. Encrypt the card number using the public key, and send as an unauthenticated request from your customer's device directly to CyberSource.
This sample demonstrates how you can replace the sensitive data fields (credit card number) on your checkout form with a field (Flex Microform) hosted entirely on CyberSource servers. This field will accept and tokenize the customer's credit card information directly from their browser on a resource hosted by CyberSource, replacing that data with a secure PCI-compliant token. This can then be sent to your server along with the other non-PCI order data. This can help achieve PCI-DSS SAQ A level compliance for your application as even your client-side code does not contain a mechanism to handle the credit card information.

The resulting token can be verified server side using the public key. Our [Java SDK](https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.cybersource%22%20AND%20a%3A%22flex-server-sdk%22) can be used to perform this function.
## Using the Flex Payment Token

You can use the token generated to make a payment with the CyberSource REST API (https://developer.cybersource.com/api/reference/api-reference.html).

### Examples
Place the token in the CustomerId field:

These repositories consist of sample web implementations in [Java](https://github.com/CyberSource/cybersource-flex-samples/blob/master/java), using [Spring Boot](https://github.com/CyberSource/cybersource-flex-samples/tree/master/java8/flex-sdk-spring-boot) (Flex API) and [JSP](https://github.com/CyberSource/cybersource-flex-samples/tree/master/java8/jsp-microform) (Hosted). The SDK supports Java 7 and 8, for earlier versions see the "nosdk" examples. Further examples in other languages will be added in future.
```json
{
"clientReferenceInformation": {
"code": "TC50171_3"
},
"processingInformation": {
"commerceIndicator": "internet"
},
"paymentInformation": {
"customer": {
"customerId": "7500BB199B4270EFE05340588D0AFCAD"
}
},
"orderInformation": {
"amountDetails": {
"totalAmount": "22",
"currency": "USD"
},
"billTo": {
"firstName": "John",
"lastName": "Doe"
}
}
}

The examples consist of a basic server that requests the keys and serves a front end that collects, encrypts and transmits the card data directly to CyberSource. Please ensure you read [our license](https://github.com/CyberSource/cybersource-flex-samples/blob/master/LICENSE.md) prior to making use of the provided code.
```

32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '2'
services:
web:
image: tomcat
ports:
- "8080:8080"
volumes:
- ./jsp-microform/target/jsp-microform-1.0.war:/usr/local/tomcat/webapps/microform.war
- ./jsp-microform/target/jsp-microform-1.0:/usr/local/tomcat/webapps/microform
- ./jsp-flexjs/target/jsp-flexjs-1.0.war:/usr/local/tomcat/webapps/flexjs.war
- ./jsp-flexjs/target/jsp-flexjs-1.0:/usr/local/tomcat/webapps/flexjs

jsp-flexjs-build:
image: maven
volumes:
- ./jsp-flexjs/:/project
- m2repo:/root/.m2
working_dir: /project
entrypoint: mvn
command: clean package

jsp-microform-build:
image: maven
volumes:
- ./jsp-microform/:/project
- m2repo:/root/.m2
working_dir: /project
entrypoint: mvn
command: clean package

volumes:
m2repo:
10 changes: 0 additions & 10 deletions java8/README.md

This file was deleted.

42 changes: 0 additions & 42 deletions java8/flex-sdk-spring-boot/.gitignore

This file was deleted.

45 changes: 0 additions & 45 deletions java8/flex-sdk-spring-boot/README.md

This file was deleted.

66 changes: 0 additions & 66 deletions java8/flex-sdk-spring-boot/pom.xml

This file was deleted.

This file was deleted.

Loading