public static CaptureResponse CaptureAction(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service, string amazonAuthorizationId, string orderAmount, string orderReferenceId, int indicator, string providerId, string creditAmountString)
        {
            //initiate the capture request
            CaptureRequest captureRequest = new CaptureRequest();
            captureRequest.SellerId = propertiesCollection.MerchantID;
            captureRequest.AmazonAuthorizationId = amazonAuthorizationId;

            Price price = new Price();
            price.Amount = orderAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;

            captureRequest.CaptureAmount = price;
            captureRequest.CaptureReferenceId = orderReferenceId.Replace('-', 'c') + "captureRef" + indicator.ToString();
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditAmountString))
            {
                ProviderCredit providerCredit = new ProviderCredit();
                providerCredit.ProviderId= providerId;
                Price creditAmount = new Price();
                creditAmount.Amount = creditAmountString;
                creditAmount.CurrencyCode = propertiesCollection.CurrencyCode;
                providerCredit.CreditAmount= creditAmount;
                ProviderCreditList providerCreditList = new ProviderCreditList();
                providerCreditList.member = new List<ProviderCredit>();
                providerCreditList.member.Add(providerCredit);
                captureRequest.ProviderCreditList = providerCreditList;
            }

            return CaptureSample.InvokeCapture(service, captureRequest);
        }
 public static GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails( IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, string providerCreditReversalId)
 {
     GetProviderCreditReversalDetailsRequest getProviderCreditReversalDetailsRequest = new GetProviderCreditReversalDetailsRequest();
     getProviderCreditReversalDetailsRequest.AmazonProviderCreditReversalId = providerCreditReversalId;
     getProviderCreditReversalDetailsRequest.SellerId = propertiesCollection.MerchantID;
     return GetProviderCreditReversalDetailsSample.InvokeGetProviderCreditReversalDetails(service, getProviderCreditReversalDetailsRequest);
 }
 public static GetOrderReferenceDetailsResponse GetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken, TextWriter buffer)
 {
     GetOrderReferenceDetailsResponse response = InvokeGetOrderReferenceDetails(propertiesCollection, service, orderReferenceId, addressConsentToken);
     printOrderReferenceDetailsResponseToBuffer(response, buffer);
     return response;
 }
 /// <summary>
 /// Create a new instance of the Service Refund sample class
 /// </summary>
 public OffAmazonPaymentsServiceRefund()
 {
     // Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
     this._propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();
     this._service = new OffAmazonPaymentsServiceClient(this._propertiesCollection);
     this._rng     = new Random();
 }
        public static RefundResponse RefundAction(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, Random rng, string amazonCaptureID, string refundAmount, string providerId, string creditReversalAmountString)
        {
            //Initiate the Refund request, including SellerId, CaptureId, RefundReferenceId and RefundAmount
            RefundRequest request = new RefundRequest();

            request.SellerId          = propertiesCollection.MerchantID;
            request.AmazonCaptureId   = amazonCaptureID;
            request.RefundReferenceId = amazonCaptureID.Replace("-", "") + "r" + rng.Next(1, 1000).ToString();

            //assign the refundAmount to the refund request
            Price price = new Price();

            price.Amount         = refundAmount;
            price.CurrencyCode   = propertiesCollection.CurrencyCode;
            request.RefundAmount = price;
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditReversalAmountString))
            {
                ProviderCreditReversal providerCreditReversal = new ProviderCreditReversal();
                providerCreditReversal.ProviderId = providerId;
                Price creditReversalAmount = new Price();
                creditReversalAmount.Amount                 = creditReversalAmountString;
                creditReversalAmount.CurrencyCode           = propertiesCollection.CurrencyCode;
                providerCreditReversal.CreditReversalAmount = creditReversalAmount;
                ProviderCreditReversalList providerCreditReversalList = new ProviderCreditReversalList();
                providerCreditReversalList.member = new List <ProviderCreditReversal>();
                providerCreditReversalList.member.Add(providerCreditReversal);
                request.ProviderCreditReversalList = providerCreditReversalList;
            }
            return(RefundSample.InvokeRefund(service, request));
        }
 /// <summary>
 /// Create a new instance of the Service Refund sample class
 /// </summary>
 public OffAmazonPaymentsServiceRefund()
 {
     // Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
     this._propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();
     this._service = new OffAmazonPaymentsServiceClient(this._propertiesCollection);
     this._rng = new Random();
 }
