//Use a loop to check the status of authorization. Once the status is not "PENDING", skip the loop.
        public static GetAuthorizationDetailsResponse CheckAuthorizationStatus(string amazonAuthorizationId, OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                               IOffAmazonPaymentsService service)
        {
            //used to check if the authorization is time-out
            TimeSpan startTime = DateTime.Now.TimeOfDay;
            GetAuthorizationDetailsRequest authDetailRequest = new GetAuthorizationDetailsRequest();

            authDetailRequest.SellerId = propertiesCollection.MerchantID;
            authDetailRequest.AmazonAuthorizationId = amazonAuthorizationId;

            GetAuthorizationDetailsResponse getAuthResponse = GetAuthorizationDetailsSample.InvokeGetAuthorizationDetails(service, authDetailRequest);

            while (getAuthResponse.IsSetGetAuthorizationDetailsResult() && getAuthResponse.GetAuthorizationDetailsResult.AuthorizationDetails.AuthorizationStatus.State.Equals(PaymentStatus.PENDING))
            {
                if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
                {
                    throw new OffAmazonPaymentsServiceException("The authorization is time-out.");
                }

                System.Threading.Thread.Sleep(8000);
                Console.WriteLine("Waiting until the Authorization Status becomes OPEN");
                getAuthResponse = GetAuthorizationDetailsSample.InvokeGetAuthorizationDetails(service, authDetailRequest);
            }

            return(getAuthResponse);
        }
        //Use a loop to check the status of authorization. Once the status is not "PENDING", skip the loop.
        public static GetAuthorizationDetailsResponse CheckAuthorizationStatus(string amazonAuthorizationId, OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service)
        {
            //used to check if the authorization is time-out
            TimeSpan startTime = DateTime.Now.TimeOfDay;
            GetAuthorizationDetailsRequest authDetailRequest = new GetAuthorizationDetailsRequest();
            authDetailRequest.SellerId = propertiesCollection.MerchantID;
            authDetailRequest.AmazonAuthorizationId = amazonAuthorizationId;

            GetAuthorizationDetailsResponse getAuthResponse = GetAuthorizationDetailsSample.InvokeGetAuthorizationDetails(service, authDetailRequest);
            while (getAuthResponse.IsSetGetAuthorizationDetailsResult() && getAuthResponse.GetAuthorizationDetailsResult.AuthorizationDetails.AuthorizationStatus.State.Equals(PaymentStatus.PENDING))
            {
                if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
                    throw new OffAmazonPaymentsServiceException("The authorization is time-out.");

                System.Threading.Thread.Sleep(8000);
                Console.WriteLine("Waiting until the Authorization Status becomes OPEN");
                getAuthResponse = GetAuthorizationDetailsSample.InvokeGetAuthorizationDetails(service, authDetailRequest);
            }

            return getAuthResponse;
        }
