protected void SaveRecurringDetailReference(Payment payment)
        {
            try
            {
                var result = RecurringClient.listRecurringDetails(new RecurringDetailsRequest
                {
                    shopperReference = payment.ReferenceId,
                    recurring        = new Adyen.Test.RecurringSoapService.Recurring
                    {
                        contract = "RECURRING"
                    },
                    merchantAccount = payment.PaymentMethod.DynamicProperty <string>().MerchantAccount
                });

                var latestDetail = result.details.OrderByDescending(x => x.creationDate).FirstOrDefault();

                if (latestDetail != null)
                {
                    payment[RecurringDetailReference] = latestDetail.recurringDetailReference;
                    payment.Save();
                }
                else
                {
                    throw new SecurityException("Could not retrive the recurring detail reference. Please make sure that recurring payments are activated for your account.");
                }
            }
            catch (Exception ex)
            {
                LoggingService.Log <AdyenPaymentMethodService>(
                    string.Format("Saving recurring detail reference failed for payment with reference id: {0}, exception: {1}",
                                  payment.ReferenceId,
                                  ex.Message));
            }
        }
Exemplo n.º 2
0
        static void Main()
        {
            using (var proxy = new RecurringClient())  // do not use RecurringPortTypeClient
            {
                try
                {
                    var thisUserDetail = new RecurringDetailsRequest();
                    thisUserDetail.shopperReference = "[Shopper Reference]";
                    thisUserDetail.recurring = new Adyen.RecurringSample.Adyen.Recurring.Recurring()
                    {
                        contract = "RECURRING"
                    };

                    var recContractDetails = proxy.ListRecurringDetails(thisUserDetail);
                    Trace.TraceInformation("Shoppermail {0}", recContractDetails.lastKnownShopperEmail);
                    Trace.TraceInformation("Creation date {0}", recContractDetails.creationDate.Value.ToShortDateString());
                    
                }
                catch (Exception ex)
                {
                    Trace.TraceError("error using RecurringClient.listRecurringDetails {0}", ex.Message);
                    
                    throw ex;
                }
            }
            ///etc...
            using (var proxy = new PaymentClient())
            {
                try
                {
                    var paymentRequest = new PaymentRequest();
                    
                    proxy.Authorise(paymentRequest);
                }
                catch (Exception ex)
                {
                }
            }

        }