static void Main(string[] args) { Console.WriteLine("Select the transaction type:\n" + "1: Auth \n" + "2: Auth Reversal\n" + "3: EMV Auth\n" + "4: Level2 capture\n" + "5: Payment Network Tokenization\n" + "6: Refund Request\n" + "7: Visa Checkout Auth\n" + "8: Android Pay Auth\n" + "9: Apple Pay Auth\n" + "10: Sale\n" ); SampleTransactions sampleTransaction = new SampleTransactions(); RequestMessage request = null; int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: request = sampleTransaction.authRequest(); break; case 2: request = sampleTransaction.authRevRequest(); break; case 3: request = sampleTransaction.emvAuthRequest(); break; case 4: request = sampleTransaction.level2CaptureRequest(); break; case 5: request = sampleTransaction.paymentNetworkTokenizationRequest(); break; case 6: request = sampleTransaction.refundRequest(); break; case 7: request = sampleTransaction.visaCheckoutAuthRequest(); break; case 8: request = sampleTransaction.androidPayAuthRequest(); break; case 9: request = sampleTransaction.applePayAuthRequest(); break; case 10: request = sampleTransaction.saleRequest(); break; } try { ReplyMessage reply = SoapClient.RunTransaction(request); SaveOrderState(); ProcessReply(reply); } /*** There are many specific exceptions that could be caught here. Only a few are provided as examples. * This is a Windows Communication Foundation (WCF) Client and uses exceptions from the System.ServiceModel * Namespaces. Please refer to the Microsoft documentation to better understand what these exceptions mean. * ***/ //System.ServiceModel Exception examples. catch (EndpointNotFoundException e) { // This is thrown when a remote endpoint could not be found or reached. // The remote endpoint is down, the client network connection is down, // the remote endpoint is unreachable, or because the remote network is unreachable. SaveOrderState(); HandleException(e); } catch (ChannelTerminatedException e) { // This is typically thrown on the client when a channel is terminated due to the server closing the connection. SaveOrderState(); HandleException(e); } //System.ServiceModel.Security Exception example. catch (MessageSecurityException e) { //Represents an exception that occurred when there is something wrong with the security applied on a message. Possibly a bad signature. SaveOrderState(); HandleSecurityException(e); } //System.Security.Cryptography exception catch (CryptographicException ce) { //Represents a problem with your X509 certificate (.p12 file) or a problem creating a signature from the certificate. SaveOrderState(); HandleCryptoException(ce); } //System.Net exception catch (WebException we) { //The WebException class is thrown by classes descended from WebRequest and WebResponse that implement pluggable protocols for accessing the Internet. SaveOrderState(); HandleWebException(we); } //Any other exception! catch (Exception e) { SaveOrderState(); HandleException(e); } Console.WriteLine("Press Return to end..."); Console.ReadLine(); }
/// <summary> /// Generates a single random transaction by selecting one partner, one or multiple products, and one or multiple quantity for each product. /// Note that transaction will be persisted at save even without using the return value, because transactions are created inside the Partner aggregate root. /// </summary> public static Transaction GenerateTransaction(IReadOnlyList <Partner> partners, IReadOnlyList <Product> products) => SampleTransactions.GenerateTransaction(partners, products);