private FundingInstrument GetFundingInstrument()
 {
     FundingInstrument instrument = new FundingInstrument();
     instrument.credit_card = CreateCreditCard();    
     instrument.credit_card_token = GetCreditCardToken();
     return instrument;
 }              
Example #2
0
        public void CreditCardPay(Address billingaddr, CreditCard cc, Amount amount)
        {
            Transaction transaction = new Transaction();
            transaction.amount = amount;
            transaction.description = "This is the payment transaction description.";

            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(transaction);

            FundingInstrument fundingInstrument = new FundingInstrument();
            fundingInstrument.credit_card = cc;

            List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
            fundingInstruments.Add(fundingInstrument);

            Payer payer = new Payer();
            payer.funding_instruments = fundingInstruments;
            payer.payment_method = "credit_card";

            Payment payment = new Payment();
            payment.intent = "sale";
            payment.payer  = payer;
            payment.transactions = transactions;

            Payment createdPayment = payment.Create(AccessToken());
        }
        public string EfetuarCompra(PessoaFisica pessoaFisica, CreditCard creditCard, int quantidadeFits)
        {
            string valor = (quantidadeFits * valorFits).ToString();

            Dictionary<string, string> payPalConfig = new Dictionary<string, string>();
            payPalConfig.Add("mode", this.mode);

            OAuthTokenCredential tokenCredential = new OAuthTokenCredential(this.clientId, this.clientSecret, payPalConfig);

            string accessToken = tokenCredential.GetAccessToken();

            Address billingAddress = new Address();
            billingAddress.line1 = string.Format("{0} Num {1}",pessoaFisica.Endereco.Rua, pessoaFisica.Endereco.Numero) ;
            billingAddress.city = pessoaFisica.Endereco.Cidade;
            billingAddress.country_code = "BR";
            billingAddress.postal_code = pessoaFisica.Endereco.CEP;
            billingAddress.state = pessoaFisica.Endereco.Estado;

            creditCard.billing_address = billingAddress;

            Details amountDetails = new Details();
            amountDetails.subtotal = valor;
            amountDetails.tax = "0.00";
            amountDetails.shipping = "0.00";

            Amount amount = new Amount();
            amount.total = (quantidadeFits * valorFits).ToString();
            amount.currency = "USD";
            amount.details = amountDetails;

            Transaction transaction = new Transaction();
            transaction.amount = amount;
            transaction.description = string.Format("Este pagamento foi efetuado por {0}, na quantia de {1} fits", pessoaFisica.Nome, quantidadeFits);

            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(transaction);

            FundingInstrument fundingInstrument = new FundingInstrument();
            fundingInstrument.credit_card = creditCard;

            List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
            fundingInstruments.Add(fundingInstrument);

            Payer payer = new Payer();
            payer.funding_instruments = fundingInstruments;
            payer.payment_method = "credit_card";

            Payment payment = new Payment();
            payment.intent = "sale";
            payment.payer = payer;
            payment.transactions = transactions;

            Payment createdPayment = payment.Create(accessToken);

            return valor;
        }
 private Payment CreatePayment()
 {
     Payment pay = new Payment();
     pay.intent = "sale";
     CreditCard card = GetCreditCard();
     List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
     FundingInstrument fundingInstrument = new FundingInstrument();
     fundingInstrument.credit_card = card;
     fundingInstruments.Add(fundingInstrument);
     Payer payer = new Payer();
     payer.payment_method = "credit_card";
     payer.funding_instruments = fundingInstruments;
     List<Transaction> transactionList = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transactionList.Add(trans);
     pay.transactions = transactionList;
     pay.payer = payer;
     return pay.Create(UnitTestUtil.GetApiContext());
 }
 private Payment GetPayment()
 {
     Payment target = new Payment();
     target.intent = "authorize";
     CreditCard card = GetCreditCard();
     List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
     FundingInstrument fundingInstrument = new FundingInstrument();
     fundingInstrument.credit_card = card;
     fundingInstruments.Add(fundingInstrument);
     Payer payer = new Payer();
     payer.payment_method = "credit_card";
     payer.funding_instruments = fundingInstruments;
     List<Transaction> transacts = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transacts.Add(trans);
     target.transactions = transacts;
     target.payer = payer;
     return target.Create(AccessToken);
 }
 public void CreatePaymentTest()
 {
     string accessToken = AccessToken;
     Payment target = new Payment();
     target.intent = "sale";
     CreditCard creditCard = GetCreditCard();
     List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
     FundingInstrument fundingInstrument = new FundingInstrument();
     fundingInstrument.credit_card = creditCard;
     fundingInstruments.Add(fundingInstrument);
     Payer payer = new Payer();
     payer.payment_method = "credit_card";
     payer.funding_instruments = fundingInstruments;
     List<Transaction> transacts = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transacts.Add(trans);
     target.transactions = transacts;
     target.payer = payer;
     Payment actual = new Payment();
     actual = target.Create(accessToken);
     Assert.AreEqual("approved", actual.state);
 }
 private FundingInstrument GetFundingInstrument()
 {
     FundingInstrument fundInstrument = new FundingInstrument();
     fundInstrument.credit_card = GetCreditCard();
     fundInstrument.credit_card_token = GetCreditCardToken();
     return fundInstrument;
 }
 public void PaymentNullAccessToken()
 {
     string accessToken = null;
     Payment pay = new Payment();
     pay.intent = "sale";
     CreditCard card = GetCreditCard();
     List<FundingInstrument> instruments = new List<FundingInstrument>();
     FundingInstrument instrument = new FundingInstrument();
     instrument.credit_card = card;
     instruments.Add(instrument);
     Payer payr = new Payer();
     payr.payment_method = "credit_card";
     payr.funding_instruments = instruments;
     List<Transaction> transacts = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transacts.Add(trans);
     pay.transactions = transacts;
     pay.payer = payr;
     Payment actual = pay.Create(accessToken);           
 }
 public void PaymentStateTest()
 {
     Payment pay = new Payment(); 
     pay.intent = "sale";
     CreditCard card = GetCreditCard();
     List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
     FundingInstrument instrument = new FundingInstrument();
     instrument.credit_card = card;
     fundingInstrumentList.Add(instrument);
     Payer payer = new Payer();
     payer.payment_method = "credit_card";
     payer.funding_instruments = fundingInstrumentList;
     List<Transaction> transacts = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transacts.Add(trans);
     pay.transactions = transacts;
     pay.payer = payer;
     Payment actual = new Payment();
     actual = pay.Create(AccessToken);
     Assert.AreEqual("approved", actual.state);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext CurrContext = HttpContext.Current;

            // ###CreditCard
            // A resource representing a credit card that can be
            // used to fund a payment.
            CreditCardToken credCardToken = new CreditCardToken();
            credCardToken.credit_card_id = "CARD-5BT058015C739554AKE2GCEI";

            // ###AmountDetails
            // Let's you specify details of a payment amount.
            AmountDetails amntDetails = new AmountDetails();
            amntDetails.shipping = "1";
            amntDetails.subtotal = "5";
            amntDetails.tax = "1";

            // ###Amount
            // Let's you specify a payment amount.
            Amount amnt = new Amount();
            amnt.currency = "USD";
            // Total must be equal to the sum of shipping, tax and subtotal.
            amnt.total = "7";
            amnt.details = amntDetails;

            // ###Transaction
            // A transaction defines the contract of a
            // payment - what is the payment for and who
            // is fulfilling it. Transaction is created with
            // a `Payee` and `Amount` types
            Transaction tran = new Transaction();
            tran.amount = amnt;
            tran.description = "This is the payment transaction description.";

            // The Payment creation API requires a list of
            // Transaction; add the created `Transaction`
            // to a List
            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(tran);

            // ###FundingInstrument
            // A resource representing a Payeer's funding instrument.
            // Use a Payer ID (A unique identifier of the payer generated
            // and provided by the facilitator. This is required when
            // creating or using a tokenized funding instrument)
            // and the `CreditCardDetails`
            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.credit_card_token = credCardToken;

            // The Payment creation API requires a list of
            // FundingInstrument; add the created `FundingInstrument`
            // to a List
            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundInstrument);

            // ###Payer
            // A resource representing a Payer that funds a payment
            // Use the List of `FundingInstrument` and the Payment Method
            // as 'credit_card'
            Payer payr = new Payer();
            payr.funding_instruments = fundingInstrumentList;
            payr.payment_method = "credit_card";

            // ###Payment
            // A Payment Resource; create one using
            // the above types and intent as 'sale'
            Payment pymnt = new Payment();
            pymnt.intent = "sale";
            pymnt.payer = payr;
            pymnt.transactions = transactions;

            try
            {
                // ###AccessToken
                // Retrieve the access token from
                // OAuthTokenCredential by passing in
                // ClientID and ClientSecret
                // It is not mandatory to generate Access Token on a per call basis.
                // Typically the access token can be generated once and
                // reused within the expiry window
                string accessToken = new OAuthTokenCredential(ConfigManager.Instance.GetProperties()["ClientID"], ConfigManager.Instance.GetProperties()["ClientSecret"]).GetAccessToken();

                // ### Api Context
                // Pass in a `ApiContext` object to authenticate
                // the call and to send a unique request id
                // (that ensures idempotency). The SDK generates
                // a request id if you do not pass one explicitly.
                APIContext apiContext = new APIContext(accessToken);
                // Use this variant if you want to pass in a request id
                // that is meaningful in your application, ideally
                // a order id.
                // String requestId = Long.toString(System.nanoTime();
                // APIContext apiContext = new APIContext(accessToken, requestId ));
                // Create a payment by posting to the APIService
                // using a valid AccessToken
                // The return object contains the status;

                // Create a payment by posting to the APIService
                // using a valid AccessToken
                // The return object contains the status;
                Payment createdPayment = pymnt.Create(apiContext);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(createdPayment.ConvertToJson()).ToString(Formatting.Indented));
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
            }
            CurrContext.Items.Add("RequestJson", JObject.Parse(pymnt.ConvertToJson()).ToString(Formatting.Indented));
            Server.Transfer("~/Response.aspx");
        }
        // ##Create
        // Sample showing to create a Payment using
        // CreditCard as a FundingInstrument
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext CurrContext = HttpContext.Current;

            // ###Items
            // Items within a transaction.
            Item item = new Item();
            item.name = "Item Name";
            item.currency = "USD";
            item.price = "1";
            item.quantity = "5";
            item.sku = "sku";

            List<Item> itms = new List<Item>();
            itms.Add(item);
            ItemList itemList = new ItemList();
            itemList.items = itms;

            // ###Address
            // Base Address object used as shipping or billing
            // address in a payment.
            Address billingAddress = new Address();
            billingAddress.city = "Johnstown";
            billingAddress.country_code = "US";
            billingAddress.line1 = "52 N Main ST";
            billingAddress.postal_code = "43210";
            billingAddress.state = "OH";

            // ###CreditCard
            // A resource representing a credit card that can be
            // used to fund a payment.
            CreditCard crdtCard = new CreditCard();
            crdtCard.billing_address = billingAddress;
            crdtCard.cvv2 = "874";
            crdtCard.expire_month = 11;
            crdtCard.expire_year = 2018;
            crdtCard.first_name = "Joe";
            crdtCard.last_name = "Shopper";
            crdtCard.number = "4417119669820331";
            crdtCard.type = "visa";

            // ###Details
            // Let's you specify details of a payment amount.
            Details details = new Details();
            details.shipping = "1";
            details.subtotal = "5";
            details.tax = "1";

            // ###Amount
            // Let's you specify a payment amount.
            Amount amnt = new Amount();
            amnt.currency = "USD";
            // Total must be equal to sum of shipping, tax and subtotal.
            amnt.total = "7";
            amnt.details = details;

            // ###Transaction
            // A transaction defines the contract of a
            // payment - what is the payment for and who
            // is fulfilling it. 
            Transaction tran = new Transaction();
            tran.amount = amnt;
            tran.description = "This is the payment transaction description.";
            tran.item_list = itemList;

            // The Payment creation API requires a list of
            // Transaction; add the created `Transaction`
            // to a List
            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(tran);

            // ###FundingInstrument
            // A resource representing a Payer's funding instrument.
            // For direct credit card payments, set the CreditCard
            // field on this object.
            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.credit_card = crdtCard;

            // The Payment creation API requires a list of
            // FundingInstrument; add the created `FundingInstrument`
            // to a List
            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundInstrument);

            // ###Payer
            // A resource representing a Payer that funds a payment
            // Use the List of `FundingInstrument` and the Payment Method
            // as `credit_card`
            Payer payr = new Payer();
            payr.funding_instruments = fundingInstrumentList;
            payr.payment_method = "credit_card";

            // ###Payment
            // A Payment Resource; create one using
            // the above types and intent as `sale` or `authorize`
            Payment pymnt = new Payment();
            pymnt.intent = "sale";
            pymnt.payer = payr;
            pymnt.transactions = transactions;

            try
            {
                // ### Api Context
                // Pass in a `APIContext` object to authenticate 
                // the call and to send a unique request id 
                // (that ensures idempotency). The SDK generates
                // a request id if you do not pass one explicitly. 
                 // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext..
                APIContext apiContext = Configuration.GetAPIContext();

                // Create a payment using a valid APIContext
                Payment createdPayment = pymnt.Create(apiContext);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(createdPayment.ConvertToJson()).ToString(Formatting.Indented));
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
            }

            CurrContext.Items.Add("RequestJson", JObject.Parse(pymnt.ConvertToJson()).ToString(Formatting.Indented));

            Server.Transfer("~/Response.aspx");
        }
        private string GetAuthorizationId(string accessToken)
        {
            // ###Address
            // Base Address object used as shipping or billing
            // address in a payment.
            Address billingAddress = new Address();
            billingAddress.city = "Johnstown";
            billingAddress.country_code = "US";
            billingAddress.line1 = "52 N Main ST";
            billingAddress.postal_code = "43210";
            billingAddress.state = "OH";

            // ###CreditCard
            // A resource representing a credit card that can be
            // used to fund a payment.
            CreditCard crdtCard = new CreditCard();
            crdtCard.billing_address = billingAddress;
            crdtCard.cvv2 = "874";
            crdtCard.expire_month = 11;
            crdtCard.expire_year = 2018;
            crdtCard.first_name = "Joe";
            crdtCard.last_name = "Shopper";
            crdtCard.number = "4417119669820331";
            crdtCard.type = "visa";

            // ###Details
            // Let's you specify details of a payment amount.
            Details details = new Details();
            details.shipping = "0.03";
            details.subtotal = "107.41";
            details.tax = "0.03";

            // ###Amount
            // Let's you specify a payment amount.
            Amount amnt = new Amount();
            amnt.currency = "USD";
            // Total must be equal to sum of shipping, tax and subtotal.
            amnt.total = "107.47";
            amnt.details = details;

            // ###Transaction
            // A transaction defines the contract of a
            // payment - what is the payment for and who
            // is fulfilling it. Transaction is created with
            // a `Payee` and `Amount` types
            Transaction tran = new Transaction();
            tran.amount = amnt;
            tran.description = "This is the payment transaction description.";

            // The Payment creation API requires a list of
            // Transaction; add the created `Transaction`
            // to a List
            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(tran);

            // ###FundingInstrument
            // A resource representing a Payeer's funding instrument.
            // Use a Payer ID (A unique identifier of the payer generated
            // and provided by the facilitator. This is required when
            // creating or using a tokenized funding instrument)
            // and the `CreditCardDetails`
            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.credit_card = crdtCard;

            // The Payment creation API requires a list of
            // FundingInstrument; add the created `FundingInstrument`
            // to a List
            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundInstrument);

            // ###Payer
            // A resource representing a Payer that funds a payment
            // Use the List of `FundingInstrument` and the Payment Method
            // as 'credit_card'
            Payer payr = new Payer();
            payr.funding_instruments = fundingInstrumentList;
            payr.payment_method = "credit_card";

            // ###Payment
            // A Payment Resource; create one using
            // the above types and intent as `sale`
            Payment pymnt = new Payment();
            pymnt.intent = "authorize";
            pymnt.payer = payr;
            pymnt.transactions = transactions;

            // Create a payment by posting to the APIService
            // using a valid AccessToken
            // The return object contains the status;
            Payment createdPayment = pymnt.Create(accessToken);

            return createdPayment.transactions[0].related_resources[0].authorization.id;
        }
