当前位置: 首页>>代码示例>>C#>>正文


C# IPayment.SavePayPalTransactionRecord方法代码示例

本文整理汇总了C#中IPayment.SavePayPalTransactionRecord方法的典型用法代码示例。如果您正苦于以下问题:C# IPayment.SavePayPalTransactionRecord方法的具体用法?C# IPayment.SavePayPalTransactionRecord怎么用?C# IPayment.SavePayPalTransactionRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPayment的用法示例。


在下文中一共展示了IPayment.SavePayPalTransactionRecord方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PerformCapturePayment

        /// <summary>
        /// Performs the capture payment operation.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="amount">
        /// The amount.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformCapturePayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args)
        {
            // We need to determine if the entire amount authorized has been collected before marking
            // the payment collected.
            var appliedPayments = GatewayProviderService.GetAppliedPaymentsByPaymentKey(payment.Key);
            var applied = appliedPayments.Sum(x => x.Amount);

            var isPartialPayment = amount - applied <= 0;

            var processor = new PayPalExpressCheckoutPaymentProcessor(_paypalApiService);
            var record = processor.VerifySuccessAuthorziation(invoice, payment);

            if (record.Success)
            {
                record = _paypalApiService.ExpressCheckout.Capture(invoice, payment, amount, isPartialPayment);
                payment.SavePayPalTransactionRecord(record);

                payment.Collected = (amount + applied) == payment.Amount;
                payment.Authorized = true;

                GatewayProviderService.Save(payment);

                GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "PayPal ExpressCheckout SUCCESS payment", amount);

                return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, CalculateTotalOwed(invoice).CompareTo(amount) <= 0);
            }

            return new PaymentResult(Attempt<IPayment>.Fail(payment), invoice, false);
        }
开发者ID:rustyswayne,项目名称:Merchello,代码行数:47,代码来源:PayPalExpressCheckoutPaymentGatewayMethod.cs

示例2: PerformRefundPayment

        /// <summary>
        /// Performs a refund or a partial refund.
        /// </summary>
        /// <param name="invoice">
        /// The invoice.
        /// </param>
        /// <param name="payment">
        /// The payment.
        /// </param>
        /// <param name="amount">
        /// The amount.
        /// </param>
        /// <param name="args">
        /// The processor arguments.
        /// </param>
        /// <returns>
        /// The <see cref="IPaymentResult"/>.
        /// </returns>
        protected override IPaymentResult PerformRefundPayment(IInvoice invoice, IPayment payment, decimal amount, ProcessorArgumentCollection args)
        {
            var record = payment.GetPayPalTransactionRecord();

            if (StringExtensions.IsNullOrWhiteSpace(record.Data.CaptureTransactionId))
            {
                var error = new NullReferenceException("PayPal transaction could not be found and/or deserialized from payment extended data collection");
                return new PaymentResult(Attempt<IPayment>.Fail(payment, error), invoice, false);
            }

            var attempt = _paypalApiService.ExpressCheckout.Refund(invoice, payment, amount);

            // store the transaction
            var refundTransActions = record.RefundTransactions.ToList();
            refundTransActions.Add(attempt);
            record.RefundTransactions = refundTransActions;

            if (!attempt.Success())
            {
                // In the case of a failure, package up the exception so we can bubble it up.
                var ex = new PayPalApiException("PayPal Checkout Express refund response ACK was not Success");
                if (record.SetExpressCheckout.ErrorTypes.Any()) ex.ErrorTypes = record.SetExpressCheckout.ErrorTypes;

                // ensure that transaction is stored in the payment
                payment.SavePayPalTransactionRecord(record);
                GatewayProviderService.Save(payment);

                return new PaymentResult(Attempt<IPayment>.Fail(payment, ex), invoice, false);
            }

            foreach (var applied in payment.AppliedPayments())
            {
                applied.TransactionType = AppliedPaymentType.Refund;
                applied.Amount = 0;
                applied.Description += " - Refunded";
                this.GatewayProviderService.Save(applied);
            }

            payment.Amount = payment.Amount - amount;

            if (payment.Amount != 0)
            {
                this.GatewayProviderService.ApplyPaymentToInvoice(payment.Key, invoice.Key, AppliedPaymentType.Debit, "To show partial payment remaining after refund", payment.Amount);
            }

            this.GatewayProviderService.Save(payment);

            return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, false);
        }
开发者ID:rustyswayne,项目名称:Merchello,代码行数:67,代码来源:PayPalExpressCheckoutPaymentGatewayMethod.cs

示例3: Process

 /// <summary>
 /// Processes the payment.
 /// </summary>
 /// <param name="payment">
 /// The payment.
 /// </param>
 /// <param name="record">
 /// The record.
 /// </param>
 /// <returns>
 /// The <see cref="PayPalExpressTransactionRecord"/>.
 /// </returns>
 private PayPalExpressTransactionRecord Process(IPayment payment, PayPalExpressTransactionRecord record)
 {
     payment.SavePayPalTransactionRecord(record);
     return record;
 }
开发者ID:jlarc,项目名称:Merchello,代码行数:17,代码来源:PayPalExpressCheckoutPaymentProcessor.cs


注:本文中的IPayment.SavePayPalTransactionRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。