public async Task Update(UpdatePaymentMethodRequest updatePaymentMethodRequest)
 {
     var resource = $"{ApiConstants.PreApprovals}/{updatePaymentMethodRequest.SubscriptionCode}/{ApiConstants.PaymentMethod}";
     await _httpHelper.CallApi <string>(new ApiRequest()
     {
         Method   = HttpMethod.Put,
         Resource = resource,
         Body     = updatePaymentMethodRequest.PaymentMethod.ToBodyPayload(updatePaymentMethodRequest.SenderHash),
         Accept   = PagseguroAccept.JsonV3
     });
 }
        public virtual Task <ProcessedCart> UpdatePaymentMethodAsync(UpdatePaymentMethodParam param)
        {
            if (param == null)
            {
                throw new ArgumentNullException(nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.CartName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.CartName)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.PaymentProviderName))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.PaymentProviderName)), nameof(param));
            }
            if (string.IsNullOrWhiteSpace(param.Scope))
            {
                throw new ArgumentException(GetMessageOfNullWhiteSpace(nameof(param.Scope)), nameof(param));
            }
            if (param.CultureInfo == null)
            {
                throw new ArgumentException(GetMessageOfNull(nameof(param.CultureInfo)), nameof(param));
            }
            if (param.CustomerId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.CustomerId)), nameof(param));
            }
            if (param.PaymentId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.PaymentId)), nameof(param));
            }
            if (param.PaymentMethodId == Guid.Empty)
            {
                throw new ArgumentException(GetMessageOfEmpty(nameof(param.PaymentMethodId)), nameof(param));
            }

            var cacheKey = BuildCartCacheKey(param.Scope, param.CartName, param.CustomerId);

            var request = new UpdatePaymentMethodRequest
            {
                CartName            = param.CartName,
                CultureName         = param.CultureInfo.Name,
                CustomerId          = param.CustomerId,
                PaymentId           = param.PaymentId,
                PaymentMethodId     = param.PaymentMethodId,
                PaymentProviderName = param.PaymentProviderName,
                ScopeId             = param.Scope
            };

            return(CacheProvider.ExecuteAndSetAsync(cacheKey, () => OvertureClient.SendAsync(request)));
        }
        public async Task <IServiceResult> Update(UpdatePaymentMethodRequest input)
        {
            var order = await _orderRepository.FindAsync(input.OrderId);

            if (order is null)
            {
                return(ServiceResult.NotFound());
            }

            order.UpdatePaymentMethod(input.Methode);

            if (order.PaymentMethod == PaymentMethods.InPerson)
            {
                await _freezOrderService.Freez(order.Id);
            }

            await _unitOfWork.CommitAsync();

            return(ServiceResult.Ok());
        }
Exemplo n.º 4
0
        /// <summary>
        /// Successful response returned from an Update Payment Account request.
        /// https://apidocs.securenet.com/docs/vault.html?lang=csharp#updateaccount
        /// </summary>
        public void SecureNet_Vault_Update_Payment_Account_Request_Returns_Successfully(string customerId, string paymentMethodId)
        {
            // Arrange
            var request = new UpdatePaymentMethodRequest
            {
                CustomerId      = customerId,
                PaymentMethodId = paymentMethodId,
                Card            = new Card
                {
                    Number         = "4444 3333 2222 1111",
                    Cvv            = "999",
                    ExpirationDate = "04/2017",
                    Address        = new Address
                    {
                        Line1 = "123 Main St.",
                        City  = "Austin",
                        State = "TX",
                        Zip   = "78759"
                    },
                    FirstName = "Jack",
                    LastName  = "Updated"
                },
                Phone             = "512-250-7865",
                Notes             = "Create a vault account",
                Primary           = true,
                UserDefinedFields = new List <UserDefinedField>
                {
                    new UserDefinedField
                    {
                        UdfName  = "Udf1",
                        UdfValue = "Udf1_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName  = "Udf2",
                        UdfValue = "Udf2_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName  = "Udf3",
                        UdfValue = "Udf3_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName  = "Udf4",
                        UdfValue = "Udf4_Value"
                    },
                    new UserDefinedField
                    {
                        UdfName  = "Udf5",
                        UdfValue = "Udf5_Value"
                    }
                },
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version     = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new CustomersController();

            // Act
            var response = controller.ProcessRequest <UpdatePaymentMethodResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }