コード例 #1
0
        private void DoSyncZeroValuePaymentProviderContinueUrl(IPublishedContent confirmationNode)
        {
            if (confirmationNode == null)
            {
                return;
            }

            var store = confirmationNode.Value <StoreReadOnly>(Umbraco.Constants.Properties.StorePropertyAlias, fallback: Fallback.ToAncestors);

            if (store == null)
            {
                return;
            }

            var paymentMethod = _vendrApi.GetPaymentMethod(store.Id, VendrCheckoutConstants.PaymentMethods.Aliases.ZeroValue);

            if (paymentMethod == null)
            {
                return;
            }

            using (var uow = _vendrApi.Uow.Create())
            {
                var writable = paymentMethod.AsWritable(uow)
                               .SetSetting("ContinueUrl", confirmationNode.Url());

                _vendrApi.SavePaymentMethod(writable);

                uow.Complete();
            }
        }
コード例 #2
0
        public override PipelineResult <InstallPipelineContext> Execute(PipelineArgs <InstallPipelineContext> args)
        {
            using (var uow = _vendrApi.Uow.Create())
            {
                if (!_vendrApi.PaymentMethodExists(args.Model.Store.Id, VendrCheckoutConstants.PaymentMethods.Aliases.ZeroValue))
                {
                    var paymentMethod = PaymentMethod.Create(uow, args.Model.Store.Id, VendrCheckoutConstants.PaymentMethods.Aliases.ZeroValue, "[Vendr Checkout] Zero Value", "zeroValue");

                    paymentMethod.SetSku("VCZV01")
                    .SetTaxClass(args.Model.Store.DefaultTaxClassId.Value)
                    .AllowInCountry(args.Model.Store.DefaultCountryId.Value);

                    // We need to set the Continue URL to the checkout confirmation page
                    // but we create nodes as unpublished, thus without a URL so we'll
                    // have to listen for the confirmation page being published and
                    // sync it's URL accordingly

                    _vendrApi.SavePaymentMethod(paymentMethod);
                }

                uow.Complete();
            }

            return(Ok());
        }