Ejemplo n.º 1
0
        public byte[] GetSignature(CreateTransactionModel model)
        {
            Transaction T = CreateTransaction(model);

            T.Currency = 1;
            return(CreatePervStr(T));
        }
        public async Task <TransactionTokenModel> CreateAsync(CreateTransactionModel createTransaction)
        {
            try
            {
                httpClient.DefaultRequestHeaders.Add(
                    "Authorization", string.Format("Basic {0}", Helper.GetBasicAuthentication(apiSecret)));

                string jsonString = JsonSerializer.Serialize(createTransaction, new JsonSerializerOptions
                {
                    IgnoreNullValues = true,
                });

                HttpResponseMessage response = await httpClient.PostAsync(Constants.TRANSACTION_ENDPOINT,
                                                                          new StringContent(jsonString, System.Text.Encoding.UTF8, "application/json"));

                string responseString = string.Empty;

                if (response.Content != null)
                {
                    responseString = await response.Content.ReadAsStringAsync();
                }

                if (response.IsSuccessStatusCode)
                {
                    return(JsonSerializer.Deserialize <TransactionTokenModel>(responseString));
                }

                throw new InvalidOperationException(responseString);
            }
            catch (Exception xe)
            {
                throw new InvalidOperationException(xe.Message);
            }
        }