Example #7
0
        public static CaptureResponse CaptureAction(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                    IOffAmazonPaymentsService service, string amazonAuthorizationId, string orderAmount, string orderReferenceId, int indicator, string providerId, string creditAmountString)
        {
            //initiate the capture request
            CaptureRequest captureRequest = new CaptureRequest();

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

            Price price = new Price();

            price.Amount       = orderAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;

            captureRequest.CaptureAmount      = price;
            captureRequest.CaptureReferenceId = orderReferenceId.Replace('-', 'c') + "captureRef" + indicator.ToString();
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditAmountString))
            {
                ProviderCredit providerCredit = new ProviderCredit();
                providerCredit.ProviderId = providerId;
                Price creditAmount = new Price();
                creditAmount.Amount         = creditAmountString;
                creditAmount.CurrencyCode   = propertiesCollection.CurrencyCode;
                providerCredit.CreditAmount = creditAmount;
                ProviderCreditList providerCreditList = new ProviderCreditList();
                providerCreditList.member = new List <ProviderCredit>();
                providerCreditList.member.Add(providerCredit);
                captureRequest.ProviderCreditList = providerCreditList;
            }

            return(CaptureSample.InvokeCapture(service, captureRequest));
        }
        public static GetOrderReferenceDetailsResponse GetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken, TextWriter buffer)
        {
            GetOrderReferenceDetailsResponse response = InvokeGetOrderReferenceDetails(propertiesCollection, service, orderReferenceId, addressConsentToken);

            printOrderReferenceDetailsResponseToBuffer(response, buffer);
            return(response);
        }
 public static GetCaptureDetailsResponse GetCaptureDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string amazonCaptureId)
 {
     GetCaptureDetailsRequest getCaptureDetailsRequest = new GetCaptureDetailsRequest();
     getCaptureDetailsRequest.AmazonCaptureId = amazonCaptureId;
     getCaptureDetailsRequest.SellerId = propertiesCollection.MerchantID;
     return GetCaptureDetailsSample.InvokeGetCaptureDetails(service, getCaptureDetailsRequest);
 }
 public static ConfirmBillingAgreementResponse ConfirmBillingAgreement(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string billingAgreementId)
 {
     ConfirmBillingAgreementRequest request = new ConfirmBillingAgreementRequest();
     request.AmazonBillingAgreementId = billingAgreementId;
     request.SellerId = propertiesCollection.MerchantID;
     return InvokeConfirmBillingAgreement(service, request);
 }
Example #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OffAmazonPaymentsServicePropertyCollection props = OffAmazonPaymentsServicePropertyCollection.getInstance();

            this.javascriptInclude = props.WidgetUrl;
            this.merchantId        = props.MerchantID;
            this.clientId          = props.ClientId;
        }
