bambora api examples

Example 1: bambora api examples

using Bambora.NA.SDK;
...

Gateway bambora = new Gateway () {
	MerchantId = YOUR_MERCHANT_ID,
	PaymentsApiKey = "YOUR_API_KEY",
	ApiVersion = "1"
};

Example 2: bambora api examples

using System;
using Bambora.NA.SDK;
using Bambora.NA.SDK.Requests;
using Bambora.NA.SDK.Domain;

namespace Bambora.NA.SDK.Demo
{
    class Program
   
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("BEGIN running sample transactions");
            
            //To point this sample application to TLS 1.2 ONLY server, uncomment line below
            //Bambora.NA.SDK.BamboraUrls.BaseUrl = "https://tls12-api.na.bambora.com";

            // Payments API
            ProcessPayment();            
            Console.WriteLine("FINISHED running sample transactions");
        }

        static string ProcessPayment()
        {

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

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

            PaymentResponse response = bambora.Payments.MakePayment(
                new CardPaymentRequest
                {
                    Amount = 100.00M,
                    OrderNumber = getRandomOrderId("test"),
                    Card = new Card
                    {
                        Name = "John Doe",
                        Number = "5100000010001004",
                        ExpiryMonth = "12",
                        ExpiryYear = "18",
                        Cvd = "123"
                    }
                }
            );

            Console.WriteLine("Payment id: " + response.TransactionId + ", " + response.Message + "\n");
            Console.WriteLine(response.TransType);

            return response.TransactionId;
        }
        private static string getRandomOrderId(string prefix)
        {
            DateTime datetime = DateTime.Now;
            double seconds = (datetime - new DateTime(1970, 1, 1).ToLocalTime()).TotalSeconds;            
            string orderId = prefix + "_" + seconds;
            if (orderId.Length > 30)
                orderId = orderId.Substring(0, 29);
            return orderId;
        }
    }
}

Tags:

Misc Example