示例#1
0
文件: Adyen.cs 项目: icaroferj/ir-api
        private bool PagarSandbox()
        {
            var additionalData = new List <wsAdyenSandbox.anyType2anyTypeMapEntry>();

            if (this.Parcelas > 1)
            {
                additionalData.Add(new wsAdyenSandbox.anyType2anyTypeMapEntry()
                {
                    key   = AdyenStatic.Fields.Installments,
                    value = this.Parcelas.ToString()
                });
            }

            wsAdyenSandbox.PaymentRequest p = new wsAdyenSandbox.PaymentRequest()
            {
                amount = new wsAdyenSandbox.Amount
                {
                    currency = ConfiguracaoAdyen.Instancia.Chaves.Currency.Valor,
                    value    = ValorFormatado,
                },
                card = new wsAdyenSandbox.Card
                {
                    cvc         = this.CodigoVerificacaoCartao,
                    expiryMonth = this.DataValidadeCartao.Substring(0, 2),
                    expiryYear  = "20" + this.DataValidadeCartao.Substring(2, 2),
                    holderName  = this.NomeCartao,
                    number      = this.NumeroCartao,
                },
                additionalData   = additionalData.ToArray(),
                merchantAccount  = ConfiguracaoAdyen.Instancia.Chaves.MerchantAccount.Valor,
                shopperEmail     = this.ClienteEmail,
                shopperIP        = this.ClienteIP,
                shopperReference = this.ClienteID,
                reference        = this.ClienteNome,
                sessionId        = this.ClienteSessionID,
            };

            wsAdyenSandbox.Payment px = new wsAdyenSandbox.Payment();
            px.Credentials = this.Credentials;
            var retorno = px.authorise(p);

            bool autorizado = AdyenStatic.Action.Autorizado(retorno.resultCode);

            this.CodigoAutenticacao = retorno.authCode ?? string.Empty;
            this.CodigoReferencia   = retorno.pspReference ?? string.Empty;

            if (autorizado)
            {
                return(true);
            }

            throw new Exception(retorno.refusalReason);
        }
示例#2
0
文件: Adyen.cs 项目: icaroferj/ir-api
        private bool CancelarSandbox()
        {
            var payment = new wsAdyenSandbox.Payment {
                Credentials = this.Credentials
            };
            var modificationRequest = new wsAdyenSandbox.ModificationRequest {
                originalReference = this.CodigoReferencia, merchantAccount = ConfiguracaoAdyen.Instancia.Chaves.MerchantAccount.Valor
            };

            var retorno = payment.cancelOrRefund(modificationRequest);

            var autorizado = AdyenStatic.Action.Autorizado(retorno.response);

            this.CodigoReferencia = retorno.pspReference;

            return(autorizado);
        }
示例#3
0
文件: Adyen.cs 项目: icaroferj/ir-api
        private bool CapturarSandbox()
        {
            var payment = new wsAdyenSandbox.Payment {
                Credentials = this.Credentials
            };
            var modificationRequest = new wsAdyenSandbox.ModificationRequest
            {
                merchantAccount    = ConfiguracaoAdyen.Instancia.Chaves.MerchantAccount.Valor,
                originalReference  = this.CodigoReferencia,
                modificationAmount = new wsAdyenSandbox.Amount
                {
                    currency = ConfiguracaoAdyen.Instancia.Chaves.Currency.Valor,
                    value    = ValorFormatado
                }
            };

            var retorno = payment.capture(modificationRequest);

            return(AdyenStatic.Action.Autorizado(retorno.response));
        }