Example #12
0
        public static GetBillingAgreementDetailsResponse GetBillingAgreementDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                    IOffAmazonPaymentsService service, string billingAgreementId)
        {
            GetBillingAgreementDetailsRequest request = new GetBillingAgreementDetailsRequest();

            request.AmazonBillingAgreementId = billingAgreementId;
            request.SellerId = propertiesCollection.MerchantID;
            return(InvokeGetBillingAgreementDetails(service, request));
        }
        public static ConfirmOrderReferenceResponse ConfirmOrderReferenceObject(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service, string orderReferenceId)
        {
            ConfirmOrderReferenceRequest confirmOrderRequest = new ConfirmOrderReferenceRequest();
            confirmOrderRequest.SellerId = propertiesCollection.MerchantID;
            confirmOrderRequest.AmazonOrderReferenceId = orderReferenceId;

            return ConfirmOrderReferenceSample.InvokeConfirmOrderReference(service, confirmOrderRequest);
        }
        public static CloseOrderReferenceResponse CloseOrderReference(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service, string orderReferenceId)
        {
            CloseOrderReferenceRequest request = new CloseOrderReferenceRequest();
            request.AmazonOrderReferenceId = orderReferenceId;
            request.SellerId = propertiesCollection.MerchantID;

            return CloseOrderReferenceSample.InvokeCloseOrderReference(service, request);
        }
        public static CloseBillingAgreementResponse CloseBillingAgreement(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                          IOffAmazonPaymentsService service, string billingAgreementId)
        {
            CloseBillingAgreementRequest request = new CloseBillingAgreementRequest();

            request.AmazonBillingAgreementId = billingAgreementId;
            request.SellerId = propertiesCollection.MerchantID;
            return(InvokeCloseBillingAgreement(service, request));
        }
        public static GetCaptureDetailsResponse GetCaptureDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                  IOffAmazonPaymentsService service, string amazonCaptureId)
        {
            GetCaptureDetailsRequest getCaptureDetailsRequest = new GetCaptureDetailsRequest();

            getCaptureDetailsRequest.AmazonCaptureId = amazonCaptureId;
            getCaptureDetailsRequest.SellerId        = propertiesCollection.MerchantID;
            return(GetCaptureDetailsSample.InvokeGetCaptureDetails(service, getCaptureDetailsRequest));
        }
        public static CloseOrderReferenceResponse CloseOrderReference(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                      IOffAmazonPaymentsService service, string orderReferenceId)
        {
            CloseOrderReferenceRequest request = new CloseOrderReferenceRequest();

            request.AmazonOrderReferenceId = orderReferenceId;
            request.SellerId = propertiesCollection.MerchantID;

            return(CloseOrderReferenceSample.InvokeCloseOrderReference(service, request));
        }
Example #18
0
        public static ConfirmOrderReferenceResponse ConfirmOrderReferenceObject(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                IOffAmazonPaymentsService service, string orderReferenceId)
        {
            ConfirmOrderReferenceRequest confirmOrderRequest = new ConfirmOrderReferenceRequest();

            confirmOrderRequest.SellerId = propertiesCollection.MerchantID;
            confirmOrderRequest.AmazonOrderReferenceId = orderReferenceId;

            return(ConfirmOrderReferenceSample.InvokeConfirmOrderReference(service, confirmOrderRequest));
        }
        private static GetOrderReferenceDetailsResponse InvokeGetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
            IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken)
        {
            GetOrderReferenceDetailsRequest getOrderRequest = new GetOrderReferenceDetailsRequest();
            getOrderRequest.SellerId = propertiesCollection.MerchantID;
            getOrderRequest.AmazonOrderReferenceId = orderReferenceId;
            getOrderRequest.AddressConsentToken = addressConsentToken;

            GetOrderReferenceDetailsResponse response = service.GetOrderReferenceDetails(getOrderRequest);
            return response;
        }
        public OffAmazonPaymentsServiceCancellation()
        {
            /************************************************************************
            * Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
            ***********************************************************************/
            propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();

            /************************************************************************
            * Instantiate  Implementation of Marketplace Payment Service
            ***********************************************************************/
            service = new OffAmazonPaymentsServiceClient(propertiesCollection);
        }
