Example #1
0
        public RunPayUComms(string username, string password, string apiurl, string safeKey, string api)
        {
            _safeKey = safeKey;
            _api = api;

            var binding = new BasicHttpBinding
            {
                Name = "EnterpriseAPISoapServiceSoapBinding1",
                CloseTimeout = new TimeSpan(0, 0, 1, 0),
                OpenTimeout = new TimeSpan(0, 0, 1, 0),
                ReceiveTimeout = new TimeSpan(0, 0, 10, 0),
                SendTimeout = new TimeSpan(0, 0, 10, 0),
                AllowCookies = false,
                BypassProxyOnLocal = false,
                HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                MaxBufferSize = 65536,
                MessageEncoding = WSMessageEncoding.Text,
                TextEncoding = Encoding.UTF8,
                TransferMode = TransferMode.Buffered,
                UseDefaultWebProxy = true,
                Security = new BasicHttpSecurity
                {
                    Message = new BasicHttpMessageSecurity
                    {
                        ClientCredentialType = BasicHttpMessageCredentialType.UserName,
                    },
                    Transport = new HttpTransportSecurity
                    {
                        ClientCredentialType = HttpClientCredentialType.None,
                        ProxyCredentialType = HttpProxyCredentialType.None,
                    },
                    Mode = BasicHttpSecurityMode.Transport
                },
                ReaderQuotas = new XmlDictionaryReaderQuotas
                {
                    MaxDepth = 32,
                    MaxStringContentLength = 8192,
                    MaxArrayLength = 16384,
                    MaxBytesPerRead = 4096,
                    MaxNameTableCharCount = 16384
                }
            };
            var address = new EndpointAddress(apiurl);
            _client = new EnterpriseAPISoapClient(binding,address);
            _client.Endpoint.Behaviors.Add(new InspectorBehavior(new ClientInspector(new SecurityHeader(username, password))));
        }
            public static SetTransactionResponseMessage InitialisePayment()
            {
                var trans = new setTransaction
                {
                    Api = "1.0",
                    Safekey = "{CE62CE80-0EFD-4035-87C1-8824C5C46E7F}",
                    TransactionType = transactionType.PAYMENT,
                    Stage = false,
                    AdditionalInformation =
                        new additionalInfo
                        {
                            merchantReference = "EasyMerchant",
                            returnUrl = "http://*****:*****@test.com",
                            mobile = "0111111111"
                        },
                    Basket =
                        new basket
                        {
                            amountInCents = "100",
                            currencyCode = "ZAR",
                            description = "Purchase"
                        },
                    Customfield =
                        new[] { new customField { key = "PaymentId", value = "PaymentId" }, }
                };

                EnterpriseAPISoapClient client = new EnterpriseAPISoapClient("PayUStaging");

                //Test soap call with hi to verify access
                //string hiResponse = client.hi();

                try
                {
                    SetTransactionResponseMessage response = client.setTransaction(
                        trans.Api,
                        trans.Safekey,
                        trans.TransactionType,
                        trans.Stage,
                        trans.AdditionalInformation,
                        trans.Customer,
                        trans.Basket,
                        trans.Fraud,
                        trans.Creditcard,
                        trans.Eft,
                        trans.Loyalty,
                        trans.BankTransfer,
                        trans.Ebucks,
                        trans.Autopay,
                        trans.Soulstace,
                        trans.Globalpay,
                        trans.Customfield,
                        trans.TransactionRecord);

                    return response;

                }
                catch (Exception ex)
                {
                }

                return null;
            }
            public static SetTransactionResponseMessage InitialisePayment()
            {
                var trans = new setTransaction
                {
                    Api                   = "1.0",
                    Safekey               = "{CE62CE80-0EFD-4035-87C1-8824C5C46E7F}",
                    TransactionType       = transactionType.PAYMENT,
                    Stage                 = false,
                    AdditionalInformation =
                        new additionalInfo
                    {
                        merchantReference       = "EasyMerchant",
                        returnUrl               = "http://*****:*****@test.com",
                        mobile         = "0111111111"
                    },
                    Basket =
                        new basket
                    {
                        amountInCents = "100",
                        currencyCode  = "ZAR",
                        description   = "Purchase"
                    },
                    Customfield =
                        new[] { new customField {
                                    key = "PaymentId", value = "PaymentId"
                                }, }
                };

                EnterpriseAPISoapClient client = new EnterpriseAPISoapClient("PayUStaging");

                //Test soap call with hi to verify access
                //string hiResponse = client.hi();

                try
                {
                    SetTransactionResponseMessage response = client.setTransaction(
                        trans.Api,
                        trans.Safekey,
                        trans.TransactionType,
                        trans.Stage,
                        trans.AdditionalInformation,
                        trans.Customer,
                        trans.Basket,
                        trans.Fraud,
                        trans.Creditcard,
                        trans.Eft,
                        trans.Loyalty,
                        trans.BankTransfer,
                        trans.Ebucks,
                        trans.Autopay,
                        trans.Soulstace,
                        trans.Globalpay,
                        trans.Customfield,
                        trans.TransactionRecord);

                    return(response);
                }
                catch (Exception ex)
                {
                }

                return(null);
            }