Example #1
0
        public static void GetOrderReferenceDetailsApiCall(string amazonBillingAgreementId, string addressConsentToken = null)
        {
            GetBillingAgreementDetailsRequest getRequestParameters = new GetBillingAgreementDetailsRequest();

            getRequestParameters.WithAmazonBillingAgreementId(amazonBillingAgreementId)
            .WithaddressConsentToken(null);

            BillingAgreementDetailsResponse getOrderReferenceDetailsResponse = client.GetBillingAgreementDetails(getRequestParameters);

            // IResponse is an interface method for common response methods for each response class
            IResponse interfaceresp = (IResponse)getOrderReferenceDetailsResponse;

            apiResponse["getBillingAgreementDetailsResponse"] = JObject.Parse(getOrderReferenceDetailsResponse.GetJson()).ToString();
        }
        /// <summary>
        /// Sets the Amazon Order Reference ID / Amazon Billing Agreement ID
        /// </summary>
        /// <param name="amazon_reference_id"></param>
        /// <returns>ChargeRequest</returns>
        public ChargeRequest WithAmazonReferenceId(string amazon_reference_id)
        {
            if (!string.IsNullOrEmpty(amazon_reference_id))
            {
                string switchChar = amazon_reference_id;
                switch (switchChar[0])
                {
                case 'P':
                case 'S':
                    chargeType = "OrderReference";
                    getOrderReferenceDetails.WithAmazonOrderReferenceId(amazon_reference_id);
                    setOrderReferenceDetails.WithAmazonOrderReferenceId(amazon_reference_id);
                    confirmOrderReference.WithAmazonOrderReferenceId(amazon_reference_id);
                    authorizeOrderReference.WithAmazonOrderReferenceId(amazon_reference_id);
                    break;

                case 'B':
                case 'C':
                    chargeType = "BillingAgreement";
                    getBillingAgreementDetails.WithAmazonBillingAgreementId(amazon_reference_id);
                    setBillingAgreementDetails.WithAmazonBillingAgreementId(amazon_reference_id);
                    confirmBillingAgreement.WithAmazonBillingAgreementId(amazon_reference_id);
                    authorizeOnBillingAgreement.WithAmazonBillingAgreementId(amazon_reference_id);
                    break;

                default:
                    throw new InvalidDataException("Invalid Amazon Reference ID");
                }
            }
            else
            {
                throw new MissingFieldException("Amazon Reference ID is a required field and should be a Order Reference ID / Billing Agreement ID");
            }

            return(this);
        }