Example #21
0
        public OffAmazonPaymentsServiceCancellation()
        {
            /************************************************************************
             * Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
             ***********************************************************************/
            propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();

            /************************************************************************
             * Instantiate  Implementation of Marketplace Payment Service
             ***********************************************************************/
            service = new OffAmazonPaymentsServiceClient(propertiesCollection);
        }
        /// <summary>
        /// Create a new instance of the class, using the order reference
        /// identifer as the basis for all service requests
        /// </summary>
        /// <param name="amazonOrderReferenceId">An order reference identifier for a draft order, obtained from the
        /// OffAmazonPayments widgets</param>
        public OffAmazonPaymentsServiceMultipleShipment(string amazonOrderReferenceId)
        {
            this.OrderList = new Dictionary <string, OrderItem>();
            ConstructOrders();

            // Instantiate the Merchant propertiesCollection object which contains
            // required parameters for creating a Marketplace Payment Service
            propertiesCollection = new OffAmazonPaymentsServicePropertyCollection();

            service = new OffAmazonPaymentsServiceClient(propertiesCollection);

            this._orderReferenceId = amazonOrderReferenceId;
        }
        public OffAmazonPaymentsServiceProviderCheckout(String oroId)
        {
            /************************************************************************
            * Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
            ***********************************************************************/
            propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();

            /************************************************************************
            * Instantiate  Implementation of Marketplace Payment Service
            ***********************************************************************/
            service = new OffAmazonPaymentsServiceClient(propertiesCollection);
            this.orderReferenceId = oroId;
        }
        public OffAmazonPaymentsServiceSimpleCheckout(String oroId)
        {
            /************************************************************************
             * Instantiate the Merchant propertiesCollection object which contains required parameters for creating a Marketplace Payment Service
             ***********************************************************************/
            propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();

            /************************************************************************
             * Instantiate  Implementation of Marketplace Payment Service
             ***********************************************************************/
            service = new OffAmazonPaymentsServiceClient(propertiesCollection);
            this.orderReferenceId = oroId;
        }
        /// <summary>
        /// Create a new instance of the class, using the order reference
        /// identifer as the basis for all service requests
        /// </summary>
        /// <param name="amazonOrderReferenceId">An order reference identifier for a draft order, obtained from the
        /// OffAmazonPayments widgets</param>
        public OffAmazonPaymentsServiceMultipleShipment(string amazonOrderReferenceId)
        {
            this.OrderList = new Dictionary<string, OrderItem>();
            ConstructOrders();

            // Instantiate the Merchant propertiesCollection object which contains
            // required parameters for creating a Marketplace Payment Service
            propertiesCollection = new OffAmazonPaymentsServicePropertyCollection();

            service = new OffAmazonPaymentsServiceClient(propertiesCollection);

            this._orderReferenceId = amazonOrderReferenceId;
        }
 public static AuthorizeOnBillingAgreementResponse AuthorizeOnBillingAgreement(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string billingAgreementId, String authAmount, int indicator, bool captureNow)
 {
     AuthorizeOnBillingAgreementRequest request = new AuthorizeOnBillingAgreementRequest();
     request.AmazonBillingAgreementId = billingAgreementId;
     request.SellerId = propertiesCollection.MerchantID;
     Price price = new Price();
     price.Amount = authAmount;
     price.CurrencyCode = propertiesCollection.CurrencyCode;
     request.AuthorizationAmount = price;
     request.CaptureNow = captureNow;
     request.AuthorizationReferenceId = billingAgreementId.Replace('-', 'a') + "authRef" + indicator.ToString();
     return InvokeAuthorizeOnBillingAgreement(service, request);
 }
 public static ProviderCreditSummaryList CheckCaptureForProviderCreditSummaryList(string amazonCaptureId, OffAmazonPaymentsServicePropertyCollection propertiesCollection, IOffAmazonPaymentsService service)
 {
     //used to check if the ProviderCreditSummaryList is available
     TimeSpan startTime = DateTime.Now.TimeOfDay;
     GetCaptureDetailsResponse getCaptureDetailsResponse = GetCaptureDetailsSample.GetCaptureDetails(propertiesCollection, service, amazonCaptureId);
     while (getCaptureDetailsResponse.IsSetGetCaptureDetailsResult() && (!getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.IsSetProviderCreditSummaryList() || getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.ProviderCreditSummaryList.member.Count < 1))
     {
         if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
             throw new OffAmazonPaymentsServiceException("The ProviderCreditSummaryList not found.");
         System.Threading.Thread.Sleep(8000);
         Console.WriteLine("Waiting until ProviderCreditSummaryList is found in GetCaptureDetailsResponse");
         getCaptureDetailsResponse = GetCaptureDetailsSample.GetCaptureDetails(propertiesCollection, service, amazonCaptureId);
     }
     return getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.ProviderCreditSummaryList;
 }
        public static SetOrderReferenceDetailsResponse SetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                IOffAmazonPaymentsService service, string orderReferenceId, string orderAmount)
        {
            SetOrderReferenceDetailsRequest setOrderRequest = new SetOrderReferenceDetailsRequest();

            setOrderRequest.SellerId = propertiesCollection.MerchantID;
            setOrderRequest.AmazonOrderReferenceId = orderReferenceId;
            //setup the currency and amount as an ordertotal object
            OrderReferenceAttributes attributes = new OrderReferenceAttributes();
            OrderTotal orderTotal = new OrderTotal();

            orderTotal.Amount       = orderAmount;
            orderTotal.CurrencyCode = propertiesCollection.CurrencyCode;
            attributes.OrderTotal   = orderTotal;
            setOrderRequest.OrderReferenceAttributes = attributes;
            return(SetOrderReferenceDetailsSample.InvokeSetOrderReferenceDetails(service, setOrderRequest));
        }
