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 void printGetAuthorizationDetailsResponseToBuffer(GetAuthorizationDetailsResponse response, TextWriter writer) { writer.WriteLine("Service Response"); writer.WriteLine("============================================================================="); writer.WriteLine(); writer.WriteLine(" GetAuthorizationDetailsResponse"); if (response.IsSetGetAuthorizationDetailsResult()) { writer.WriteLine(" GetAuthorizationDetailsResult"); GetAuthorizationDetailsResult getAuthorizationDetailsResult = response.GetAuthorizationDetailsResult; if (getAuthorizationDetailsResult.IsSetAuthorizationDetails()) { writer.WriteLine(" AuthorizationDetails"); AuthorizationDetails authorizationDetails = getAuthorizationDetailsResult.AuthorizationDetails; if (authorizationDetails.IsSetAmazonAuthorizationId()) { writer.WriteLine(" AmazonAuthorizationId"); writer.WriteLine(" {0}", authorizationDetails.AmazonAuthorizationId); } if (authorizationDetails.IsSetAuthorizationReferenceId()) { writer.WriteLine(" AuthorizationReferenceId"); writer.WriteLine(" {0}", authorizationDetails.AuthorizationReferenceId); } if (authorizationDetails.IsSetAuthorizationBillingAddress()) { writer.WriteLine(" AuthorizationBillingAddress"); Address authorizationBillingAddress = authorizationDetails.AuthorizationBillingAddress; if (authorizationBillingAddress.IsSetName()) { writer.WriteLine(" Name"); writer.WriteLine(" {0}", authorizationBillingAddress.Name); } if (authorizationBillingAddress.IsSetAddressLine1()) { writer.WriteLine(" AddressLine1"); writer.WriteLine(" {0}", authorizationBillingAddress.AddressLine1); } if (authorizationBillingAddress.IsSetAddressLine2()) { writer.WriteLine(" AddressLine2"); writer.WriteLine(" {0}", authorizationBillingAddress.AddressLine2); } if (authorizationBillingAddress.IsSetAddressLine3()) { writer.WriteLine(" AddressLine3"); writer.WriteLine(" {0}", authorizationBillingAddress.AddressLine3); } if (authorizationBillingAddress.IsSetCity()) { writer.WriteLine(" City"); writer.WriteLine(" {0}", authorizationBillingAddress.City); } if (authorizationBillingAddress.IsSetCounty()) { writer.WriteLine(" County"); writer.WriteLine(" {0}", authorizationBillingAddress.County); } if (authorizationBillingAddress.IsSetDistrict()) { writer.WriteLine(" District"); writer.WriteLine(" {0}", authorizationBillingAddress.District); } if (authorizationBillingAddress.IsSetStateOrRegion()) { writer.WriteLine(" StateOrRegion"); writer.WriteLine(" {0}", authorizationBillingAddress.StateOrRegion); } if (authorizationBillingAddress.IsSetPostalCode()) { writer.WriteLine(" PostalCode"); writer.WriteLine(" {0}", authorizationBillingAddress.PostalCode); } if (authorizationBillingAddress.IsSetCountryCode()) { writer.WriteLine(" CountryCode"); writer.WriteLine(" {0}", authorizationBillingAddress.CountryCode); } if (authorizationBillingAddress.IsSetPhone()) { writer.WriteLine(" Phone"); writer.WriteLine(" {0}", authorizationBillingAddress.Phone); } } if (authorizationDetails.IsSetSellerAuthorizationNote()) { writer.WriteLine(" SellerAuthorizationNote"); writer.WriteLine(" {0}", authorizationDetails.SellerAuthorizationNote); } if (authorizationDetails.IsSetAuthorizationAmount()) { writer.WriteLine(" AuthorizationAmount"); Price authorizationAmount = authorizationDetails.AuthorizationAmount; if (authorizationAmount.IsSetAmount()) { writer.WriteLine(" Amount"); writer.WriteLine(" {0}", authorizationAmount.Amount); } if (authorizationAmount.IsSetCurrencyCode()) { writer.WriteLine(" CurrencyCode"); writer.WriteLine(" {0}", authorizationAmount.CurrencyCode); } } if (authorizationDetails.IsSetCapturedAmount()) { writer.WriteLine(" CapturedAmount"); Price capturedAmount = authorizationDetails.CapturedAmount; if (capturedAmount.IsSetAmount()) { writer.WriteLine(" Amount"); writer.WriteLine(" {0}", capturedAmount.Amount); } if (capturedAmount.IsSetCurrencyCode()) { writer.WriteLine(" CurrencyCode"); writer.WriteLine(" {0}", capturedAmount.CurrencyCode); } } if (authorizationDetails.IsSetAuthorizationFee()) { writer.WriteLine(" AuthorizationFee"); Price authorizationFee = authorizationDetails.AuthorizationFee; if (authorizationFee.IsSetAmount()) { writer.WriteLine(" Amount"); writer.WriteLine(" {0}", authorizationFee.Amount); } if (authorizationFee.IsSetCurrencyCode()) { writer.WriteLine(" CurrencyCode"); writer.WriteLine(" {0}", authorizationFee.CurrencyCode); } } if (authorizationDetails.IsSetCreationTimestamp()) { writer.WriteLine(" CreationTimestamp"); writer.WriteLine(" {0}", authorizationDetails.CreationTimestamp); } if (authorizationDetails.IsSetExpirationTimestamp()) { writer.WriteLine(" ExpirationTimestamp"); writer.WriteLine(" {0}", authorizationDetails.ExpirationTimestamp); } if (authorizationDetails.IsSetAuthorizationStatus()) { writer.WriteLine(" AuthorizationStatus"); Status authorizationStatus = authorizationDetails.AuthorizationStatus; if (authorizationStatus.IsSetState()) { writer.WriteLine(" State"); writer.WriteLine(" {0}", authorizationStatus.State); } if (authorizationStatus.IsSetLastUpdateTimestamp()) { writer.WriteLine(" LastUpdateTimestamp"); writer.WriteLine(" {0}", authorizationStatus.LastUpdateTimestamp); } if (authorizationStatus.IsSetReasonCode()) { writer.WriteLine(" ReasonCode"); writer.WriteLine(" {0}", authorizationStatus.ReasonCode); } if (authorizationStatus.IsSetReasonDescription()) { writer.WriteLine(" ReasonDescription"); writer.WriteLine(" {0}", authorizationStatus.ReasonDescription); } if (authorizationDetails.IsSetAddressVerificationCode()) { writer.WriteLine(" AddressVerificationCode"); writer.WriteLine(" {0}", authorizationDetails.AddressVerificationCode); } } } } if (response.IsSetResponseMetadata()) { writer.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { writer.WriteLine(" RequestId"); writer.WriteLine(" {0}", responseMetadata.RequestId); } } }
public static AuthorizeOnBillingAgreementResponse InvokeAuthorizeOnBillingAgreement(IOffAmazonPaymentsService service, AuthorizeOnBillingAgreementRequest request) { AuthorizeOnBillingAgreementResponse response = null; try { response = service.AuthorizeOnBillingAgreement(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" AuthorizeOnBillingAgreementResponse"); if (response.IsSetAuthorizeOnBillingAgreementResult()) { Console.WriteLine(" AuthorizeOnBillingAgreementResult"); AuthorizeOnBillingAgreementResult authorizeOnBillingAgreementResult = response.AuthorizeOnBillingAgreementResult; if (authorizeOnBillingAgreementResult.IsSetAuthorizationDetails()) { Console.WriteLine(" AuthorizationDetails"); AuthorizationDetails authorizationDetails = authorizeOnBillingAgreementResult.AuthorizationDetails; if (authorizationDetails.IsSetAmazonAuthorizationId()) { Console.WriteLine(" AmazonAuthorizationId"); Console.WriteLine(" {0}", authorizationDetails.AmazonAuthorizationId); } if (authorizationDetails.IsSetAuthorizationReferenceId()) { Console.WriteLine(" AuthorizationReferenceId"); Console.WriteLine(" {0}", authorizationDetails.AuthorizationReferenceId); } if (authorizationDetails.IsSetAuthorizationBillingAddress()) { Console.WriteLine(" AuthorizationBillingAddress"); Address authorizationBillingAddress = authorizationDetails.AuthorizationBillingAddress; if (authorizationBillingAddress.IsSetName()) { Console.WriteLine(" Name"); Console.WriteLine(" {0}", authorizationBillingAddress.Name); } if (authorizationBillingAddress.IsSetAddressLine1()) { Console.WriteLine(" AddressLine1"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine1); } if (authorizationBillingAddress.IsSetAddressLine2()) { Console.WriteLine(" AddressLine2"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine2); } if (authorizationBillingAddress.IsSetAddressLine3()) { Console.WriteLine(" AddressLine3"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine3); } if (authorizationBillingAddress.IsSetCity()) { Console.WriteLine(" City"); Console.WriteLine(" {0}", authorizationBillingAddress.City); } if (authorizationBillingAddress.IsSetCounty()) { Console.WriteLine(" County"); Console.WriteLine(" {0}", authorizationBillingAddress.County); } if (authorizationBillingAddress.IsSetDistrict()) { Console.WriteLine(" District"); Console.WriteLine(" {0}", authorizationBillingAddress.District); } if (authorizationBillingAddress.IsSetStateOrRegion()) { Console.WriteLine(" StateOrRegion"); Console.WriteLine(" {0}", authorizationBillingAddress.StateOrRegion); } if (authorizationBillingAddress.IsSetPostalCode()) { Console.WriteLine(" PostalCode"); Console.WriteLine(" {0}", authorizationBillingAddress.PostalCode); } if (authorizationBillingAddress.IsSetCountryCode()) { Console.WriteLine(" CountryCode"); Console.WriteLine(" {0}", authorizationBillingAddress.CountryCode); } if (authorizationBillingAddress.IsSetPhone()) { Console.WriteLine(" Phone"); Console.WriteLine(" {0}", authorizationBillingAddress.Phone); } } if (authorizationDetails.IsSetSellerAuthorizationNote()) { Console.WriteLine(" SellerAuthorizationNote"); Console.WriteLine(" {0}", authorizationDetails.SellerAuthorizationNote); } if (authorizationDetails.IsSetAuthorizationAmount()) { Console.WriteLine(" AuthorizationAmount"); Price authorizationAmount = authorizationDetails.AuthorizationAmount; if (authorizationAmount.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", authorizationAmount.Amount); } if (authorizationAmount.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", authorizationAmount.CurrencyCode); } } if (authorizationDetails.IsSetCapturedAmount()) { Console.WriteLine(" CapturedAmount"); Price capturedAmount = authorizationDetails.CapturedAmount; if (capturedAmount.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", capturedAmount.Amount); } if (capturedAmount.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", capturedAmount.CurrencyCode); } } if (authorizationDetails.IsSetAuthorizationFee()) { Console.WriteLine(" AuthorizationFee"); Price authorizationFee = authorizationDetails.AuthorizationFee; if (authorizationFee.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", authorizationFee.Amount); } if (authorizationFee.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", authorizationFee.CurrencyCode); } } if (authorizationDetails.IsSetIdList()) { Console.WriteLine(" IdList"); IdList idList = authorizationDetails.IdList; List <String> memberList = idList.member; foreach (String member in memberList) { Console.WriteLine(" member"); Console.WriteLine(" {0}", member); } } if (authorizationDetails.IsSetCreationTimestamp()) { Console.WriteLine(" CreationTimestamp"); Console.WriteLine(" {0}", authorizationDetails.CreationTimestamp); } if (authorizationDetails.IsSetExpirationTimestamp()) { Console.WriteLine(" ExpirationTimestamp"); Console.WriteLine(" {0}", authorizationDetails.ExpirationTimestamp); } if (authorizationDetails.IsSetAuthorizationStatus()) { Console.WriteLine(" AuthorizationStatus"); Status authorizationStatus = authorizationDetails.AuthorizationStatus; if (authorizationStatus.IsSetState()) { Console.WriteLine(" State"); Console.WriteLine(" {0}", authorizationStatus.State); } if (authorizationStatus.IsSetLastUpdateTimestamp()) { Console.WriteLine(" LastUpdateTimestamp"); Console.WriteLine(" {0}", authorizationStatus.LastUpdateTimestamp); } if (authorizationStatus.IsSetReasonCode()) { Console.WriteLine(" ReasonCode"); Console.WriteLine(" {0}", authorizationStatus.ReasonCode); } if (authorizationStatus.IsSetReasonDescription()) { Console.WriteLine(" ReasonDescription"); Console.WriteLine(" {0}", authorizationStatus.ReasonDescription); } } if (authorizationDetails.IsSetOrderItemCategories()) { Console.WriteLine(" OrderItemCategories"); OrderItemCategories orderItemCategories = authorizationDetails.OrderItemCategories; List <String> orderItemCategoryList = orderItemCategories.OrderItemCategory; foreach (String orderItemCategory in orderItemCategoryList) { Console.WriteLine(" OrderItemCategory"); Console.WriteLine(" {0}", orderItemCategory); } } if (authorizationDetails.IsSetCaptureNow()) { Console.WriteLine(" CaptureNow"); Console.WriteLine(" {0}", authorizationDetails.CaptureNow); } if (authorizationDetails.IsSetSoftDescriptor()) { Console.WriteLine(" SoftDescriptor"); Console.WriteLine(" {0}", authorizationDetails.SoftDescriptor); } if (authorizationDetails.IsSetAddressVerificationCode()) { Console.WriteLine(" AddressVerificationCode"); Console.WriteLine(" {0}", authorizationDetails.AddressVerificationCode); } } if (authorizeOnBillingAgreementResult.IsSetAmazonOrderReferenceId()) { Console.WriteLine(" AmazonOrderReferenceId"); Console.WriteLine(" {0}", authorizeOnBillingAgreementResult.AmazonOrderReferenceId); } } if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } } catch (OffAmazonPaymentsServiceException ex) { PrintException(ex); } return(response); }
public static AuthorizeResponse InvokeAuthorize(IOffAmazonPaymentsService service, AuthorizeRequest request) { AuthorizeResponse response = null; try { response = service.Authorize(request); Console.WriteLine("Service Response"); Console.WriteLine("============================================================================="); Console.WriteLine(); Console.WriteLine(" AuthorizeResponse"); if (response.IsSetAuthorizeResult()) { Console.WriteLine(" AuthorizeResult"); AuthorizeResult authorizeResult = response.AuthorizeResult; if (authorizeResult.IsSetAuthorizationDetails()) { Console.WriteLine(" AuthorizationDetails"); AuthorizationDetails authorizationDetails = authorizeResult.AuthorizationDetails; if (authorizationDetails.IsSetAmazonAuthorizationId()) { Console.WriteLine(" AmazonAuthorizationId"); Console.WriteLine(" {0}", authorizationDetails.AmazonAuthorizationId); } if (authorizationDetails.IsSetAuthorizationReferenceId()) { Console.WriteLine(" AuthorizationReferenceId"); Console.WriteLine(" {0}", authorizationDetails.AuthorizationReferenceId); } if (authorizationDetails.IsSetAuthorizationBillingAddress()) { Console.WriteLine(" AuthorizationBillingAddress"); Address authorizationBillingAddress = authorizationDetails.AuthorizationBillingAddress; if (authorizationBillingAddress.IsSetName()) { Console.WriteLine(" Name"); Console.WriteLine(" {0}", authorizationBillingAddress.Name); } if (authorizationBillingAddress.IsSetAddressLine1()) { Console.WriteLine(" AddressLine1"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine1); } if (authorizationBillingAddress.IsSetAddressLine2()) { Console.WriteLine(" AddressLine2"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine2); } if (authorizationBillingAddress.IsSetAddressLine3()) { Console.WriteLine(" AddressLine3"); Console.WriteLine(" {0}", authorizationBillingAddress.AddressLine3); } if (authorizationBillingAddress.IsSetCity()) { Console.WriteLine(" City"); Console.WriteLine(" {0}", authorizationBillingAddress.City); } if (authorizationBillingAddress.IsSetCounty()) { Console.WriteLine(" County"); Console.WriteLine(" {0}", authorizationBillingAddress.County); } if (authorizationBillingAddress.IsSetDistrict()) { Console.WriteLine(" District"); Console.WriteLine(" {0}", authorizationBillingAddress.District); } if (authorizationBillingAddress.IsSetStateOrRegion()) { Console.WriteLine(" StateOrRegion"); Console.WriteLine(" {0}", authorizationBillingAddress.StateOrRegion); } if (authorizationBillingAddress.IsSetPostalCode()) { Console.WriteLine(" PostalCode"); Console.WriteLine(" {0}", authorizationBillingAddress.PostalCode); } if (authorizationBillingAddress.IsSetCountryCode()) { Console.WriteLine(" CountryCode"); Console.WriteLine(" {0}", authorizationBillingAddress.CountryCode); } if (authorizationBillingAddress.IsSetPhone()) { Console.WriteLine(" Phone"); Console.WriteLine(" {0}", authorizationBillingAddress.Phone); } } if (authorizationDetails.IsSetSellerAuthorizationNote()) { Console.WriteLine(" SellerAuthorizationNote"); Console.WriteLine(" {0}", authorizationDetails.SellerAuthorizationNote); } if (authorizationDetails.IsSetAuthorizationAmount()) { Console.WriteLine(" AuthorizationAmount"); Price authorizationAmount = authorizationDetails.AuthorizationAmount; if (authorizationAmount.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", authorizationAmount.Amount); } if (authorizationAmount.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", authorizationAmount.CurrencyCode); } } if (authorizationDetails.IsSetCapturedAmount()) { Console.WriteLine(" CapturedAmount"); Price capturedAmount = authorizationDetails.CapturedAmount; if (capturedAmount.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", capturedAmount.Amount); } if (capturedAmount.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", capturedAmount.CurrencyCode); } } if (authorizationDetails.IsSetAuthorizationFee()) { Console.WriteLine(" AuthorizationFee"); Price authorizationFee = authorizationDetails.AuthorizationFee; if (authorizationFee.IsSetAmount()) { Console.WriteLine(" Amount"); Console.WriteLine(" {0}", authorizationFee.Amount); } if (authorizationFee.IsSetCurrencyCode()) { Console.WriteLine(" CurrencyCode"); Console.WriteLine(" {0}", authorizationFee.CurrencyCode); } } if (authorizationDetails.IsSetCreationTimestamp()) { Console.WriteLine(" CreationTimestamp"); Console.WriteLine(" {0}", authorizationDetails.CreationTimestamp); } if (authorizationDetails.IsSetExpirationTimestamp()) { Console.WriteLine(" ExpirationTimestamp"); Console.WriteLine(" {0}", authorizationDetails.ExpirationTimestamp); } if (authorizationDetails.IsSetAuthorizationStatus()) { Console.WriteLine(" AuthorizationStatus"); Status authorizationStatus = authorizationDetails.AuthorizationStatus; if (authorizationStatus.IsSetState()) { Console.WriteLine(" State"); Console.WriteLine(" {0}", authorizationStatus.State); } if (authorizationStatus.IsSetLastUpdateTimestamp()) { Console.WriteLine(" LastUpdateTimestamp"); Console.WriteLine(" {0}", authorizationStatus.LastUpdateTimestamp); } if (authorizationStatus.IsSetReasonCode()) { Console.WriteLine(" ReasonCode"); Console.WriteLine(" {0}", authorizationStatus.ReasonCode); } if (authorizationStatus.IsSetReasonDescription()) { Console.WriteLine(" ReasonDescription"); Console.WriteLine(" {0}", authorizationStatus.ReasonDescription); } } if (authorizationDetails.IsSetAddressVerificationCode()) { Console.WriteLine(" AddressVerificationCode"); Console.WriteLine(" {0}", authorizationDetails.AddressVerificationCode); } } } } catch (OffAmazonPaymentsServiceException ex) { PrintException(ex); } return(response); }