Ejemplo n.º 3
0
        public async static Task <CreateTransactionModel> DoTransaction(string IdUser, string FromAddress_Buyer, string ToAddress_Owner, string Amount)
        {
            CreateTransactionModel _transaction = new CreateTransactionModel()
            {
                amount = Amount, hashFrom = FromAddress_Buyer, hashTo = ToAddress_Owner, hashTransaction = ""
            };

            var mainAddress = String.Format(ConfigurationManager.AppSettings["MainAddress"]);             //AppSettings.MainAddress;
            var web3        = new Nethereum.Web3.Web3(ConfigurationManager.AppSettings["BlockchainURL"]); //AppSettings.BlockchainURL

            try
            {
                var unlockMainAddress = await web3.Personal.UnlockAccount.SendRequestAsync(mainAddress, ConfigurationManager.AppSettings["MainAddressPassphrase"].ToString(), 100);//AppSettings.MainAddressPassphrase

                if (unlockMainAddress)
                {
                    HexBigInteger gas  = new HexBigInteger(90000);
                    HexBigInteger gas2 = new HexBigInteger(0);

                    var approvedAddress = await GetContractFunction("approveOwner").SendTransactionAsync(mainAddress, gas, gas2, FromAddress_Buyer, new BigInteger(float.Parse(Amount)));

                    if (approvedAddress.Length > 10)
                    {
                        var functionBalance = GetContractFunction("balanceOf");
                        var _balance        = await functionBalance.CallAsync <Int64>(FromAddress_Buyer);

                        if (Convert.ToDouble(Amount) > Convert.ToDouble(_balance))
                        {
                            _transaction = null;
                            return(_transaction);
                        }

                        var functionFrom = GetContractFunction("transferFrom");
                        var _result      = await functionFrom.SendTransactionAsync(mainAddress, gas, gas2, FromAddress_Buyer, ToAddress_Owner, new BigInteger(float.Parse(Amount)));

                        _transaction.hashTransaction = _result.ToString();
                    }
                }
            }
            catch (Exception Ex)
            {
                //Encolar una notificacion para que muestre
                NotificationManager notificationManager = new NotificationManager();

                Notification notification = new Notification();
                notification.IdUser  = new Guid(IdUser);
                notification.Label   = NotificationLabels.CampaignValidation;
                notification.Title   = string.Format("Campaign validation error {0}", DateTime.Now);
                notification.Message = Ex.Message;

                notificationManager.EnqueueNotification(notification);
            }
            finally
            {
                //Then Lock mainAddress again
                await web3.Personal.LockAccount.SendRequestAsync(mainAddress);
            }
            return(_transaction);
        }
        public async Task GetTransitionCopy_Success(CreateTransactionModel model)
        {
            _transactionRepository.Setup(c => c.GetTransactionByIdAndUser(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(model);

            var result = (await _manager.GetTransitionCopy(It.IsAny <int>(), It.IsAny <int>())).AsSource().OfLikeness <CreateTransactionModel>();

            Assert.True(result.Equals(model));
        }
Ejemplo n.º 5
0
        public async Task <int> CreateUser([FromBody] CreateTransactionModel model)
        {
            var result = 0;

            result = await Server.CreateTransaction(model.Date, model.Description, model.Category, model.SubCategory, model.Type, model.Amount);

            return(result);
        }
        public async Task CreateTransaction_Error(CreateTransactionModel model)
        {
            _transactionManager.Setup(c => c.CreateTransaction(It.IsAny <int>(), model)).ReturnsAsync(ErrorDictionary.Error);

            var response = await _controller.CreateTransaction(model) as BadRequestObjectResult;

            Assert.True(response.StatusCode == (int)HttpStatusCode.BadRequest);
            Assert.Equal((string)response.Value, ErrorDictionary.Error);
        }
        public TransactionModel ConvertCreateModel(CreateTransactionModel model)
        {
            decimal amount;

            decimal.TryParse(model.Amount, out amount);
            return(new TransactionModel()
            {
                Amount = amount
            });
        }
Ejemplo n.º 8
0
        /// <inheritdoc />
        public TransactionResponse <TUserdefined> CreateTransaction <TUserdefined>(CreateTransactionModel <TUserdefined> requestData) where TUserdefined : class
        {
            //Post to Paygate
            var transactionData = SinglePaymentRequestSoapXml.Get(_merchantId, _merchantSecret, requestData);

            //Get the response
            var response = _url.PostStringToUrl(transactionData, _contentType);

            return(CreateXmlDocument(response).ToTransactionResponse <TUserdefined>());
        }
        public async Task CreateTransaction_Amount_Negative_Error(CreateTransactionModel model)
        {
            model.Amount = -1;
            _transactionManager.Setup(c => c.CreateTransaction(It.IsAny <int>(), model)).ReturnsAsync(ErrorDictionary.Ok).Verifiable();

            var response = await _controller.CreateTransaction(model) as BadRequestObjectResult;

            _transactionManager.Verify(c => c.CreateTransaction(It.IsAny <int>(), model), Times.Never);
            Assert.True(response.StatusCode == (int)HttpStatusCode.BadRequest);
            Assert.Equal((string)response.Value, ErrorDictionary.AmountMustByPositive);
        }
        public ServiceResponse <bool> Create([FromBody] CreateTransactionModel createModel)
        {
            var response = new ServiceResponse <bool>();

            var creditCardModel = _creditCardService.GetByToken(createModel.Token);

            if (creditCardModel.IsSuccessed)
            {
                TransactionModel model = new TransactionConverter().ConvertCreateModel(createModel);
                decimal          amount;
                decimal.TryParse(createModel.Amount, out amount);

                if (_braintreeWarpper.Sale(amount, createModel.Token))
                {
                    model.IsActive     = true;
                    model.IsDeleted    = false;
                    model.CreditCardId = creditCardModel.Data.ID;

                    var validationResult = _transactionModelValidator.Validate(model);
                    if (validationResult.IsValid)
                    {
                        var entity          = new TransactionConverter().Convert(model);
                        var serviceResponse = _transactionService.Create(entity);
                        response.IsSuccessed = serviceResponse.IsSuccessed;
                        response.Errors      = serviceResponse.Errors;
                        response.Data        = true;
                    }
                    else
                    {
                        _logger.Error("{source} {template} {logtype} {ValidationError}", "controller", "TransactionEntity", "validationerror", validationResult.Errors);
                        response.IsSuccessed = false;
                        response.Errors      = new ValidationFailureConverter().Convert(validationResult.Errors.ToList());
                    }
                }
                else
                {
                    response.IsSuccessed = false;
                    response.Errors.Add(new ServiceError()
                    {
                        InnerMessage = "Payment Error.", Message = "There is an error with payment! Please contact.", Code = "2009062057"
                    });
                }
            }
            else
            {
                response.IsSuccessed = false;
                response.Errors.Add(new ServiceError()
                {
                    InnerMessage = "Token not found in the credit card table.", Message = "There is an error with payment! Please contact.", Code = "2009062304"
                });
            }

            return(response);
        }
        public async Task GetTransaction_Success(CreateTransactionModel model)
        {
            _transactionManager.Setup(c => c.GetTransitionCopy(It.IsAny <int>(), It.IsAny <int>())).ReturnsAsync(model).Verifiable();

            var response = await _controller.GetTransaction(1) as OkObjectResult;

            var received = response.Value.AsSource().OfLikeness <CreateTransactionModel>();

            Assert.True(response.StatusCode == (int)HttpStatusCode.OK);
            Assert.True(received.Equals(model));
        }
        public async Task CreateTransaction_Smaller_Balance_Error(CreateTransactionModel model)
        {
            _balanceRepository.Setup(c => c.GetBalance(0)).ReturnsAsync((decimal)(model.Amount - 1)).Verifiable();
            _transactionRepository.Setup(c => c.AddTransaction(It.IsAny <TransferTransaction>())).ReturnsAsync(1).Verifiable();
            _balanceRepository.Setup(c => c.AddBalanceEntries(It.IsAny <List <Balance> >())).ReturnsAsync(It.IsAny <List <Balance> >).Verifiable();

            var result = await _manager.CreateTransaction(0, model);

            _balanceRepository.Verify(c => c.GetBalance(0), Times.Once);
            _transactionRepository.Verify(c => c.AddTransaction(It.IsAny <TransferTransaction>()), Times.Never);
            _balanceRepository.Verify(c => c.AddBalanceEntries(It.IsAny <List <Balance> >()), Times.Never);
            Assert.True(result == ErrorDictionary.BalanceSmallerThenAmount);
        }
Ejemplo n.º 13
0
        public API_TransactionFlowResult SendTransaction(CreateTransactionModel model)
        {
            Transaction T = CreateTransaction(model);

            T.Currency = 1;
            TransactionFlowResult Res = _connect.TransactionFlow(T);

            if (Res.Status.Code > 0)
            {
                throw new Exception(Res.Status.Message);
            }
            return(new API_TransactionFlowResult_4_3(Res));
        }
Ejemplo n.º 14
0
        private async Task <bool> IsEnoughBalanceAsync(CreateTransactionModel transaction)
        {
            if (transaction.Type.IsCredit())
            {
                var currentBalance = await _balanceService.GetCurrentAccountBalanceAsync();

                if (currentBalance < transaction.Amount)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 15
0
        public API_TransactionFlowResult SendTransaction(CreateTransactionModel model, byte[] PrivateKey)
        {
            Transaction T = CreateTransaction(model);

            T.Currency  = 1;
            T.Signature = SignTransaction(PrivateKey, CreatePervStr(T));
            TransactionFlowResult Res = _connect.TransactionFlow(T);

            if (Res.Status.Code > 0)
            {
                throw new Exception(Res.Status.Message);
            }
            return(new API_TransactionFlowResult_4_3(Res));
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> CreateTransaction([FromBody] CreateTransactionModel model)
        {
            var json = JsonConvert.SerializeObject(model);
            var data = new StringContent(json, Encoding.UTF8, "application/json");
            var url  = "http://localhost:8000/transaction/add";

            using (var client = new HttpClient())
            {
                var response = await client.PostAsync(url, data);

                string result = await response.Content.ReadAsStringAsync();
            }

            return(Ok());
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> CreateTransaction(CreateTransactionModel model)
        {
            if (model.Amount <= 0)
            {
                return(BadRequest(ErrorDictionary.AmountMustByPositive));
            }
            var userId = User.Identity.GetUserId();
            var result = await _transactionManager.CreateTransaction(userId, model);

            if (string.Equals(result, ErrorDictionary.Ok))
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
Ejemplo n.º 18
0
        public T SendTransaction <T>(CreateTransactionModel model, byte[] PrivateKey) where T : CreateTransactionModel
        {
            Transaction t = CreateTransaction(model);

            t.Currency  = 1;
            t.Signature = SignTransaction(PrivateKey, CreatePervStr(t));
            TransactionFlowResult Res = _connect.TransactionFlow(t);

            if (Res.Status.Code > 0)
            {
                throw new Exception(Res.Status.Message);
            }
            model.Target = t.Target;

            return((T)model);
        }
Ejemplo n.º 19
0
        public async Task <string> CreateTransaction(int userId, CreateTransactionModel transactionModel)
        {
            var semaphore = dictionary.GetOrAdd(userId, new SemaphoreSlim(1, 1));
            await semaphore.WaitAsync();

            try
            {
                var balance = await _balanceRepository.GetBalance(userId);

                if (balance < transactionModel.Amount)
                {
                    return(ErrorDictionary.BalanceSmallerThenAmount);
                }

                var date = DateTime.UtcNow;

                var transactionId = await AddTransaction(userId, (int)transactionModel.CorrespondentId, date);

                var negativeBalance = new Balance();
                var positiveBalance = new Balance();
                negativeBalance.Amount                = -(int)transactionModel.Amount;
                positiveBalance.Amount                = (int)transactionModel.Amount;
                negativeBalance.CreationDate          = positiveBalance.CreationDate = date;
                negativeBalance.TransferTransactionId = positiveBalance.TransferTransactionId = transactionId;
                negativeBalance.UserId                = userId;
                positiveBalance.UserId                = (int)transactionModel.CorrespondentId;

                var result = await _balanceRepository.AddBalanceEntries(new List <Balance>() { negativeBalance, positiveBalance });

                if (result.All(c => c.Id > 0))
                {
                    return(ErrorDictionary.Ok);
                }
                else
                {
                    await _balanceRepository.RemoveBalanceEntry(result.FirstOrDefault(c => c.Id > 0));

                    await _transferTransactionRepository.RemoveTransaction(transactionId);

                    return(ErrorDictionary.Error);
                }
            }
            finally
            {
                semaphore.Release();
            }
        }
Ejemplo n.º 20
0
        public async Task <TransactionDetailsModel> CreateTransactionAsync(CreateTransactionModel transaction)
        {
            if (await IsEnoughBalanceAsync(transaction) == false)
            {
                throw new CreateTransactionException(CreateTransactionErrors.NotEnoughBalance);
            }

            var transactionDto = Mapper.Map <TransactionDto>(transaction);

            transactionDto.Occured = DateTime.UtcNow;

            var entity = _transactionsRepository.AddTransaction(transactionDto);

            var mappedEntity = Mapper.Map <TransactionDetailsModel>(entity);

            return(mappedEntity);
        }
Ejemplo n.º 21
0
        public async Task <CustomizedResult> Adicionar(CreateTransactionModel model)
        {
            var transaction = model.ConvertToEntity();

            if (!transaction.IsValid())
            {
                var result = new CustomizedResult("Found an error", transaction);
                result.AdicionarMensagensDeErro(transaction.ErrorMessages);
                return(result);
            }
            ;
            var addedTransaction = await _repository.Adicionar(transaction);

            var successResult = new CustomizedResult("Transaction added", addedTransaction.ConvertToModel());

            return(successResult);
        }
        public async Task CreateTransaction_Success(CreateTransactionModel model, Balance balance1, Balance balance2)
        {
            var list = new List <Balance>()
            {
                balance1, balance2
            };

            _balanceRepository.Setup(c => c.GetBalance(0)).ReturnsAsync((decimal)(model.Amount + 1)).Verifiable();
            _transactionRepository.Setup(c => c.AddTransaction(It.IsAny <TransferTransaction>())).ReturnsAsync(1).Verifiable();
            _balanceRepository.Setup(c => c.AddBalanceEntries(It.IsAny <List <Balance> >())).ReturnsAsync(list).Verifiable();

            var result = await _manager.CreateTransaction(0, model);

            _balanceRepository.Verify(c => c.GetBalance(0), Times.Once);
            _transactionRepository.Verify(c => c.AddTransaction(It.IsAny <TransferTransaction>()), Times.Once);
            _balanceRepository.Verify(c => c.AddBalanceEntries(It.IsAny <List <Balance> >()), Times.Once);
            Assert.True(result == ErrorDictionary.Ok);
        }
Ejemplo n.º 23
0
        public async Task CreateTransaction()
        {
            CreateTransactionModel createTransaction = new CreateTransactionModel
            {
                CustomerId    = "TEST_ID",
                TemplateKey   = configuration["TEMPLATE_KEY"],
                HostedOptions = new HostedOptionsModel
                {
                    CompletionEmail = configuration["EMAIL"]
                },
                Phone = configuration["PHONE"]
            };

            ITransaction transactionService = (ITransaction)ServiceProvider.GetService(typeof(ITransaction));

            TransactionTokenModel token = await transactionService.CreateAsync(createTransaction);

            Console.WriteLine(JsonSerializer.Serialize(token));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Create tax transaction
        /// </summary>
        /// <param name="createTransactionModel">Request parameters to create a transaction</param>
        /// <param name="logTransactionDetails">Whether to log tax transaction request and response</param>
        /// <returns>Transaction</returns>
        public TransactionModel CreateTaxTransaction(CreateTransactionModel createTransactionModel, bool logTransactionDetails)
        {
            return(HandleRequest(() =>
            {
                //create transaction
                var transaction = ServiceClient.CreateTransaction(string.Empty, createTransactionModel)
                                  ?? throw new NopException("No response from the service");

                //whether there are any errors
                if (transaction.messages?.Any() ?? false)
                {
                    throw new NopException(transaction.messages
                                           .Aggregate(string.Empty, (error, message) => $"{error}{message.summary}{Environment.NewLine}"));
                }

                //return the result
                return transaction;
            }));
        }
Ejemplo n.º 25
0
        public Transaction CreateTransaction(CreateTransactionModel model)
        {
            if (model.Source.Length != 32)
            {
                throw new Exception("The length of the Source is not equal to 32");
            }

            WalletDataGetResult WalletData = _connect.WalletDataGet(model.Source);

            if (WalletData.Status.Code > 0)
            {
                throw new Exception(WalletData.Status.Message);
            }

            Transaction Res = new Transaction
            {
                Id         = WalletData.WalletData.LastTransactionId + 1,
                Source     = model.Source,
                Amount     = AmountConvert(model.Amount),
                Fee        = AmountCommissionEncode(model.Fee),
                UserFields = model.UserData
            };

            if (model.SmartContract.Code == null)
            {
                if (model.Target.Length != 32)
                {
                    throw new Exception("The length of the Target is not equal to 32");
                }
                Res.Target = model.Target;
            }
            else
            {
                Res.SmartContract = new SmartContractInvocation();

                byte[] ByteC = Res.Source;
                ConcatByteAr(ref ByteC, NumbToByte(Res.Id, 6));
                SmartContractCompileResult ByteCodes = _connect.SmartContractCompile(model.SmartContract.Code);
                if (ByteCodes.Status.Code > 0)
                {
                    throw new Exception(ByteCodes.Status.Message);
                }
                foreach (ByteCodeObject item in ByteCodes.ByteCodeObjects)
                {
                    ConcatByteAr(ref ByteC, item.ByteCode);
                }
                Res.Target = Blake2s.Blake2S.ComputeHash(ByteC);

                Res.SmartContract.SmartContractDeploy = new SmartContractDeploy
                {
                    SourceCode      = model.SmartContract.Code,
                    ByteCodeObjects = ByteCodes.ByteCodeObjects
                };
            }

            if (model.SmartContract.Method != null)
            {
                Res.SmartContract = new SmartContractInvocation
                {
                    Method = model.SmartContract.Method,
                    Params = new List <Variant>()
                };

                if (model.SmartContract.Params != null)
                {
                    foreach (API_Variant i in model.SmartContract.Params)
                    {
                        Res.SmartContract.Params.Add(VariantConvert(i));
                    }
                }
            }

            if (Res.SmartContract != null)
            {
                Res.SmartContract.ForgetNewState = model.SmartContract.ForgetNewState;
            }

            if (model.UsedContracts != null)
            {
                Res.UsedContracts = new List <byte[]>();
                foreach (string i in model.UsedContracts)
                {
                    Res.UsedContracts.Add(Base58CheckEncoding.DecodePlain(i));
                }
            }
            return(Res);
        }
Ejemplo n.º 26
0
        internal static string Get <TUserdefined>(string merchantId, string merchantSecret, CreateTransactionModel <TUserdefined> data) where TUserdefined : class
        {
            var userdefinedFieldsAvailable = 5;
            var totalTextLengthPerField    = 254;
            var stringData = Serialize(data.UserdefinedData);
            var compressed = stringData.CompressString();

            if (compressed.Length + 1 > (userdefinedFieldsAvailable * totalTextLengthPerField))
            {
                throw new Exception("User Defined Field exceeds available length");
            }

            var userDefinedFieldXml = "";

            if (string.IsNullOrEmpty(compressed))
            {
                return(Get(merchantId, merchantSecret, data, userDefinedFieldXml));
            }

            // Add it to the xml
            var splitString = compressed.SplitInChunks(254);
            var idx         = 1;

            foreach (var x in splitString)
            {
                userDefinedFieldXml += $@"<pay:UserDefinedFields><pay:key>{idx}</pay:key><pay:value>{x}</pay:value></pay:UserDefinedFields>";
                idx++;
            }

            return(Get(merchantId, merchantSecret, data, userDefinedFieldXml));
        }
Ejemplo n.º 27
0
 public async Task <IActionResult> Adicionar([FromBody] CreateTransactionModel createTransactionModel)
 => CustomResponse(await _transactionService.Adicionar(createTransactionModel));
Ejemplo n.º 28
0
 public static Transaction ConvertToEntity(this CreateTransactionModel model)
 {
     return(new Transaction(model.Description, model.Amount, model.Date));
 }
Ejemplo n.º 29
0
        private static string Get(string merchantId, string merchantSecret, CreateTransactionModel data, string userDefinedFieldXml)
        {
            //TODO: Remove the validation below and use data attributes and custom Validator
            if (data == null)
            {
                throw new NullReferenceException(nameof(data));
            }

            if (data.Customer == null)
            {
                throw new NullReferenceException(nameof(data.Customer));
            }

            if (string.IsNullOrEmpty(data.Customer.FirstName))
            {
                throw new NullReferenceException(nameof(data.Customer.FirstName));
            }

            if (string.IsNullOrEmpty(data.Customer.LastName))
            {
                throw new NullReferenceException(nameof(data.Customer.LastName));
            }

            if (string.IsNullOrEmpty(data.Customer.Email))
            {
                throw new NullReferenceException(nameof(data.Customer.Email));
            }

            if (string.IsNullOrEmpty(data.Customer.Mobile))
            {
                //only if Fraud and Risk screening is activated
                //throw new NullReferenceException(nameof(data.Customer.Mobile));
            }

            if (string.IsNullOrEmpty(data.Card.HolderName))
            {
                throw new NullReferenceException(nameof(data.Card.HolderName));
            }

            if (string.IsNullOrEmpty(data.Card.Number))
            {
                throw new NullReferenceException(nameof(data.Card.Number));
            }

            if (string.IsNullOrEmpty(data.Card.Cvv))
            {
                throw new NullReferenceException(nameof(data.Card.Cvv));
            }

            if (data.Card.BudgetPeriod == null)
            {
                throw new NullReferenceException(nameof(data.Card.BudgetPeriod));
            }

            if (string.IsNullOrEmpty(data.Card.ExpiryMonth))
            {
                throw new NullReferenceException(nameof(data.Card.ExpiryMonth));
            }

            if (string.IsNullOrEmpty(data.Card.ExpiryYear))
            {
                throw new NullReferenceException(nameof(data.Card.ExpiryYear));
            }

            var productItemsXml = "";

            if (data.Order.Items.Any())
            {
                productItemsXml = data.Order.Items.Aggregate(productItemsXml, (current, orderItem) => current + $@"<pay:OrderItems>
                                                <pay:ProductCode>{orderItem?.ProductCode ?? ""}</pay:ProductCode>
                                                <pay:ProductDescription>{orderItem?.ProductDescription ?? ""}</pay:ProductDescription>
                                                <pay:ProductCategory>{orderItem?.ProductCategory ?? ""}</pay:ProductCategory>
                                                <pay:ProductRisk>{orderItem?.ProductRisk ?? ""}</pay:ProductRisk>
                                                <pay:OrderQuantity>{orderItem?.OrderQuantity}</pay:OrderQuantity>
                                                <pay:UnitPrice>{orderItem?.UnitPrice}</pay:UnitPrice>
                                                <pay:Currency>{orderItem?.Currency?.ToString() ?? ""}</pay:Currency>
                                            </pay:OrderItems>");
            }

            var merchantRedirectUrl = data.Redirect?.RedirectUrl ?? "";
            var merchantNotifyUrl   = data.Redirect?.NotifyUrl ?? "";

            return($@"<soapenv:Envelope xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:pay=""http://www.paygate.co.za/PayHOST"">
                        <soapenv:Header/>
                        <soapenv:Body>
                            <pay:SinglePaymentRequest>
                                <pay:CardPaymentRequest>
                                    <pay:Account>
                                        <pay:PayGateId>{merchantId ?? ""}</pay:PayGateId>
                                        <pay:Password>{merchantSecret ?? ""}</pay:Password>
                                    </pay:Account>
                                    <pay:Customer>
                                        <pay:FirstName>{data.Customer?.FirstName ?? ""}</pay:FirstName>
                                        <pay:LastName>{data.Customer?.LastName ?? ""}</pay:LastName>
                                        <pay:Mobile>{data.Customer?.Mobile ?? ""}</pay:Mobile>
                                        <pay:Email>{data.Customer?.Email ?? ""}</pay:Email>
                                    </pay:Customer>
                                    <pay:CardNumber>{data.Card?.Number ?? ""}</pay:CardNumber>
                                    <pay:CardExpiryDate>{data.Card?.ExpiryMonth ?? ""}{data.Card?.ExpiryYear ?? ""}</pay:CardExpiryDate>
                                    <pay:CVV>{data.Card?.Cvv ?? ""}</pay:CVV>
                                    <pay:BudgetPeriod>{data.Card?.BudgetPeriod}</pay:BudgetPeriod>
                                    <!-- 3D secure redirect object -->
                                    <pay:Redirect>
                                        <pay:NotifyUrl>{merchantNotifyUrl}</pay:NotifyUrl>
                                        <pay:ReturnUrl>{merchantRedirectUrl}</pay:ReturnUrl>
                                    </pay:Redirect>
                                    <pay:Order>
                                        <pay:MerchantOrderId>{data.Order?.MerchantOrderId ?? ""}</pay:MerchantOrderId>
                                        <pay:Currency>{data.Order?.Currency}</pay:Currency>
                                        <pay:Amount>{data.Order?.Amount}</pay:Amount>
                                        {productItemsXml}
                                    </pay:Order>
                                    {userDefinedFieldXml}   
                                </pay:CardPaymentRequest>
                            </pay:SinglePaymentRequest>
                        </soapenv:Body>
                    </soapenv:Envelope>");
        }
Ejemplo n.º 30
0
 internal static string Get(string merchantId, string merchantSecret, CreateTransactionModel data)
 {
     return(Get(merchantId, merchantSecret, data, ""));
 }