Example #29
0
        public static SetBillingAgreementDetailsResponse SetBillingAgreementDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                    IOffAmazonPaymentsService service, string billingAgreementId, string sellerBillingAgreementId,
                                                                                    string customNote, string storeName, string sellerNote)
        {
            SetBillingAgreementDetailsRequest request = new SetBillingAgreementDetailsRequest();

            request.AmazonBillingAgreementId = billingAgreementId;
            request.SellerId = propertiesCollection.MerchantID;
            BillingAgreementAttributes attr = new BillingAgreementAttributes();

            attr.SellerNote = sellerNote;
            SellerBillingAgreementAttributes sellerAttr = new SellerBillingAgreementAttributes();

            sellerAttr.SellerBillingAgreementId = sellerBillingAgreementId;
            sellerAttr.CustomInformation        = customNote;
            sellerAttr.StoreName = storeName;
            attr.SellerBillingAgreementAttributes = sellerAttr;
            request.BillingAgreementAttributes    = attr;
            return(InvokeSetBillingAgreementDetails(service, request));
        }
        public static GetRefundDetailsResponse CheckRefundStatus(string amazonRefundId, IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection)
        {
            //used to check if the refund is time-out
            TimeSpan startTime = DateTime.Now.TimeOfDay;
            GetRefundDetailsRequest refundDetailRequest = new GetRefundDetailsRequest();
            refundDetailRequest.SellerId = propertiesCollection.MerchantID;
            refundDetailRequest.AmazonRefundId = amazonRefundId;

            GetRefundDetailsResponse getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest);
            while (getRefundDetailsResponse.IsSetGetRefundDetailsResult() && getRefundDetailsResponse.GetRefundDetailsResult.RefundDetails.RefundStatus.State.Equals(PaymentStatus.PENDING))
            {
                if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
                    throw new OffAmazonPaymentsServiceException("The refund has timed-out.");

                System.Threading.Thread.Sleep(8000);
                Console.WriteLine("Waiting until the Refund Status changes from PENDING");
                getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest);
            }

            return getRefundDetailsResponse;
        }
        public static AuthorizeResponse AuthorizeAction(OffAmazonPaymentsServicePropertyCollection propertiesCollection, 
            IOffAmazonPaymentsService service, string orderReferenceId, String orderAmount, int indicator, int authorizationOption)
        {
            //initiate the authorization request
            AuthorizeRequest authRequest = new AuthorizeRequest();
            authRequest.AmazonOrderReferenceId = orderReferenceId;
            authRequest.SellerId = propertiesCollection.MerchantID;
            Price price = new Price();
            //get the ordertotal object from the setOrderReference's response
            OrderTotal authOrderTotal = new OrderTotal();
            price.Amount = orderAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;
            authRequest.AuthorizationAmount = price;
            authRequest.AuthorizationReferenceId = orderReferenceId.Replace('-', 'a') + "authRef" + indicator.ToString();
            //If Fast Authorization is required, set the transaction timeout in the request to 0.
            if (authorizationOption == 2)
            {
                authRequest.TransactionTimeout = 0;
            }

            return AuthorizeSample.InvokeAuthorize(service, authRequest);
        }
        //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;
        }
        public static AuthorizeResponse AuthorizeAction(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                        IOffAmazonPaymentsService service, string orderReferenceId, String orderAmount, int indicator, int authorizationOption)
        {
            //initiate the authorization request
            AuthorizeRequest authRequest = new AuthorizeRequest();

            authRequest.AmazonOrderReferenceId = orderReferenceId;
            authRequest.SellerId = propertiesCollection.MerchantID;
            Price price = new Price();
            //get the ordertotal object from the setOrderReference's response
            OrderTotal authOrderTotal = new OrderTotal();

            price.Amount       = orderAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;
            authRequest.AuthorizationAmount      = price;
            authRequest.AuthorizationReferenceId = orderReferenceId.Replace('-', 'a') + "authRef" + indicator.ToString();
            //If Fast Authorization is required, set the transaction timeout in the request to 0.
            if (authorizationOption == 2)
            {
                authRequest.TransactionTimeout = 0;
            }

            return(AuthorizeSample.InvokeAuthorize(service, authRequest));
        }
 public static SetBillingAgreementDetailsResponse SetBillingAgreementDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string billingAgreementId, string sellerBillingAgreementId,
     string customNote, string storeName, string sellerNote)
 {
     SetBillingAgreementDetailsRequest request = new SetBillingAgreementDetailsRequest();
     request.AmazonBillingAgreementId = billingAgreementId;
     request.SellerId = propertiesCollection.MerchantID;
     BillingAgreementAttributes attr = new BillingAgreementAttributes();
     attr.SellerNote = sellerNote;
     SellerBillingAgreementAttributes sellerAttr = new SellerBillingAgreementAttributes();
     sellerAttr.SellerBillingAgreementId = sellerBillingAgreementId;
     sellerAttr.CustomInformation = customNote;
     sellerAttr.StoreName = storeName;
     attr.SellerBillingAgreementAttributes = sellerAttr;
     request.BillingAgreementAttributes = attr;
     return InvokeSetBillingAgreementDetails(service, request);
 }
        public static ReverseProviderCreditResponse ReverseProviderCreditAction(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, Random rng, string amazonProviderCreditId, string creditReversalAmount)
        {
            //Initiate the ReverseProviderCredit request, including SellerId, AmazonProviderCreditId, CreditReversalReferenceId and CreditReversalAmount
            ReverseProviderCreditRequest request = new ReverseProviderCreditRequest();
            request.SellerId = propertiesCollection.MerchantID;
            request.AmazonProviderCreditId = amazonProviderCreditId;
            request.CreditReversalReferenceId = amazonProviderCreditId.Replace("-", "") + "r" + rng.Next(1, 1000).ToString();

            //assign the ReverseProviderCreditAmount to the ReverseProviderCredit request
            Price price = new Price();
            price.Amount = creditReversalAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;
            request.CreditReversalAmount = price;

            return ReverseProviderCreditSample.InvokeReverseProviderCredit(service, request);
        }
        public static GetRefundDetailsResponse GetRefundDetails(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, string amazonRefundId)
        {
            GetRefundDetailsRequest request = new GetRefundDetailsRequest();

            request.SellerId       = propertiesCollection.MerchantID;
            request.AmazonRefundId = amazonRefundId;
            return(GetRefundDetailsSample.InvokeGetRefundDetails(service, request));
        }
 public static GetOrderReferenceDetailsResponse GetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
     IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken)
 {
     return GetOrderReferenceDetails(propertiesCollection, service, orderReferenceId, addressConsentToken, Console.Out);
 }
