示例#1
0
        /// <summary>
        /// Creates the credit card.
        /// </summary>
        /// <returns>Omise card object</returns>
        /// <param name="customerId">Customer Id</param>
        /// <param name="cardCreateInfo">Card information</param>
        public Card CreateCard(string customerId, CardCreateInfo cardCreateInfo)
        {
            if (string.IsNullOrEmpty(customerId))
            {
                throw new ArgumentNullException("customerId");
            }
            if (cardCreateInfo == null)
            {
                throw new ArgumentNullException("cardCreateInfo");
            }
            if (!cardCreateInfo.Valid)
            {
                throw new InvalidCardException(getObjectErrors(cardCreateInfo));
            }

            var tokenResult = this.tokenService.CreateToken(new TokenInfo()
            {
                Card = cardCreateInfo
            });

            string url    = string.Format("/customers/{0}/cards", customerId);
            string result = requester.ExecuteRequest(url, "POST", string.Format("card={0}", tokenResult.Id));

            return(cardFactory.Create(result));
        }
示例#2
0
 /// <summary>
 ///  Initializes a new instance of the <see cref="Omise.CustomerCreateInfo"/> class.
 /// </summary>
 /// <param name="email">Customer's email</param>
 /// <param name="description">Description of the customer</param>
 /// <param name="cardCreateInfo">Credit card information to attach to customer</param>
 public CustomerUpdateInfo(string email, string description, CardCreateInfo cardCreateInfo)
 {
     this.email          = email;
     this.description    = description;
     this.cardCreateInfo = cardCreateInfo;
 }