Example #3
0
        public AuthorizationDetails GetAuthorizationDetails(AmazonPayClient client, string authorizationId, out AmazonPayApiData data)
        {
            data = new AmazonPayApiData();

            AuthorizationDetails details = null;
            var request = new GetAuthorizationDetailsRequest();

            request.SellerId = client.Settings.SellerId;
            request.AmazonAuthorizationId = authorizationId;

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

            if (response.IsSetGetAuthorizationDetailsResult())
            {
                var result = response.GetAuthorizationDetailsResult;

                if (result != null && result.IsSetAuthorizationDetails())
                {
                    details = result.AuthorizationDetails;
                }
            }

            try
            {
                data.MessageType = "GetAuthorizationDetails";

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

                if (details != null)
                {
                    if (details.IsSetAmazonAuthorizationId())
                    {
                        data.AuthorizationId = details.AmazonAuthorizationId;
                    }

                    if (details.IsSetAuthorizationReferenceId())
                    {
                        data.ReferenceId = details.AuthorizationReferenceId;
                    }

                    if (details.IsSetIdList() && details.IdList.IsSetmember())
                    {
                        data.CaptureId = (details.IdList.member != null && details.IdList.member.Count > 0 ? details.IdList.member[0] : null);
                    }

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

                    if (details.IsSetAuthorizationAmount())
                    {
                        data.AuthorizedAmount = new AmazonPayApiPrice(details.AuthorizationAmount.Amount, details.AuthorizationAmount.CurrencyCode);
                    }

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

                    if (details.IsSetCaptureNow())
                    {
                        data.CaptureNow = details.CaptureNow;
                    }

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

                    if (details.IsSetExpirationTimestamp())
                    {
                        data.Expiration = details.ExpirationTimestamp;
                    }

                    if (details.IsSetAuthorizationStatus())
                    {
                        data.ReasonCode        = details.AuthorizationStatus.ReasonCode;
                        data.ReasonDescription = details.AuthorizationStatus.ReasonDescription;
                        data.State             = details.AuthorizationStatus.State.ToString();
                        data.StateLastUpdate   = details.AuthorizationStatus.LastUpdateTimestamp;
                    }
                }
            }
            catch (Exception exc)
            {
                exc.Dump();
            }
            return(details);
        }
        public AuthorizationDetails GetAuthorizationDetails(AmazonPayClient client, string authorizationId, out AmazonPayApiData data)
        {
            data = new AmazonPayApiData();

            AuthorizationDetails details = null;
            var request = new GetAuthorizationDetailsRequest();
            request.SellerId = client.Settings.SellerId;
            request.AmazonAuthorizationId = authorizationId;

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

            if (response.IsSetGetAuthorizationDetailsResult())
            {
                var result = response.GetAuthorizationDetailsResult;

                if (result != null && result.IsSetAuthorizationDetails())
                    details = result.AuthorizationDetails;
            }

            try
            {
                data.MessageType = "GetAuthorizationDetails";

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

                if (details != null)
                {
                    if (details.IsSetAmazonAuthorizationId())
                        data.AuthorizationId = details.AmazonAuthorizationId;

                    if (details.IsSetAuthorizationReferenceId())
                        data.ReferenceId = details.AuthorizationReferenceId;

                    if (details.IsSetIdList() && details.IdList.IsSetmember())
                        data.CaptureId = (details.IdList.member != null && details.IdList.member.Count > 0 ? details.IdList.member[0] : null);

                    if (details.IsSetAuthorizationFee())
                        data.Fee = new AmazonPayApiPrice(details.AuthorizationFee.Amount, details.AuthorizationFee.CurrencyCode);

                    if (details.IsSetAuthorizationAmount())
                        data.AuthorizedAmount = new AmazonPayApiPrice(details.AuthorizationAmount.Amount, details.AuthorizationAmount.CurrencyCode);

                    if (details.IsSetCapturedAmount())
                        data.CapturedAmount = new AmazonPayApiPrice(details.CapturedAmount.Amount, details.CapturedAmount.CurrencyCode);

                    if (details.IsSetCaptureNow())
                        data.CaptureNow = details.CaptureNow;

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

                    if (details.IsSetExpirationTimestamp())
                        data.Expiration = details.ExpirationTimestamp;

                    if (details.IsSetAuthorizationStatus())
                    {
                        data.ReasonCode = details.AuthorizationStatus.ReasonCode;
                        data.ReasonDescription = details.AuthorizationStatus.ReasonDescription;
                        data.State = details.AuthorizationStatus.State.ToString();
                        data.StateLastUpdate = details.AuthorizationStatus.LastUpdateTimestamp;
                    }
                }
            }
            catch (Exception exc)
            {
                exc.Dump();
            }
            return details;
        }
 public static GetAuthorizationDetailsResponse InvokeGetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request)
 {
     return GetAuthorizationDetails(service, request, Console.Out);
 }
 public static GetAuthorizationDetailsResponse GetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request, TextWriter buffer)
 {
     GetAuthorizationDetailsResponse response = GetAuthorizationDetails(service, request);
     printGetAuthorizationDetailsResponseToBuffer(response, buffer);
     return response;
 }
 private static GetAuthorizationDetailsResponse GetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request)
 {
     GetAuthorizationDetailsResponse response = null;
     response = service.GetAuthorizationDetails(request);
     return response;
 }
        private static GetAuthorizationDetailsResponse GetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request)
        {
            GetAuthorizationDetailsResponse response = null;

            response = service.GetAuthorizationDetails(request);
            return(response);
        }
        public static GetAuthorizationDetailsResponse GetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request, TextWriter buffer)
        {
            GetAuthorizationDetailsResponse response = GetAuthorizationDetails(service, request);

            printGetAuthorizationDetailsResponseToBuffer(response, buffer);
            return(response);
        }
 public static GetAuthorizationDetailsResponse InvokeGetAuthorizationDetails(IOffAmazonPaymentsService service, GetAuthorizationDetailsRequest request)
 {
     return(GetAuthorizationDetails(service, request, Console.Out));
 }