Example #38
0
        public static ReverseProviderCreditResponse ReverseProviderCreditAction(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, Random rng, string amazonProviderCreditId, string creditReversalAmount)
        {
            //Initiate the ReverseProviderCredit request, including SellerId, AmazonProviderCreditId, CreditReversalReferenceId and CreditReversalAmount
            ReverseProviderCreditRequest request = new ReverseProviderCreditRequest();

            request.SellerId = propertiesCollection.MerchantID;
            request.AmazonProviderCreditId    = amazonProviderCreditId;
            request.CreditReversalReferenceId = amazonProviderCreditId.Replace("-", "") + "r" + rng.Next(1, 1000).ToString();

            //assign the ReverseProviderCreditAmount to the ReverseProviderCredit request
            Price price = new Price();

            price.Amount                 = creditReversalAmount;
            price.CurrencyCode           = propertiesCollection.CurrencyCode;
            request.CreditReversalAmount = price;

            return(ReverseProviderCreditSample.InvokeReverseProviderCredit(service, request));
        }
        public static ProviderCreditSummaryList CheckCaptureForProviderCreditSummaryList(string amazonCaptureId, OffAmazonPaymentsServicePropertyCollection propertiesCollection, IOffAmazonPaymentsService service)
        {
            //used to check if the ProviderCreditSummaryList is available
            TimeSpan startTime = DateTime.Now.TimeOfDay;
            GetCaptureDetailsResponse getCaptureDetailsResponse = GetCaptureDetailsSample.GetCaptureDetails(propertiesCollection, service, amazonCaptureId);

            while (getCaptureDetailsResponse.IsSetGetCaptureDetailsResult() && (!getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.IsSetProviderCreditSummaryList() || getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.ProviderCreditSummaryList.member.Count < 1))
            {
                if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
                {
                    throw new OffAmazonPaymentsServiceException("The ProviderCreditSummaryList not found.");
                }
                System.Threading.Thread.Sleep(8000);
                Console.WriteLine("Waiting until ProviderCreditSummaryList is found in GetCaptureDetailsResponse");
                getCaptureDetailsResponse = GetCaptureDetailsSample.GetCaptureDetails(propertiesCollection, service, amazonCaptureId);
            }
            return(getCaptureDetailsResponse.GetCaptureDetailsResult.CaptureDetails.ProviderCreditSummaryList);
        }
        public static GetRefundDetailsResponse CheckRefundStatus(string amazonRefundId, IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection)
        {
            //used to check if the refund is time-out
            TimeSpan startTime = DateTime.Now.TimeOfDay;
            GetRefundDetailsRequest refundDetailRequest = new GetRefundDetailsRequest();

            refundDetailRequest.SellerId       = propertiesCollection.MerchantID;
            refundDetailRequest.AmazonRefundId = amazonRefundId;

            GetRefundDetailsResponse getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest);

            while (getRefundDetailsResponse.IsSetGetRefundDetailsResult() && getRefundDetailsResponse.GetRefundDetailsResult.RefundDetails.RefundStatus.State.Equals(PaymentStatus.PENDING))
            {
                if (DateTime.Now.TimeOfDay.Milliseconds - startTime.Milliseconds > 60000)
                {
                    throw new OffAmazonPaymentsServiceException("The refund has timed-out.");
                }

                System.Threading.Thread.Sleep(8000);
                Console.WriteLine("Waiting until the Refund Status changes from PENDING");
                getRefundDetailsResponse = GetRefundDetailsSample.InvokeGetRefundDetails(service, refundDetailRequest);
            }

            return(getRefundDetailsResponse);
        }
