|
| 1 | +package net.authorize.sample; |
| 2 | + |
| 3 | +import java.io.BufferedReader; |
| 4 | +import java.io.IOException; |
| 5 | +import java.io.InputStreamReader; |
| 6 | + |
| 7 | +import net.authorize.sample.VisaCheckout.*; |
| 8 | +import net.authorize.sample.PaymentTransactions.*; |
| 9 | + |
| 10 | +/** |
| 11 | + * Created by anetdeveloper on 8/5/15. |
| 12 | + */ |
| 13 | +public class SampleCode { |
| 14 | + |
| 15 | + public static void main( String[] args ) |
| 16 | + { |
| 17 | + System.out.println( "Hello World!" ); |
| 18 | + |
| 19 | + if (args.length == 0) |
| 20 | + { |
| 21 | + SelectMethod(); |
| 22 | + } |
| 23 | + else if (args.length == 1) |
| 24 | + { |
| 25 | + RunMethod(args[0]); |
| 26 | + return; |
| 27 | + } |
| 28 | + else |
| 29 | + { |
| 30 | + ShowUsage(); |
| 31 | + } |
| 32 | + |
| 33 | + System.out.println(""); |
| 34 | + System.out.print("Press <Return> to finish ..."); |
| 35 | + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 36 | + try{ |
| 37 | + int i = Integer.parseInt(br.readLine()); |
| 38 | + }catch(Exception ex){ |
| 39 | + } |
| 40 | + |
| 41 | + } |
| 42 | + |
| 43 | + private static void ShowUsage() |
| 44 | + { |
| 45 | + System.out.println("Usage : java -jar SampleCode.jar [CodeSampleName]"); |
| 46 | + System.out.println(""); |
| 47 | + System.out.println("Run with no parameter to select a method. Otherwise pass a method name."); |
| 48 | + System.out.println(""); |
| 49 | + System.out.println("Code Sample Names: "); |
| 50 | + ShowMethods(); |
| 51 | + |
| 52 | + |
| 53 | + } |
| 54 | + |
| 55 | + private static void SelectMethod() |
| 56 | + { |
| 57 | + System.out.println("Code Sample Names: "); |
| 58 | + System.out.println(""); |
| 59 | + ShowMethods(); |
| 60 | + System.out.println(""); |
| 61 | + System.out.print("Type a sample name & then press <Return> : "); |
| 62 | + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); |
| 63 | + try{ |
| 64 | + RunMethod(br.readLine()); |
| 65 | + }catch(Exception ex){ |
| 66 | + System.out.print("Error no such method"); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + private static void ShowMethods() |
| 71 | + { |
| 72 | + System.out.println(" VisaCheckoutDecrypt"); |
| 73 | + System.out.println(" VisaCheckoutTransaction"); |
| 74 | + System.out.println(" ChargeCreditCard"); |
| 75 | + } |
| 76 | + |
| 77 | + private static void RunMethod(String methodName) |
| 78 | + { |
| 79 | + // These are default transaction keys. |
| 80 | + // You can create your own keys in seconds by signing up for a sandbox account here: https://developer.authorize.net/sandbox/ |
| 81 | + String apiLoginId = "5KP3u95bQpv"; |
| 82 | + String transactionKey = "4Ktq966gC55GAX7S"; |
| 83 | + |
| 84 | + |
| 85 | + switch (methodName) { |
| 86 | + case "VisaCheckoutDecrypt": |
| 87 | + VisaCheckoutDecrypt.run(apiLoginId, transactionKey); |
| 88 | + |
| 89 | + break; |
| 90 | + case "VisaCheckoutTransaction": |
| 91 | + VisaCheckoutTransaction.run(apiLoginId, transactionKey); |
| 92 | + break; |
| 93 | + case "ChargeCreditCard": |
| 94 | + ChargeCreditCard.run(apiLoginId, transactionKey); |
| 95 | + break; |
| 96 | + |
| 97 | + default: |
| 98 | + ShowUsage(); |
| 99 | + break; |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | +} |
0 commit comments