コード例 #1
0
        public void Run()
        {
            var customerId   = AddCustomer();
            int creditcardId = StoreCreditCard(customerId);
            var request      = new AttemptPayment
            {
                Amount     = 10,
                CustomerId = customerId,
                PayMethods = new[]
                {
                    new PayMethod
                    {
                        CreditCardId = creditcardId
                    }
                }
            };

            try
            {
                var result = _transactionsService.AttemptPayment(request);

                if (!result.IsSuccess())
                {
                    throw new Exception("Attempt payment failed.");
                }

                Console.WriteLine("Payment attempt with id: " + result.Id);
            }
            catch (Exception)
            {
            }
        }
コード例 #2
0
        public int AttemptPayment()
        {
            var customerId   = this._customerId;
            int creditcardId = StoreCreditCard(customerId);
            int invoiceId    = CreateInvoice(customerId);

            var request = new AttemptPayment
            {
                Amount     = 10,
                CustomerId = customerId,
                PayMethods = new[]
                {
                    new PayMethod
                    {
                        CreditCardId = creditcardId
                    }
                },
                AppliedTo = new[]
                {
                    new TransactionAppliedTo
                    {
                        InvoiceId = invoiceId
                    }
                }
            };

            try
            {
                var result = _transactionsService.AttemptPayment(request);

                if (!result.IsSuccess())
                {
                    throw new Exception("Attempt payment failed.");
                }

                return(result.Id);
            }
            catch (Exception)
            {
            }

            return(0);
        }