Example #41
0
        public static GetProviderCreditReversalDetailsResponse GetProviderCreditReversalDetails(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, string providerCreditReversalId)
        {
            GetProviderCreditReversalDetailsRequest getProviderCreditReversalDetailsRequest = new GetProviderCreditReversalDetailsRequest();

            getProviderCreditReversalDetailsRequest.AmazonProviderCreditReversalId = providerCreditReversalId;
            getProviderCreditReversalDetailsRequest.SellerId = propertiesCollection.MerchantID;
            return(GetProviderCreditReversalDetailsSample.InvokeGetProviderCreditReversalDetails(service, getProviderCreditReversalDetailsRequest));
        }
 public static SetOrderReferenceDetailsResponse SetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection, 
     IOffAmazonPaymentsService service, string orderReferenceId, string orderAmount)
 {
     SetOrderReferenceDetailsRequest setOrderRequest = new SetOrderReferenceDetailsRequest();
     setOrderRequest.SellerId = propertiesCollection.MerchantID;
     setOrderRequest.AmazonOrderReferenceId = orderReferenceId;
     //setup the currency and amount as an ordertotal object
     OrderReferenceAttributes attributes = new OrderReferenceAttributes();
     OrderTotal orderTotal = new OrderTotal();
     orderTotal.Amount = orderAmount;
     orderTotal.CurrencyCode = propertiesCollection.CurrencyCode;
     attributes.OrderTotal = orderTotal;
     setOrderRequest.OrderReferenceAttributes = attributes;
     return SetOrderReferenceDetailsSample.InvokeSetOrderReferenceDetails(service, setOrderRequest);
 }
        public static RefundResponse RefundAction(IOffAmazonPaymentsService service, OffAmazonPaymentsServicePropertyCollection propertiesCollection, Random rng, string amazonCaptureID, string refundAmount, string providerId, string creditReversalAmountString)
        {
            //Initiate the Refund request, including SellerId, CaptureId, RefundReferenceId and RefundAmount
            RefundRequest request = new RefundRequest();
            request.SellerId = propertiesCollection.MerchantID;
            request.AmazonCaptureId = amazonCaptureID;
            request.RefundReferenceId = amazonCaptureID.Replace("-", "") + "r" + rng.Next(1, 1000).ToString();

            //assign the refundAmount to the refund request
            Price price = new Price();
            price.Amount = refundAmount;
            price.CurrencyCode = propertiesCollection.CurrencyCode;
            request.RefundAmount = price;
            if (!String.IsNullOrEmpty(providerId) && !String.IsNullOrEmpty(creditReversalAmountString))
            {
                ProviderCreditReversal providerCreditReversal = new ProviderCreditReversal();
                providerCreditReversal.ProviderId = providerId;
                Price creditReversalAmount = new Price();
                creditReversalAmount.Amount = creditReversalAmountString;
                creditReversalAmount.CurrencyCode = propertiesCollection.CurrencyCode;
                providerCreditReversal.CreditReversalAmount = creditReversalAmount;
                ProviderCreditReversalList providerCreditReversalList = new ProviderCreditReversalList();
                providerCreditReversalList.member = new List<ProviderCreditReversal>();
                providerCreditReversalList.member.Add(providerCreditReversal);
                request.ProviderCreditReversalList = providerCreditReversalList;
            }
            return RefundSample.InvokeRefund(service, request);
        }
