コード例 #1
0
        public async Task <PCISafeCardDetails> CreateSavedCardAsync([FromBody] PCISafeCardDetails card)
        {
            var shopper = await _oc.Me.GetAsync <MeUserWithXp>(UserContext.AccessToken);

            return(await _creditCardCommand.CreateSavedCardAsync(shopper, card));
        }
コード例 #2
0
        public async Task <PCISafeCardDetails> CreateSavedCardAsync(MeUserWithXp shopper, PCISafeCardDetails card)
        {
            var customerID = shopper?.xp?.PaymentProcessorCustomerID;
            var customer   = new PaymentSystemCustomer()
            {
                ID                    = shopper?.xp?.PaymentProcessorCustomerID, // cannot assume customer ID is set-able
                Email                 = shopper.Email,
                FirstName             = shopper.FirstName,
                LastName              = shopper.LastName,
                CustomerAlreadyExists = customerID != null,
            };
            var savedCard = await _creditCardSaver.CreateSavedCardAsync(customer, card);

            if (!customer.CustomerAlreadyExists)
            {
                var patch = new PartialUser <MeUserWithXp>()
                {
                    xp = new { PaymentProcessorCustomerID = savedCard.CustomerID }
                };
                await _oc.Users.PatchAsync(shopper.Buyer.ID, shopper.ID, patch);
            }
            return(savedCard.Card);
        }