-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #104 from CyberSource/feature/new-samples
Update Sample codes for Flex microform in GitHub
- Loading branch information
Showing
6 changed files
with
412 additions
and
85 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/main/java/samples/FlexMicroform/GenerateCaptureContextAcceptCard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package samples.FlexMicroform; | ||
|
||
import java.util.*; | ||
import com.cybersource.authsdk.core.MerchantConfig; | ||
import Api.*; | ||
import Data.Configuration; | ||
import Invokers.ApiClient; | ||
import Model.*; | ||
|
||
public class GenerateCaptureContextAcceptCard { | ||
private static String responseCode = null; | ||
private static String status = null; | ||
private static Properties merchantProp; | ||
|
||
public static void main(String args[]) throws Exception { | ||
run(); | ||
} | ||
|
||
public static void run() { | ||
|
||
GenerateCaptureContextRequest requestObj = new GenerateCaptureContextRequest(); | ||
|
||
requestObj.clientVersion("v2"); | ||
|
||
List <String> targetOrigins = new ArrayList <String>(); | ||
targetOrigins.add("https://www.test.com"); | ||
requestObj.targetOrigins(targetOrigins); | ||
|
||
List <String> allowedCardNetworks = new ArrayList <String>(); | ||
allowedCardNetworks.add("VISA"); | ||
allowedCardNetworks.add("MASTERCARD"); | ||
allowedCardNetworks.add("AMEX"); | ||
allowedCardNetworks.add("CARNET"); | ||
allowedCardNetworks.add("CARTESBANCAIRES"); | ||
allowedCardNetworks.add("CUP"); | ||
allowedCardNetworks.add("DINERSCLUB"); | ||
allowedCardNetworks.add("DISCOVER"); | ||
allowedCardNetworks.add("EFTPOS"); | ||
allowedCardNetworks.add("ELO"); | ||
allowedCardNetworks.add("JCB"); | ||
allowedCardNetworks.add("JCREW"); | ||
allowedCardNetworks.add("MADA"); | ||
allowedCardNetworks.add("MAESTRO"); | ||
allowedCardNetworks.add("MEEZA"); | ||
requestObj.allowedCardNetworks(allowedCardNetworks); | ||
|
||
List<String> allowedPaymentTypes = new ArrayList<String>(); | ||
allowedPaymentTypes.add("CARD"); | ||
requestObj.allowedPaymentTypes(allowedPaymentTypes); | ||
|
||
try { | ||
merchantProp = Configuration.getMerchantDetails(); | ||
ApiClient apiClient = new ApiClient(); | ||
MerchantConfig merchantConfig = new MerchantConfig(merchantProp); | ||
apiClient.merchantConfig = merchantConfig; | ||
|
||
MicroformIntegrationApi apiInstance = new MicroformIntegrationApi(apiClient); | ||
String response = apiInstance.generateCaptureContext(requestObj); | ||
|
||
responseCode = apiClient.responseCode; | ||
status = apiClient.status; | ||
System.out.println("ResponseCode :" + responseCode); | ||
System.out.println("ResponseMessage :" + status); | ||
System.out.println("Response Body :" + response); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/samples/FlexMicroform/GenerateCaptureContextAcceptCheck.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package samples.FlexMicroform; | ||
|
||
import java.util.*; | ||
import com.cybersource.authsdk.core.MerchantConfig; | ||
import Api.*; | ||
import Data.Configuration; | ||
import Invokers.ApiClient; | ||
import Model.*; | ||
|
||
public class GenerateCaptureContextAcceptCheck { | ||
private static String responseCode = null; | ||
private static String status = null; | ||
private static Properties merchantProp; | ||
|
||
public static void main(String args[]) throws Exception { | ||
run(); | ||
} | ||
|
||
public static void run() { | ||
|
||
GenerateCaptureContextRequest requestObj = new GenerateCaptureContextRequest(); | ||
|
||
requestObj.clientVersion("v2"); | ||
|
||
List <String> targetOrigins = new ArrayList <String>(); | ||
targetOrigins.add("https://www.test.com"); | ||
requestObj.targetOrigins(targetOrigins); | ||
|
||
List<String> allowedPaymentTypes = new ArrayList<String>(); | ||
allowedPaymentTypes.add("CHECK"); | ||
requestObj.allowedPaymentTypes(allowedPaymentTypes); | ||
|
||
try { | ||
merchantProp = Configuration.getMerchantDetails(); | ||
ApiClient apiClient = new ApiClient(); | ||
MerchantConfig merchantConfig = new MerchantConfig(merchantProp); | ||
apiClient.merchantConfig = merchantConfig; | ||
|
||
MicroformIntegrationApi apiInstance = new MicroformIntegrationApi(apiClient); | ||
String response = apiInstance.generateCaptureContext(requestObj); | ||
|
||
responseCode = apiClient.responseCode; | ||
status = apiClient.status; | ||
System.out.println("ResponseCode :" + responseCode); | ||
System.out.println("ResponseMessage :" + status); | ||
System.out.println("Response Body :" + response); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
63 changes: 0 additions & 63 deletions
63
src/main/java/samples/FlexMicroform/GenerateCaptureContextWithCheckoutAPI.java
This file was deleted.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
src/main/java/samples/UnifiedCheckout/GenerateCaptureContextForClickToPayDropInUI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package samples.UnifiedCheckout; | ||
|
||
import java.util.*; | ||
import com.cybersource.authsdk.core.MerchantConfig; | ||
import Api.*; | ||
import Data.Configuration; | ||
import Invokers.ApiClient; | ||
import Model.*; | ||
|
||
public class GenerateCaptureContextForClickToPayDropInUI { | ||
private static String responseCode = null; | ||
private static String status = null; | ||
private static Properties merchantProp; | ||
|
||
public static void main(String args[]) throws Exception { | ||
run(); | ||
} | ||
|
||
public static void run() { | ||
|
||
GenerateUnifiedCheckoutCaptureContextRequest requestObj = new GenerateUnifiedCheckoutCaptureContextRequest(); | ||
|
||
requestObj.clientVersion("0.23"); | ||
|
||
List <String> targetOrigins = new ArrayList <String>(); | ||
targetOrigins.add("https://yourCheckoutPage.com"); | ||
requestObj.targetOrigins(targetOrigins); | ||
|
||
|
||
List <String> allowedCardNetworks = new ArrayList <String>(); | ||
allowedCardNetworks.add("VISA"); | ||
allowedCardNetworks.add("MASTERCARD"); | ||
allowedCardNetworks.add("AMEX"); | ||
allowedCardNetworks.add("CARNET"); | ||
allowedCardNetworks.add("CARTESBANCAIRES"); | ||
allowedCardNetworks.add("CUP"); | ||
allowedCardNetworks.add("DINERSCLUB"); | ||
allowedCardNetworks.add("DISCOVER"); | ||
allowedCardNetworks.add("EFTPOS"); | ||
allowedCardNetworks.add("ELO"); | ||
allowedCardNetworks.add("JCB"); | ||
allowedCardNetworks.add("JCREW"); | ||
allowedCardNetworks.add("MADA"); | ||
allowedCardNetworks.add("MAESTRO"); | ||
allowedCardNetworks.add("MEEZA"); | ||
requestObj.allowedCardNetworks(allowedCardNetworks); | ||
|
||
|
||
List <String> allowedPaymentTypes = new ArrayList <String>(); | ||
allowedPaymentTypes.add("CLICKTOPAY"); | ||
requestObj.allowedPaymentTypes(allowedPaymentTypes); | ||
|
||
requestObj.country("US"); | ||
requestObj.locale("en_US"); | ||
Upv1capturecontextsCaptureMandate captureMandate = new Upv1capturecontextsCaptureMandate(); | ||
captureMandate.billingType("FULL"); | ||
captureMandate.requestEmail(true); | ||
captureMandate.requestPhone(true); | ||
captureMandate.requestShipping(true); | ||
|
||
List <String> shipToCountries = new ArrayList <String>(); | ||
shipToCountries.add("US"); | ||
shipToCountries.add("GB"); | ||
captureMandate.shipToCountries(shipToCountries); | ||
|
||
captureMandate.showAcceptedNetworkIcons(true); | ||
requestObj.captureMandate(captureMandate); | ||
|
||
Upv1capturecontextsOrderInformation orderInformation = new Upv1capturecontextsOrderInformation(); | ||
Upv1capturecontextsOrderInformationAmountDetails orderInformationAmountDetails = new Upv1capturecontextsOrderInformationAmountDetails(); | ||
orderInformationAmountDetails.totalAmount("21.00"); | ||
orderInformationAmountDetails.currency("USD"); | ||
orderInformation.amountDetails(orderInformationAmountDetails); | ||
|
||
requestObj.orderInformation(orderInformation); | ||
|
||
try { | ||
merchantProp = Configuration.getMerchantDetails(); | ||
ApiClient apiClient = new ApiClient(); | ||
MerchantConfig merchantConfig = new MerchantConfig(merchantProp); | ||
apiClient.merchantConfig = merchantConfig; | ||
|
||
UnifiedCheckoutCaptureContextApi apiInstance = new UnifiedCheckoutCaptureContextApi(apiClient); | ||
String response = apiInstance.generateUnifiedCheckoutCaptureContext(requestObj); | ||
|
||
responseCode = apiClient.responseCode; | ||
status = apiClient.status; | ||
System.out.println("ResponseCode :" + responseCode); | ||
System.out.println("ResponseMessage :" + status); | ||
System.out.println("Response Body :" + response); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.