Example #44
0
        public static AuthorizeOnBillingAgreementResponse AuthorizeOnBillingAgreement(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                      IOffAmazonPaymentsService service, string billingAgreementId, String authAmount, int indicator, bool captureNow)
        {
            AuthorizeOnBillingAgreementRequest request = new AuthorizeOnBillingAgreementRequest();

            request.AmazonBillingAgreementId = billingAgreementId;
            request.SellerId = propertiesCollection.MerchantID;
            Price price = new Price();

            price.Amount                     = authAmount;
            price.CurrencyCode               = propertiesCollection.CurrencyCode;
            request.AuthorizationAmount      = price;
            request.CaptureNow               = captureNow;
            request.AuthorizationReferenceId = billingAgreementId.Replace('-', 'a') + "authRef" + indicator.ToString();
            return(InvokeAuthorizeOnBillingAgreement(service, request));
        }
 public static GetOrderReferenceDetailsResponse GetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                         IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken)
 {
     return(GetOrderReferenceDetails(propertiesCollection, service, orderReferenceId, addressConsentToken, Console.Out));
 }
 public OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout(string billingAgreementId)
 {
     propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();
     service = new OffAmazonPaymentsServiceClient(propertiesCollection);
     this.billingAgreementId = billingAgreementId;
 }
 public OffAmazonPaymentsServiceAutomaticPaymentsSimpleCheckout(string billingAgreementId)
 {
     propertiesCollection = OffAmazonPaymentsServicePropertyCollection.getInstance();
     service = new OffAmazonPaymentsServiceClient(propertiesCollection);
     this.billingAgreementId = billingAgreementId;
 }
        private static GetOrderReferenceDetailsResponse InvokeGetOrderReferenceDetails(OffAmazonPaymentsServicePropertyCollection propertiesCollection,
                                                                                       IOffAmazonPaymentsService service, string orderReferenceId, string addressConsentToken)
        {
            GetOrderReferenceDetailsRequest getOrderRequest = new GetOrderReferenceDetailsRequest();

            getOrderRequest.SellerId = propertiesCollection.MerchantID;
            getOrderRequest.AmazonOrderReferenceId = orderReferenceId;
            getOrderRequest.AddressConsentToken    = addressConsentToken;

            GetOrderReferenceDetailsResponse response = service.GetOrderReferenceDetails(getOrderRequest);

            return(response);
        }
        //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);
        }