Example #1
0
        private static void CreateProfileWithToken()
        {
            Console.WriteLine("Creating Payment Profile with a Legato Token... ");

            Gateway beanstream = new Gateway()
            {
                MerchantId      = 300200578,
                PaymentsApiKey  = "4BaD82D9197b4cc4b70a221911eE9f70",
                ReportingApiKey = "4e6Ff318bee64EA391609de89aD4CF5d",
                ProfilesApiKey  = "D97D3BE1EE964A6193D17A571D9FBC80",
                ApiVersion      = "1"
            };

            string url  = "https://www.beanstream.com/scripts/tokenization/tokens";
            var    data = new {
                number       = "5100000010001004",
                expiry_month = "12",
                expiry_year  = "18",
                cvd          = "123"
            };

            var requestInfo             = new RequestObject(HttpMethod.Post, url, null, data);
            var command                 = new ExecuteWebRequest(requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter();
            var result = executer.ExecuteCommand(command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject <LegatoTokenResponse>(result.Response);

            Console.WriteLine("Retrieved Legato Token: " + token.Token);

            // You can create a profile with a token instead of a card.
            // It will save the billing information, but the token is still single-use
            ProfileResponse response = beanstream.Profiles.CreateProfile(
                new Token()
            {
                Name = "Jane Doe",
                Code = token.Token
            },
                new Address()
            {
                Name         = "Jane Doe",
                AddressLine1 = "123 Fake St.",
                City         = "victoria",
                Province     = "bc",
                Country      = "ca",
                PostalCode   = "v9t2g6",
                PhoneNumber  = "12501234567",
                EmailAddress = "*****@*****.**"
            });

            Console.WriteLine("Created profile with ID: " + response.Id);

            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            // delete it so when we create a profile again with the same card we won't get an error
            beanstream.Profiles.DeleteProfile(response.Id);
        }
Example #2
0
        //TODO this is being implemented

        /*static void ProcessInterac() {
         *
         *      Console.WriteLine ("Processing Interac Payment... ");
         *
         *      Beanstream beanstream = new Beanstream () {
         *              MerchantId = 300200578,
         *              ApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
         *              ApiVersion = "1"
         *      };
         *
         *      // STEP 1:
         *      // The first step is to tell Beanstream you are making an Interac payment
         *      // and to get the Transaction ID for the next step
         *      PaymentResponse response = beanstream.Payments.MakePayment (
         *              new InteracPaymentRequest {
         *                      amount = "100.00",
         *                      order_number = getRandomOrderId("test")
         *              }
         *      );
         *      Console.WriteLine ("Interac Payment id: " + response.id + ", " + response.message+"\n");
         *
         *
         *      // STEP 2:
         *      // Next you redirect the user to the bank's website for the actual interac processing
         * }*/


        static void ProcessTokenPayment()
        {
            // The first step is to call the Legato service to get a token.
            // This is normally performed on the client machine, and not on the server.
            // The goal with tokens is to not have credit card information move through your server,
            // thus lowering your scope for PCI compliance

            string url  = "https://www.beanstream.com/scripts/tokenization/tokens";
            var    data = new {
                number       = "5100000010001004",
                expiry_month = "12",
                expiry_year  = "18",
                cvd          = "123"
            };

            var requestInfo             = new RequestObject(HttpMethod.Post, url, null, data);
            var command                 = new ExecuteWebRequest(requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter();
            var result = executer.ExecuteCommand(command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject <LegatoTokenResponse>(result.Response);

            Console.WriteLine("legato token: " + token.Token);

            // Now that we have a token that represents our credit card info, we can process
            // the payment with that token

            Gateway beanstream = new Gateway()
            {
                MerchantId     = 300200578,
                PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
                ApiVersion     = "1"
            };

            PaymentResponse response = beanstream.Payments.MakePayment(
                new TokenPaymentRequest()
            {
                Amount      = 30,
                OrderNumber = getRandomOrderId("test"),
                Token       = new Token {
                    Code = token.Token,
                    Name = "John Doe"
                }
            }
                );

            Console.WriteLine("Token payment result: " + response.TransactionId + ", " + response.Message + "\n");

            Assert.IsNotEmpty(response.TransactionId);
            Assert.AreEqual("Approved", response.Message);
            Assert.AreEqual("P", response.TransType);
        }
Example #3
0
        private static void CreateProfileWithToken()
        {
            Console.WriteLine("Creating Payment Profile with a Legato Token... ");

            string url  = "https://web.na.bambora.com/scripts/tokenization/tokens";
            var    data = new {
                number       = "5100000010001004",
                expiry_month = "12",
                expiry_year  = "18",
                cvd          = "123"
            };

            var requestInfo             = new RequestObject(HttpMethod.Post, url, null, data);
            var command                 = new ExecuteWebRequest(requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter();
            var result = executer.ExecuteCommand(command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject <LegatoTokenResponse>(result.Response);

            Console.WriteLine("Retrieved Legato Token: " + token.Token);

            // You can create a profile with a token instead of a card.
            // It will save the billing information, but the token is still single-use
            ProfileResponse response = _bambora.Profiles.CreateProfile(
                new Token()
            {
                Name = "Jane Doe",
                Code = token.Token
            },
                new Address()
            {
                Name         = "Jane Doe",
                AddressLine1 = "123 Fake St.",
                City         = "victoria",
                Province     = "bc",
                Country      = "ca",
                PostalCode   = "v9t2g6",
                PhoneNumber  = "12501234567",
                EmailAddress = "*****@*****.**"
            });

            Console.WriteLine("Created profile with ID: " + response.Id);

            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            // delete it so when we create a profile again with the same card we won't get an error
            _bambora.Profiles.DeleteProfile(response.Id);
        }
Example #4
0
        private static void AddTokenizedCardToProfileAndMakePayment()
        {
            Console.WriteLine("Adding Tokenized Card to Profile... ");

            ProfileResponse response = _bambora.Profiles.CreateProfile(
                new Card()
            {
                Name        = "Jane Doe",
                Number      = "5100000010001004",
                ExpiryMonth = "12",
                ExpiryYear  = "18",
                Cvd         = "123"
            },
                new Address()
            {
                Name         = "Jane Doe",
                AddressLine1 = "123 Fake St.",
                City         = "victoria",
                Province     = "bc",
                Country      = "ca",
                PostalCode   = "v9t2g6",
                PhoneNumber  = "12501234567",
                EmailAddress = "*****@*****.**"
            });

            Console.WriteLine("Created profile with ID: " + response.Id);
            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            PaymentProfile profile = _bambora.Profiles.GetProfile(response.Id);

            // get a legato token representing the credit card
            string url  = "https://web.na.bambora.com/scripts/tokenization/tokens";
            var    data = new {
                number       = "4030000010001234",
                expiry_month = "12",
                expiry_year  = "18",
                cvd          = "123"
            };

            var requestInfo             = new RequestObject(HttpMethod.Post, url, null, data);
            var command                 = new ExecuteWebRequest(requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter();
            var result = executer.ExecuteCommand(command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject <LegatoTokenResponse>(result.Response);

            response = profile.AddCard(_bambora.Profiles, new Token {
                Name = "Jane Doe",
                Code = token.Token
            });
            Console.WriteLine("Added tokenized card to profile");
            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            PaymentResponse pResp = _bambora.Payments.MakePayment(new ProfilePaymentRequest {
                Amount         = 7.91M,
                OrderNumber    = getRandomOrderId("profile"),
                PaymentProfile = new PaymentProfileField()
                {
                    CardId       = 2,
                    CustomerCode = response.Id
                }
            });

            Assert.IsNotNull(pResp);

            // delete it so when we create a profile again with the same card we won't get an error
            _bambora.Profiles.DeleteProfile(response.Id);
        }
        //TODO this is being implemented
        /*static void ProcessInterac() {

            Console.WriteLine ("Processing Interac Payment... ");

            Beanstream beanstream = new Beanstream () {
                MerchantId = 300200578,
                ApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
                ApiVersion = "1"
            };

            // STEP 1:
            // The first step is to tell Beanstream you are making an Interac payment
            // and to get the Transaction ID for the next step
            PaymentResponse response = beanstream.Payments.MakePayment (
                new InteracPaymentRequest {
                    amount = "100.00",
                    order_number = getRandomOrderId("test")
                }
            );
            Console.WriteLine ("Interac Payment id: " + response.id + ", " + response.message+"\n");

            // STEP 2:
            // Next you redirect the user to the bank's website for the actual interac processing
        }*/
        static void ProcessTokenPayment()
        {
            // The first step is to call the Legato service to get a token.
            // This is normally performed on the client machine, and not on the server.
            // The goal with tokens is to not have credit card information move through your server,
            // thus lowering your scope for PCI compliance

            string url = "https://www.beanstream.com/scripts/tokenization/tokens";
            var data = new {
                number = "5100000010001004",
                expiry_month = "12",
                expiry_year = "18",
                cvd = "123"
            };

            var requestInfo = new RequestObject(HttpMethod.Post, url, null, data);
            var command = new ExecuteWebRequest (requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter ();
            var result = executer.ExecuteCommand (command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject<LegatoTokenResponse>(result.Response);
            Console.WriteLine ("legato token: " + token.Token);

            // Now that we have a token that represents our credit card info, we can process
            // the payment with that token

            Gateway beanstream = new Gateway () {
                MerchantId = 300200578,
                PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
                ApiVersion = "1"
            };

            PaymentResponse response = beanstream.Payments.MakePayment (
                new TokenPaymentRequest ()
                {
                    Amount = 30,
                    OrderNumber = getRandomOrderId("test"),
                    Token = new Token {
                        Code = token.Token,
                        Name = "John Doe"
                    }
                }
            );

            Console.WriteLine ("Token payment result: " + response.TransactionId + ", " + response.Message+"\n");

            Assert.IsNotEmpty (response.TransactionId);
            Assert.AreEqual ("Approved", response.Message);
            Assert.AreEqual ("P", response.TransType);
        }
        private static void CreateProfileWithToken()
        {
            Console.WriteLine ("Creating Payment Profile with a Legato Token... ");

            Gateway beanstream = new Gateway () {
                MerchantId = 300200578,
                PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
                ReportingApiKey = "4e6Ff318bee64EA391609de89aD4CF5d",
                ProfilesApiKey = "D97D3BE1EE964A6193D17A571D9FBC80",
                ApiVersion = "1"
            };

            string url = "https://www.beanstream.com/scripts/tokenization/tokens";
            var data = new {
                number = "5100000010001004",
                expiry_month = "12",
                expiry_year = "18",
                cvd = "123"
            };

            var requestInfo = new RequestObject(HttpMethod.Post, url, null, data);
            var command = new ExecuteWebRequest (requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter ();
            var result = executer.ExecuteCommand (command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject<LegatoTokenResponse>(result.Response);
            Console.WriteLine ("Retrieved Legato Token: "+token.Token);

            // You can create a profile with a token instead of a card.
            // It will save the billing information, but the token is still single-use
            ProfileResponse response = beanstream.Profiles.CreateProfile (
                new Token() {
                    Name = "Jane Doe",
                    Code = token.Token
                },
                new Address() {
                    Name = "Jane Doe",
                    AddressLine1 = "123 Fake St.",
                    City = "victoria",
                    Province = "bc",
                    Country = "ca",
                    PostalCode = "v9t2g6",
                    PhoneNumber = "12501234567",
                    EmailAddress = "*****@*****.**"
                });
            Console.WriteLine ("Created profile with ID: " + response.Id);

            Assert.IsNotNull (response);
            Assert.AreEqual ("Operation Successful", response.Message);

            // delete it so when we create a profile again with the same card we won't get an error
            beanstream.Profiles.DeleteProfile (response.Id);
        }
        private static void AddTokenizedCardToProfileAndMakePayment()
        {
            Console.WriteLine ("Adding Tokenized Card to Profile... ");

            Gateway beanstream = new Gateway () {
                MerchantId = 300200578,
                PaymentsApiKey = "4BaD82D9197b4cc4b70a221911eE9f70",
                ReportingApiKey = "4e6Ff318bee64EA391609de89aD4CF5d",
                ProfilesApiKey = "D97D3BE1EE964A6193D17A571D9FBC80",
                ApiVersion = "1"
            };

            ProfileResponse response = beanstream.Profiles.CreateProfile (
                new Card() {
                    Name = "Jane Doe",
                    Number = "5100000010001004",
                    ExpiryMonth = "12",
                    ExpiryYear = "18",
                    Cvd = "123"
                },
                new Address() {
                    Name = "Jane Doe",
                    AddressLine1 = "123 Fake St.",
                    City = "victoria",
                    Province = "bc",
                    Country = "ca",
                    PostalCode = "v9t2g6",
                    PhoneNumber = "12501234567",
                    EmailAddress = "*****@*****.**"
                });
            Console.WriteLine ("Created profile with ID: " + response.Id);
            Assert.IsNotNull (response);
            Assert.AreEqual ("Operation Successful", response.Message);

            PaymentProfile profile = beanstream.Profiles.GetProfile (response.Id);

            // get a legato token representing the credit card
            string url = "https://www.beanstream.com/scripts/tokenization/tokens";
            var data = new {
                number = "4030000010001234",
                expiry_month = "12",
                expiry_year = "18",
                cvd = "123"
            };

            var requestInfo = new RequestObject(HttpMethod.Post, url, null, data);
            var command = new ExecuteWebRequest (requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter ();
            var result = executer.ExecuteCommand (command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject<LegatoTokenResponse>(result.Response);

            response = profile.AddCard (beanstream.Profiles, new Token {
                Name = "Jane Doe",
                Code = token.Token
            });
            Console.WriteLine ("Added tokenized card to profile");
            Assert.IsNotNull (response);
            Assert.AreEqual ("Operation Successful", response.Message);

            PaymentResponse pResp = beanstream.Payments.MakePayment (new ProfilePaymentRequest {
                Amount = 7.91M,
                OrderNumber = getRandomOrderId("profile"),
                PaymentProfile = new PaymentProfileField() {
                    CardId = 2,
                    CustomerCode = response.Id
                }
            });
            Assert.IsNotNull (pResp);

            // delete it so when we create a profile again with the same card we won't get an error
            beanstream.Profiles.DeleteProfile (response.Id);
        }
Example #8
0
        private static void AddTokenizedCardToProfileAndMakePayment()
        {
            Console.WriteLine("Adding Tokenized Card to Profile... ");

            Gateway beanstream = new Gateway()
            {
                MerchantId      = 300200578,
                PaymentsApiKey  = "4BaD82D9197b4cc4b70a221911eE9f70",
                ReportingApiKey = "4e6Ff318bee64EA391609de89aD4CF5d",
                ProfilesApiKey  = "D97D3BE1EE964A6193D17A571D9FBC80",
                ApiVersion      = "1"
            };

            ProfileResponse response = beanstream.Profiles.CreateProfile(
                new Card()
            {
                Name        = "Jane Doe",
                Number      = "5100000010001004",
                ExpiryMonth = "12",
                ExpiryYear  = "18",
                Cvd         = "123"
            },
                new Address()
            {
                Name         = "Jane Doe",
                AddressLine1 = "123 Fake St.",
                City         = "victoria",
                Province     = "bc",
                Country      = "ca",
                PostalCode   = "v9t2g6",
                PhoneNumber  = "12501234567",
                EmailAddress = "*****@*****.**"
            });

            Console.WriteLine("Created profile with ID: " + response.Id);
            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            PaymentProfile profile = beanstream.Profiles.GetProfile(response.Id);

            // get a legato token representing the credit card
            string url  = "https://www.beanstream.com/scripts/tokenization/tokens";
            var    data = new {
                number       = "4030000010001234",
                expiry_month = "12",
                expiry_year  = "18",
                cvd          = "123"
            };

            var requestInfo             = new RequestObject(HttpMethod.Post, url, null, data);
            var command                 = new ExecuteWebRequest(requestInfo);
            WebCommandExecuter executer = new WebCommandExecuter();
            var result = executer.ExecuteCommand(command);

            LegatoTokenResponse token = JsonConvert.DeserializeObject <LegatoTokenResponse>(result.Response);

            response = profile.AddCard(beanstream.Profiles, new Token {
                Name = "Jane Doe",
                Code = token.Token
            });
            Console.WriteLine("Added tokenized card to profile");
            Assert.IsNotNull(response);
            Assert.AreEqual("Operation Successful", response.Message);

            PaymentResponse pResp = beanstream.Payments.MakePayment(new ProfilePaymentRequest {
                Amount         = 7.91,
                OrderNumber    = getRandomOrderId("profile"),
                PaymentProfile = new PaymentProfileField()
                {
                    CardId       = 2,
                    CustomerCode = response.Id
                }
            });

            Assert.IsNotNull(pResp);

            // delete it so when we create a profile again with the same card we won't get an error
            beanstream.Profiles.DeleteProfile(response.Id);
        }