Example #13
0
        private Payment CreatePaymentCreditCard()
        {
            //Create Payment With Credit Card
            try
            {
                Transaction tran = new Transaction();

                //Redirect Url
                RedirectUrls red = new RedirectUrls();
                red.return_url = "";
                red.cancel_url = "";

                //Detail
                Details det = new Details();
                det.shipping = "0";
                det.tax = "0";
                det.fee = "0";

                //Address
                Address billingAddress = new Address();
                billingAddress.city = "Johnstown";
                billingAddress.country_code = "US";
                billingAddress.line1 = "52 N Main ST";
                billingAddress.postal_code = "43210";
                billingAddress.state = "OH";

                //CreditCard
                CreditCard creditCard = new CreditCard();
                creditCard.number = "4417119669820331";
                creditCard.type = "visa";
                creditCard.expire_month = 11;
                creditCard.expire_year = 2018;
                creditCard.cvv2 = "111";
                creditCard.first_name = "TestF";
                creditCard.last_name = "TestL";
                creditCard.billing_address = billingAddress;

                //Create item
                ItemList ItemList = new ItemList();
                ItemList.items = new List<Item>();
                ItemList.items.Add(new Item { name = "A", currency = "USD", price = "10", quantity = "1", sku = "1" });
                ItemList.items.Add(new Item { name = "B", currency = "USD", price = "20", quantity = "2", sku = "1" });
                ItemList.items.Add(new Item { name = "C", currency = "USD", price = "50", quantity = "3", sku = "1" });
                ItemList.items.Add(new Item { name = "D", currency = "USD", price = "100", quantity = "4", sku = "1" });
                //tran.item_list = ItemList;

                //Create Amount
                Amount amnt = new Amount();
                amnt.currency = "USD";
                amnt.total = "600";
                //amnt.details = det;
                tran.amount = amnt;

                //Transaction
                tran.description = "TestPaypal Sandbox";
                List<Transaction> transactions = new List<Transaction>();
                transactions.Add(tran);

                //Instrument
                FundingInstrument fundingInstrument = new FundingInstrument();
                fundingInstrument.credit_card = creditCard;

                List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
                fundingInstruments.Add(fundingInstrument);

                Payer payer = new Payer();
                payer.payment_method = "credit_card";
                payer.funding_instruments = fundingInstruments;

                //Payment
                Payment payment = new Payment();
                payment.intent = "sale";
                payment.payer = payer;
                payment.transactions = transactions;
                payment.redirect_urls = red;

                Payment createdPayment = payment.Create(Api);

                return createdPayment;
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                var a = ex.Message;
                return null;
            }
        }
 public void CreateTestForNullAccessToken()
 {
     string accessToken = null;
     Payment target = new Payment();
     target.intent = "sale";
     CreditCard creditCard = GetCreditCard();
     List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
     FundingInstrument fundingInstrument = new FundingInstrument();
     fundingInstrument.credit_card = creditCard;
     fundingInstruments.Add(fundingInstrument);
     Payer payer = new Payer();
     payer.payment_method = "credit_card";
     payer.funding_instruments = fundingInstruments;
     List<Transaction> transacts = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transacts.Add(trans);
     target.transactions = transacts;
     target.payer = payer;
     try
     {
         Payment actual = target.Create(accessToken);
     }
     catch(ArgumentNullException exe)
     {
         Assert.IsNotNull(exe);
     }
 }
 public void FundingInstrumentConstructorTest()
 {
     FundingInstrument target = new FundingInstrument();
     Assert.IsNotNull(target);
 }
 private Payment CreatePayment()
 {
     Payment pay = new Payment();
     pay.intent = "authorize";
     CreditCard card = GetCreditCard();
     List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
     FundingInstrument instrument = new FundingInstrument();
     instrument.credit_card = card;
     fundingInstrumentList.Add(instrument);
     Payer payr = new Payer();
     payr.payment_method = "credit_card";
     payr.funding_instruments = fundingInstrumentList;
     List<Transaction> transactionList = new List<Transaction>();
     Transaction trans = new Transaction();
     trans.amount = GetAmount();
     transactionList.Add(trans);
     pay.transactions = transactionList;
     pay.payer = payr;
     return pay.Create(AccessToken);
 }     
        public Payment CreatePayment(string email, PaymentMethod paymntMethod, string orderAmount, string orderDescription)
        {
            Payment pay = null;

            Amount amount = new Amount();
            amount.currency = "USD";
            amount.total = orderAmount;

            Transaction transaction = new Transaction();
            transaction.amount = amount;
            transaction.description = orderDescription;

            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(transaction);

            FundingInstrument fundingInstrument = new FundingInstrument();
            CreditCardToken creditCardToken = new CreditCardToken();
            creditCardToken.credit_card_id = GetSignedInUserCreditCardID(email);
            fundingInstrument.credit_card_token = creditCardToken;

            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundingInstrument);

            Payer payer = new Payer();
            payer.funding_instruments = fundingInstrumentList;
            payer.payment_method = paymntMethod.ToString();

            Payment pyment = new Payment();
            pyment.intent = "sale";
            pyment.payer = payer;
            pyment.transactions = transactions;
            pay = pyment.Create(Api);
            return pay;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpContext CurrContext = HttpContext.Current;

            // ###Items
            // Items within a transaction.
            Item item = new Item();
            item.name = "Item Name";
            item.currency = "USD";
            item.price = "1";
            item.quantity = "5";
            item.sku = "sku";

            List<Item> itms = new List<Item>();
            itms.Add(item);
            ItemList itemList = new ItemList();
            itemList.items = itms;

            // ###CreditCard
            // A resource representing a credit card that can be
            // used to fund a payment.
            CreditCardToken credCardToken = new CreditCardToken();
            credCardToken.credit_card_id = "CARD-5MY32504F4899612AKIHAQHY";

            // ###Details
            // Let's you specify details of a payment amount.
            Details details = new Details();
            details.shipping = "1";
            details.subtotal = "5";
            details.tax = "1";

            // ###Amount
            // Let's you specify a payment amount.
            Amount amnt = new Amount();
            amnt.currency = "USD";
            // Total must be equal to the sum of shipping, tax and subtotal.
            amnt.total = "7";
            amnt.details = details;

            // ###Transaction
            // A transaction defines the contract of a
            // payment - what is the payment for and who
            // is fulfilling it. 
            Transaction tran = new Transaction();
            tran.amount = amnt;
            tran.description = "This is the payment transaction description.";
            tran.item_list = itemList;

            // The Payment creation API requires a list of
            // Transaction; add the created `Transaction`
            // to a List
            List<Transaction> transactions = new List<Transaction>();
            transactions.Add(tran);

            // ###FundingInstrument
            // A resource representing a Payer's funding instrument.
            // For stored credit card payments, set the CreditCardToken
            // field on this object.
            FundingInstrument fundInstrument = new FundingInstrument();
            fundInstrument.credit_card_token = credCardToken;

            // The Payment creation API requires a list of
            // FundingInstrument; add the created `FundingInstrument`
            // to a List
            List<FundingInstrument> fundingInstrumentList = new List<FundingInstrument>();
            fundingInstrumentList.Add(fundInstrument);

            // ###Payer
            // A resource representing a Payer that funds a payment
            // Use the List of `FundingInstrument` and the Payment Method
            // as 'credit_card'
            Payer payr = new Payer();
            payr.funding_instruments = fundingInstrumentList;
            payr.payment_method = "credit_card";

            // ###Payment
            // A Payment Resource; create one using
            // the above types and intent as 'sale'
            Payment pymnt = new Payment();
            pymnt.intent = "sale";
            pymnt.payer = payr;
            pymnt.transactions = transactions;

            try
            {
                // ### Api Context
                // Pass in a `APIContext` object to authenticate 
                // the call and to send a unique request id 
                // (that ensures idempotency). The SDK generates
                // a request id if you do not pass one explicitly. 
                 // See [Configuration.cs](/Source/Configuration.html) to know more about APIContext..
                APIContext apiContext = Configuration.GetAPIContext();

                // Create a payment using a valid APIContext
                Payment createdPayment = pymnt.Create(apiContext);
                CurrContext.Items.Add("ResponseJson", JObject.Parse(createdPayment.ConvertToJson()).ToString(Formatting.Indented));
            }
            catch (PayPal.Exception.PayPalException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
            }
            CurrContext.Items.Add("RequestJson", JObject.Parse(pymnt.ConvertToJson()).ToString(Formatting.Indented));
            Server.Transfer("~/Response.aspx");
        }