Exemple #1
0
        public void CanConstructWithAllPropertiesInitialized()
        {
            // act
            var request = new UpdateChargePermissionRequest();

            // assert
            Assert.IsNotNull(request);
            Assert.IsNotNull(request.MerchantMetadata);
        }
Exemple #2
0
 public void CanUpdateChargePermission()
 {
     mockClient.Protected().As <IClientMapping>()
     .Setup(c => c.ProcessRequest <ChargePermissionResponse>(It.IsAny <ApiRequest>(),
                                                             It.IsAny <Dictionary <string, string> >()))
     .Returns((ApiRequest request, Dictionary <string, string> headers) => AssertPreProcessRequestFlow <ChargePermissionResponse>(request, headers, HttpMethod.PATCH,
                                                                                                                                  $"{Constants.Resources.WebStore.ChargePermissions}/{checkoutSessionIdToTest}/"));
     var testRequest = new UpdateChargePermissionRequest()
     {
         MerchantMetadata = { MerchantReferenceId = "123456", MerchantStoreName = "MerchantStoreName", NoteToBuyer = "NoteToBuyer", CustomInformation = "CustomInformation" }
     };
     var result = mockClient.Object.UpdateChargePermission(checkoutSessionIdToTest, testRequest);
 }
Exemple #3
0
        public void CanConvertToJsonRecurringMetadata()
        {
            // arrange
            var request = new UpdateChargePermissionRequest();

            request.RecurringMetadata.Frequency.Unit      = FrequencyUnit.Month;
            request.RecurringMetadata.Frequency.Value     = 3;
            request.RecurringMetadata.Amount.Amount       = 23.45m;
            request.RecurringMetadata.Amount.CurrencyCode = Currency.GBP;

            // act
            string json  = request.ToJson();
            string json2 = request.ToJson();

            // assert
            Assert.AreEqual(json, json2);
            Assert.AreEqual("{\"recurringMetadata\":{\"frequency\":{\"unit\":\"Month\",\"value\":3},\"amount\":{\"amount\":23.45,\"currencyCode\":\"GBP\"}}}", json);
        }
Exemple #4
0
        public void CanConvertToJsonMerchantMetadata()
        {
            // arrange
            var request = new UpdateChargePermissionRequest();

            request.MerchantMetadata.CustomInformation   = "bar";
            request.MerchantMetadata.MerchantReferenceId = "345";
            request.MerchantMetadata.MerchantStoreName   = "anotherShop";
            request.MerchantMetadata.NoteToBuyer         = "mee";

            // act
            string json  = request.ToJson();
            string json2 = request.ToJson();

            // assert
            Assert.AreEqual(json, json2);
            Assert.AreEqual("{\"merchantMetadata\":{\"merchantReferenceId\":\"345\",\"merchantStoreName\":\"anotherShop\",\"noteToBuyer\":\"mee\",\"customInformation\":\"bar\"}}", json);
        }
Exemple #5
0
        public void CanConvertToJsonMinimal()
        {
            // arrange
            var request = new UpdateChargePermissionRequest();

            // act
            string json  = request.ToJson();
            string json2 = request.ToJson();

            // assert
            Assert.AreEqual(json, json2);
            Assert.AreEqual("{}", json);

            // verify object hasn't been corrupted
            request.MerchantMetadata.CustomInformation   = "bar";
            request.MerchantMetadata.MerchantReferenceId = "345";
            request.MerchantMetadata.MerchantStoreName   = "anotherShop";
            request.MerchantMetadata.NoteToBuyer         = "mee";
        }
Exemple #6
0
        /// <summary>
        /// Updates a Charge Permission.
        /// </summary>
        public ChargePermissionResponse UpdateChargePermission(string chargePermissionId, UpdateChargePermissionRequest request, Dictionary <string, string> headers = null)
        {
            var apiPath    = apiUrlBuilder.BuildFullApiPath(Constants.ApiServices.Default, Constants.Resources.WebStore.ChargePermissions, chargePermissionId);
            var apiRequest = new ApiRequest(apiPath, HttpMethod.PATCH, request, headers);

            var result = CallAPI <ChargePermissionResponse>(apiRequest);

            return(result);
        }