示例#1
0
        public CaptureDetails GetCaptureDetails(AmazonPayClient client, string captureId, out AmazonPayApiData data)
        {
            data = new AmazonPayApiData();

            CaptureDetails details = null;
            var            request = new GetCaptureDetailsRequest();

            request.SellerId        = client.Settings.SellerId;
            request.AmazonCaptureId = captureId;

            var response = client.Service.GetCaptureDetails(request);

            if (response != null && response.IsSetGetCaptureDetailsResult())
            {
                var result = response.GetCaptureDetailsResult;
                if (result != null && result.IsSetCaptureDetails())
                {
                    details = result.CaptureDetails;
                }
            }

            try
            {
                data.MessageType = "GetCaptureDetails";

                if (response.IsSetResponseMetadata() && response.ResponseMetadata.IsSetRequestId())
                {
                    data.MessageId = response.ResponseMetadata.RequestId;
                }

                if (details != null)
                {
                    if (details.IsSetAmazonCaptureId())
                    {
                        data.CaptureId = details.AmazonCaptureId;
                    }

                    if (details.IsSetCaptureReferenceId())
                    {
                        data.ReferenceId = details.CaptureReferenceId;
                    }

                    if (details.IsSetCaptureFee())
                    {
                        data.Fee = new AmazonPayApiPrice(details.CaptureFee.Amount, details.CaptureFee.CurrencyCode);
                    }

                    if (details.IsSetCaptureAmount())
                    {
                        data.CapturedAmount = new AmazonPayApiPrice(details.CaptureAmount.Amount, details.CaptureAmount.CurrencyCode);
                    }

                    if (details.IsSetRefundedAmount())
                    {
                        data.RefundedAmount = new AmazonPayApiPrice(details.RefundedAmount.Amount, details.RefundedAmount.CurrencyCode);
                    }

                    if (details.IsSetCreationTimestamp())
                    {
                        data.Creation = details.CreationTimestamp;
                    }

                    if (details.IsSetCaptureStatus())
                    {
                        data.ReasonCode        = details.CaptureStatus.ReasonCode;
                        data.ReasonDescription = details.CaptureStatus.ReasonDescription;
                        data.State             = details.CaptureStatus.State.ToString();
                        data.StateLastUpdate   = details.CaptureStatus.LastUpdateTimestamp;
                    }
                }
            }
            catch (Exception exc)
            {
                exc.Dump();
            }
            return(details);
        }
示例#2
0
        public static CaptureResponse InvokeCapture(IOffAmazonPaymentsService service, CaptureRequest request)
        {
            CaptureResponse response = null;

            try
            {
                response = service.Capture(request);
                Console.WriteLine("Service Response");
                Console.WriteLine("=============================================================================");
                Console.WriteLine();
                Console.WriteLine("        CaptureResponse");
                if (response.IsSetCaptureResult())
                {
                    Console.WriteLine("            CaptureResult");
                    CaptureResult captureResult = response.CaptureResult;
                    if (captureResult.IsSetCaptureDetails())
                    {
                        Console.WriteLine("                CaptureDetails");
                        CaptureDetails captureDetails = captureResult.CaptureDetails;
                        if (captureDetails.IsSetAmazonCaptureId())
                        {
                            Console.WriteLine("                    AmazonCaptureId");
                            Console.WriteLine("                        {0}", captureDetails.AmazonCaptureId);
                        }
                        if (captureDetails.IsSetCaptureReferenceId())
                        {
                            Console.WriteLine("                    CaptureReferenceId");
                            Console.WriteLine("                        {0}", captureDetails.CaptureReferenceId);
                        }
                        if (captureDetails.IsSetSellerCaptureNote())
                        {
                            Console.WriteLine("                    SellerCaptureNote");
                            Console.WriteLine("                        {0}", captureDetails.SellerCaptureNote);
                        }
                        if (captureDetails.IsSetCaptureAmount())
                        {
                            Console.WriteLine("                    CaptureAmount");
                            Price captureAmount = captureDetails.CaptureAmount;
                            if (captureAmount.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", captureAmount.Amount);
                            }
                            if (captureAmount.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", captureAmount.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetRefundedAmount())
                        {
                            Console.WriteLine("                    RefundedAmount");
                            Price refundedAmount = captureDetails.RefundedAmount;
                            if (refundedAmount.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", refundedAmount.Amount);
                            }
                            if (refundedAmount.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", refundedAmount.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetCaptureFee())
                        {
                            Console.WriteLine("                    CaptureFee");
                            Price captureFee = captureDetails.CaptureFee;
                            if (captureFee.IsSetAmount())
                            {
                                Console.WriteLine("                        Amount");
                                Console.WriteLine("                            {0}", captureFee.Amount);
                            }
                            if (captureFee.IsSetCurrencyCode())
                            {
                                Console.WriteLine("                        CurrencyCode");
                                Console.WriteLine("                            {0}", captureFee.CurrencyCode);
                            }
                        }
                        if (captureDetails.IsSetCreationTimestamp())
                        {
                            Console.WriteLine("                    CreationTimestamp");
                            Console.WriteLine("                        {0}", captureDetails.CreationTimestamp);
                        }
                        if (captureDetails.IsSetProviderCreditSummaryList())
                        {
                            Console.WriteLine("                    ProviderCreditSummaryList");
                            foreach (ProviderCreditSummary providerCreditSummary in captureDetails.ProviderCreditSummaryList.member)
                            {
                                if (providerCreditSummary.IsSetProviderCreditId())
                                {
                                    Console.WriteLine("                         ProviderCreditId");
                                    Console.WriteLine("                             {0}", providerCreditSummary.ProviderCreditId);
                                }
                                if (providerCreditSummary.IsSetProviderId())
                                {
                                    Console.WriteLine("                         ProviderId");
                                    Console.WriteLine("                             {0}", providerCreditSummary.ProviderId);
                                }
                            }
                        }
                        if (captureDetails.IsSetCaptureStatus())
                        {
                            Console.WriteLine("                    CaptureStatus");
                            Status captureStatus = captureDetails.CaptureStatus;
                            if (captureStatus.IsSetState())
                            {
                                Console.WriteLine("                        State");
                                Console.WriteLine("                            {0}", captureStatus.State);
                            }
                            if (captureStatus.IsSetLastUpdateTimestamp())
                            {
                                Console.WriteLine("                        LastUpdateTimestamp");
                                Console.WriteLine("                            {0}", captureStatus.LastUpdateTimestamp);
                            }
                            if (captureStatus.IsSetReasonCode())
                            {
                                Console.WriteLine("                        ReasonCode");
                                Console.WriteLine("                            {0}", captureStatus.ReasonCode);
                            }
                            if (captureStatus.IsSetReasonDescription())
                            {
                                Console.WriteLine("                        ReasonDescription");
                                Console.WriteLine("                            {0}", captureStatus.ReasonDescription);
                            }
                        }
                    }
                }

                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }

                Console.WriteLine();
            }

            catch (OffAmazonPaymentsServiceException ex)
            {
                PrintException(ex);
            }

            return(response);
        }