static void ProcessPreauthorization() { Console.WriteLine ("Processing Pre-auth payments... "); Gateway beanstream = new Gateway () { MerchantId = 300200578, PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70", ApiVersion = "1" }; CardPaymentRequest paymentRequest = new CardPaymentRequest { Amount = 100.00M, OrderNumber = getRandomOrderId("test"), Card = new Card { Name = "John Doe", Number = "5100000010001004", ExpiryMonth = "12", ExpiryYear = "18", Cvd = "123" } }; // pre-authorize the payment for $100 PaymentResponse response = beanstream.Payments.PreAuth (paymentRequest); // In order for Pre-authorizations to work, you must enable them on your account: // http://support.beanstream.com/#docs/pre-authorizations-process-transaction-api.htm%3FTocPath%3DDeveloper%2520Resources%7CThe%2520Process%2520Transaction%2520API%7C_____8 // // 1. Log in to the Online Member Area. // 2. Navigate to administration > account admin > order settings in the left menu. // 3. Under the heading Restrict Internet Transaction Processing Types, select either of the last two options: // 3.a. Select Purchases or Pre-Authorization Only: allows you to process both types of transaction through your web interface // 3.b. De-select Restrict Internet Transaction Processing Types: allows you to process all types of transactions including returns, voids and pre-auth completions Console.WriteLine ("Pre-auth Payment id: " + response.TransactionId + ", " + response.Message); Assert.IsNotEmpty (response.TransactionId); Assert.AreEqual ("Approved", response.Message); Assert.AreEqual ("PA", response.TransType); // complete the pre-auth and get the money from the customer response = beanstream.Payments.PreAuthCompletion ( response.TransactionId, 60.00M ); Console.WriteLine ("Pre-auth result: " + response.TransactionId + ", " + response.Message+"\n" ); Assert.IsNotEmpty (response.TransactionId); Assert.AreEqual ("Approved", response.Message); Assert.AreEqual ("PAC", response.TransType); }
public void Setup() { _cardPaymentRequest = new CardPaymentRequest { Amount = 40.00, OrderNumber = "asdfghjkl00001", Card = new Card { Name = "John Doe", Number = "5100000010001004", ExpiryMonth = "12", ExpiryYear = "18", Cvd = "123" } }; _executer = new Mock<IWebCommandExecuter>(); }
/// <summary> /// Pre-authorize a payment. Use this if you want to know if a customer has sufficient funds /// before processing a payment. A real-world example of this is pre-authorizing at the gas pump /// for $100 before you fill up, then end up only using $60 of gas; the customer is only charged /// $60. The final payment is used with PreAuthCompletion(). /// </summary> /// <returns>The response, in particular the payment ID that is needed to complete the purchase.</returns> /// <param name="paymentRequest">Payment request.</param> public PaymentResponse PreAuth(CardPaymentRequest paymentRequest) { Gateway.ThrowIfNullArgument (paymentRequest, "paymentRequest"); paymentRequest.Card.Complete = false; // false to make it a pre-auth return PreAuthInternal (paymentRequest); }