Ejemplo n.º 1
0
        public PaymentResult AddCreditCard(Shopper shopper, string cardData, string recurringContract = null)
        {
            var payment = new AuthoriseService(_client);

            var addCreditCardRequest = new AddCreditCardRequest
            {
                MerchantAccount = _adyenConfiguration.MerchantAccount,
                Amount          = new Amount
                {
                    Currency = "EUR",
                    Value    = 0
                },
                Reference        = "ADD-CREDIT-CARD-REQUEST" + Guid.NewGuid(),
                ShopperEmail     = shopper.Email,
                ShopperReference = shopper.Reference,
                ShopperName      = new Name
                {
                    FirstName = shopper.FirstName,
                    LastName  = shopper.LastName
                },
                Recurring = new Recurring
                {
                    Contract = recurringContract ?? "ONECLICK,RECURRING"
                },
                AdditionalData = new Dictionary <string, string>
                {
                    { "card.encrypted.json", cardData }
                }
            };

            return(payment.Authorise(addCreditCardRequest));
        }
Ejemplo n.º 2
0
        public static PaymentRequest CreateForRecurringPayment(Shopper shopper,
                                                               string paymentReference,
                                                               int amount,
                                                               string currency,
                                                               string recurringDetailReference,
                                                               string merchantAccount)
        {
            var request = Create(shopper, paymentReference, amount, currency, recurringDetailReference, merchantAccount);

            request.Recurring = new Adyen.EcommLibrary.Model.Reccuring.Recurring
            {
                Contract = Contract.Recurring
            };
            request.ShopperInteraction = ShopperInteraction.ContAuth;
            return(request);
        }
Ejemplo n.º 3
0
        public PaymentResult AuthoriseRecurringOnClick(int amount,
                                                       string currency,
                                                       Shopper shopper,
                                                       string paymentReference,
                                                       string recurringDetailReference,
                                                       string cardData)
        {
            var payment = new Payment(_client);

            var paymentRequest = PaymentRequestFactory.CreateForRecurringOneclickPayment(
                shopper, paymentReference,
                amount, currency, recurringDetailReference,
                _adyenConfiguration.MerchantAccount, cardData
                );

            return(payment.Authorise(paymentRequest));
        }
Ejemplo n.º 4
0
 private static PaymentRequest Create(
     Shopper shopper, string paymentReference,
     int amount, string currency,
     string recurringDetailReference, string merchantAccount)
 {
     return(new PaymentRequest
     {
         MerchantAccount = merchantAccount,
         Amount = new Amount(currency, amount),
         Reference = paymentReference,
         ShopperEmail = shopper.Email,
         ShopperReference = shopper.Reference,
         ShopperName = new Name
         {
             FirstName = shopper.FirstName,
             LastName = shopper.LastName
         },
         SelectedRecurringDetailReference = recurringDetailReference,
     });
 }
Ejemplo n.º 5
0
        public static PaymentRequest CreateForRecurringOneclickPayment(Shopper shopper,
                                                                       string paymentReference,
                                                                       int amount,
                                                                       string currency,
                                                                       string recurringDetailReference,
                                                                       string merchantAccount,
                                                                       string cardData)
        {
            var request = Create(shopper, paymentReference, amount, currency, recurringDetailReference, merchantAccount);

            request.Recurring = new Adyen.EcommLibrary.Model.Reccuring.Recurring
            {
                Contract = Contract.Oneclick
            };
            request.AdditionalData = new Dictionary <string, string>
            {
                { "card.encrypted.json", cardData }
            };
            request.ShopperInteraction = ShopperInteraction.Ecommerce;
            return(request);
        }