Beispiel #1
0
        public static void SendMoney()
        {
            var apiContext = Configuration.GetAPIContext();

            var paymentList = Payment.List(apiContext);
            var payout      = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You have a payment"
                },
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = "8.99",
                            currency = "EUR"
                        },
                        receiver       = "*****@*****.**",
                        note           = "Thank you.",
                        sender_item_id = "item_1"
                    }
                }
            };


            var createdPayout = payout.Create(apiContext);
        }
        public PayoutBatchHeader SendPayment(string reciverEmail, decimal amount, string note)
        {
            var apiContext = PaypalConfiguration.GetAPIContext();
            var payout     = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You have redeem points payment"
                },

                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = decimal.Round(amount, 2).ToString(),
                            currency = "USD"
                        },
                        receiver       = reciverEmail,
                        note           = note,
                        sender_item_id = "item_1"
                    }
                }
            };

            PayoutBatch createdPayout = payout.Create(apiContext, false);

            return(createdPayout.batch_header);
        }
        private PayoutBatch CreatePayout()
        {
            var        payout     = new Payout();
            APIContext ApiContext = Configuration.GetAPIContext();

            var sender_batch_header = new PayoutSenderBatchHeader()
            {
                email_subject   = "You have a payout!",
                sender_batch_id = "Payouts_2018_" + Convert.ToString((new Random()).Next(100000))
            };
            var amount = new Currency()
            {
                currency = "USD",
                value    = "100"
            };
            var payoutitem = new List <PayoutItem>();
            var item       = new PayoutItem()
            {
                recipient_type = PayoutRecipientType.PHONE,
                amount         = amount,
                note           = "Học phí",
                sender_item_id = Convert.ToString((new Random()).Next(100000)),
                receiver       = "408-491-2437"
            };

            payoutitem.Add(item);
            payout.items = payoutitem;
            payout.sender_batch_header = sender_batch_header;
            return(Payout.Create(ApiContext, payout));
        }
        private void DoPayPalPayment(double price)
        {
            var config      = ConfigManager.Instance.GetProperties();
            var accessToken = new OAuthTokenCredential(config).GetAccessToken();
            var apiContext  = new APIContext(accessToken);

            var payout = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = "batch_" + Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You have payment",
                    recipient_type  = PayoutRecipientType.EMAIL
                },

                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency {
                            value = price.ToString(), currency = "USD"
                        },
                        receiver       = "*****@*****.**",
                        note           = "Thank you",
                        sender_item_id = "item_1"
                    }
                }
            };

            var created = payout.Create(apiContext, false);
        }
 public static PayoutBatch CreateSingleSynchronousPayoutBatch(APIContext apiContext)
 {
     return(Payout.Create(apiContext, new Payout
     {
         sender_batch_header = new PayoutSenderBatchHeader
         {
             sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
             email_subject = "You have a Payout!"
         },
         items = new List <PayoutItem>
         {
             new PayoutItem
             {
                 recipient_type = PayoutRecipientType.EMAIL,
                 amount = new Currency
                 {
                     value = "1.0",
                     currency = "USD"
                 },
                 note = "Thanks for the payment!",
                 sender_item_id = "2014031400023",
                 receiver = "*****@*****.**"
             }
         }
     },
                          true));
 }
        public async Task <PayoutBatch> CreateAsync(
            string transactionId,
            string email,
            decimal amount,
            string?description   = null,
            string?correlationId = null
            )
        {
            var payout = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    email_subject   = Options.Payout.Email.Subject,
                    sender_batch_id = correlationId ?? Guid.NewGuid().ToString(),
                    recipient_type  = PayoutRecipientType.EMAIL
                },
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        amount = new Currency
                        {
                            currency = Options.Payout.Currency,
                            value    = amount.ToString(CultureInfo.InvariantCulture)
                        },
                        receiver       = email,
                        note           = description ?? Options.Payout.Email.Note,
                        sender_item_id = transactionId
                    }
                }
            };

            return(await Task.FromResult(Payout.Create(Context, payout)));
        }
Beispiel #7
0
        public void Payouts(IEnumerable <AdminPayoutsViewModel> models)
        {
            var apiToken = new OAuthTokenCredential(settings.ClientId, settings.ClientSecret)
                           .GetAccessToken();

            var apiContext = new APIContext(apiToken);

            var payoutItems = new List <PayoutItem>();

            foreach (var model in models)
            {
                var payoutItem = new PayoutItem
                {
                    recipient_type = PayoutRecipientType.EMAIL,
                    amount         = new Currency
                    {
                        value    = model.Amount.ToString(),
                        currency = "EUR"
                    },
                    receiver       = model.Email,
                    note           = $"{model.Email} have a payment of  {model.Amount}",
                    sender_item_id = Guid.NewGuid().ToString()
                };

                payoutItems.Add(payoutItem);
            }

            var payout = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You Have a Payment!"
                },
                items = payoutItems,
            };

            var createPayout = payout.Create(apiContext);

            var batchId = createPayout.batch_header.payout_batch_id;
            var get     = Payout.Get(apiContext, batchId);

            var price = decimal.Parse(get.batch_header.amount.value);

            var payoutPayPal = new PayoutPayPal
            {
                BatchId   = batchId,
                Amount    = price,
                CreatedOn = DateTime.UtcNow.AddHours(GlobalConstants.BULGARIAN_HOURS_FROM_UTC_TIME)
            };

            var forDelete = this.db.PaymentsToInstructors.ToList();

            this.db.PaymentsToInstructors.RemoveRange(forDelete);

            this.db.PayoutPayPals.Add(payoutPayPal);
            this.db.SaveChanges();
        }
        public ActionResult GetPayout()
        {
            var pay = CreatePayout();

            if (pay.batch_header.batch_status == "PENDING")
            {
                APIContext ApiContext = Configuration.GetAPIContext();
                var        payout     = new Payout();
                payout.Create(ApiContext);
                return(Json(Payout.Get(ApiContext, pay.batch_header.payout_batch_id), JsonRequestBehavior.AllowGet));
            }
            return(Json(-1, JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        private TransactionResponse CommitTransactionUsingLatestApi(TransactionRequest request)
        {
            Random random = new Random();

            int batchID1 = 1000000 + random.Next(1, 1000000);
            int batchID2 = 1000000 + random.Next(1, 1000000);

            var config = new Dictionary <string, string>();

            config["mode"]         = "live";
            config["clientId"]     = accountDetails.ClientID;
            config["clientSecret"] = accountDetails.ClientSecret;

            var accessToken = new OAuthTokenCredential(config).GetAccessToken();
            var apiContext  = new APIContext(accessToken);

            var payout = new Payout
            {
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = batchID1.ToString(),
                    email_subject   = AppSettings.Payments.TransactionNote,
                    recipient_type  = PayoutRecipientType.EMAIL
                },
                items = new List <PayoutItem>()
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = request.Payment.ToShortClearString(),
                            currency = AppSettings.Site.CurrencyCode
                        },
                        note           = AppSettings.Payments.TransactionNote,
                        sender_item_id = batchID2.ToString(),
                        receiver       = request.PayeeId
                    }
                }
            };

            var result = payout.Create(apiContext);

            string PayoutBatchID = result.batch_header.payout_batch_id;

            return(new PayPalTransactionResponse(this, Payout.Get(apiContext, PayoutBatchID)));
        }
Beispiel #10
0
        public PayoutBatch SendPayout(string subject, List <PayoutItem> payouts)
        {
            try
            {
                var payout = new Payout()
                {
                    sender_batch_header = new PayoutSenderBatchHeader
                    {
                        sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                        email_subject   = subject
                    },
                    items = payouts
                };

                return(payout.Create(PaypalConfig.GetAPIContext(), false));
            }
            catch
            {
                return(null);
            }
        }
Beispiel #11
0
        public bool execute()
        {
            // ### Initialize `Payout` Object tests
            // Initialize a new `Payout` object with details of the batch payout to be created.
            var payout = new Payout
            {
                // #### items
                // The `items` array contains the list of payout items to be included in this payout.
                // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                // array can contain more than one item.
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = amount.ToString(),
                            currency = currency
                        },
                        receiver       = receiver,
                        note           = "Thank you.",
                        sender_item_id = "item_1"
                    },
                }
            };

            // ### Payout.Create()
            // Creates the batch payout resource.
            // `syncMode = false` indicates that this call will be performed **asynchronously**,
            // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
            // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
            // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
            var createdPayout = payout.Create(apiContext, true);

            ZDatabaseManager.sendTransactionQuery(this.accountID, -amount, 2, 6, 2);

            return(true);
        }
        public bool Transfer(string gmail, double amount)
        {
            using (var scope = new TransactionScope())
            {
                var apiContext =
                    new APIContext(new OAuthTokenCredential(PaypalConfig.CLIENT_ID, PaypalConfig.CLIENT_SECRET)
                                   .GetAccessToken());

                var payout = new Payout
                {
                    sender_batch_header = new PayoutSenderBatchHeader
                    {
                        sender_batch_id = "batch_" + Guid.NewGuid().ToString().Substring(0, 8),
                        email_subject   = "Money for service completion"
                    },

                    items = new List <PayoutItem>
                    {
                        new PayoutItem
                        {
                            recipient_type = PayoutRecipientType.EMAIL,
                            amount         = new Currency
                            {
                                value    = amount.ToString(),
                                currency = "USD"
                            },
                            receiver       = gmail,
                            note           = "Thank for using our service",
                            sender_item_id = "item_1"
                        }
                    }
                };

                var created = payout.Create(apiContext, false);
                Console.WriteLine(created.batch_header.time_completed);
                return(true);
            }
        }
Beispiel #13
0
        public ActionResult PayoutWithPaypal(int credits = 0)
        {
            ApplicationUserRepository <Tester> userRepo = new ApplicationUserRepository <Tester>();
            Tester tester = userRepo.GetByUserName(User.Identity.Name);

            if (credits < 100)
            {
                TempData["error"] = "Minimal amount of credits for withdraw is 100 (1 EUR)";
                ViewBag.Credits   = tester.Credits;
                return(View("Withdraw"));
            }

            if (tester.Credits < credits)
            {
                TempData["error"] = "You don't have required amount of credits!";
                ViewBag.Credits   = tester.Credits;
                return(View("Withdraw"));
            }

            //getting the apiContext
            APIContext apiContext = PaypalConfiguration.GetAPIContext();

            try
            {
                var payout = new Payout
                {
                    // #### sender_batch_header
                    // Describes how the payments defined in the `items` array are to be handled.
                    sender_batch_header = new PayoutSenderBatchHeader
                    {
                        sender_batch_id = "batch_" + Guid.NewGuid().ToString().Substring(0, 8),
                        email_subject   = "You have a payment"
                    },
                    // #### items
                    // The `items` array contains the list of payout items to be included in this payout.
                    // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                    // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                    // array can contain more than one item.
                    items = new List <PayoutItem>
                    {
                        new PayoutItem
                        {
                            recipient_type = PayoutRecipientType.EMAIL,
                            amount         = new Currency
                            {
                                value    = ((int)(credits * 0.01)).ToString(),
                                currency = "EUR"
                            },
                            receiver       = tester.Email,
                            note           = "Thank you.",
                            sender_item_id = "item_1"
                        }
                    }
                };

                var creatPayout = payout.Create(apiContext, false);
            }
            catch (Exception ex)
            {
                TempData["error"] = "Withdraw failed";
                ViewBag.Credits   = tester.Credits;
                return(View("Withdraw"));
            }

            //on successful payment, show success page to user.
            tester.Credits = tester.Credits - credits;
            userRepo.Update(tester);

            ViewBag.Credits     = tester.Credits;
            TempData["success"] = "Withdraw request succeed. Please check your mailbox and follow instructions of PayPal company.";
            return(View("Withdraw"));
        }
Beispiel #14
0
        protected override void RunSample()
        {
            // ### 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.
            var apiContext = Configuration.GetAPIContext();

            // ### Initialize `Payout` Object
            // Initialize a new `Payout` object with details of the batch payout to be created.
            var payout = new Payout
            {
                // #### sender_batch_header
                // Describes how the payments defined in the `items` array are to be handled.
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You have a payment"
                },
                // #### items
                // The `items` array contains the list of payout items to be included in this payout.
                // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                // array can contain more than one item.
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = Session["amountToPaypal"].ToString(),
                            currency = "USD"
                        },
                        receiver       = "*****@*****.**",//Session["whoToPaypal"].ToString(),
                        note           = "Thank you.",
                        sender_item_id = "item_1"
                    }//,
                     //new PayoutItem
                     //{
                     //    recipient_type = PayoutRecipientType.EMAIL,
                     //    amount = new Currency
                     //    {
                     //        value = "0.90",
                     //        currency = "USD"
                     //    },
                     //    receiver = "*****@*****.**",
                     //    note = "Thank you.",
                     //    sender_item_id = "item_2"
                     //},
                     //new PayoutItem
                     //{
                     //    recipient_type = PayoutRecipientType.EMAIL,
                     //    amount = new Currency
                     //    {
                     //        value = "2.00",
                     //        currency = "USD"
                     //    },
                     //    receiver = "*****@*****.**",
                     //    note = "Thank you.",
                     //    sender_item_id = "item_3"
                     //}
                }
            };

            // ^ Ignore workflow code segment
            //#region Track Workflow
            //this.flow.AddNewRequest("Create payout", payout);
            //#endregion

            // ### Payout.Create()
            // Creates the batch payout resource.
            // `syncMode = false` indicates that this call will be performed **asynchronously**,
            // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
            // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
            // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
            var createdPayout = payout.Create(apiContext, false);

            // ^ Ignore workflow code segment
            //#region Track Workflow
            //this.flow.RecordResponse(createdPayout);
            //#endregion

            // For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/).
        }
        protected void cashout_Click(object sender, EventArgs e)
        {
            if (Session["CashoutAmount"] == null)
            {
                Response.Write("<script>alert('Please select Reward Amount you want to get')</script>");
            }
            else
            {
                SqlConnection sc = new SqlConnection();
                sc.ConnectionString = ConfigurationManager.ConnectionStrings["GroupProjectConnectionString"].ConnectionString;
                sc.Open();
                SqlCommand insert = new SqlCommand();
                insert.Connection = sc;

                insert.CommandText = "SELECT [TotalAmount] FROM [MoneyTransaction] where MoneyTransactionID=(select max(MoneyTransactionID) from MoneyTransaction)";
                SqlDataReader reader = insert.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    int totalPoints = Convert.ToInt32(reader["TotalAmount"]);
                    reader.Close();
                    int        sessionID = (int)(Session["ID"]);
                    SqlCommand trans     = new SqlCommand("select value from giftcard where giftcardID = @giftcardID");
                    trans.Parameters.AddWithValue("@giftcardID", rblcashout.SelectedValue);
                    trans.Connection = sc;
                    SqlDataReader transReader = trans.ExecuteReader();
                    transReader.Read();
                    Session["transAmount"] = Convert.ToInt32(transReader["value"]);
                    int transactionAmount = (int)(Session["transAmount"]);
                    transReader.Close();
                    if (totalPoints >= transactionAmount && (Convert.ToInt32(Session["PointsBalance"]) > transactionAmount))
                    {
                        MoneyTransaction newTransaction = new MoneyTransaction(totalPoints, DateTime.Today.ToShortDateString(), transactionAmount, DateTime.Today.ToShortDateString(), Session["loggedIn"].ToString(), Convert.ToInt32(Session["ID"]));
                        insert.CommandText = "INSERT INTO [dbo].[MoneyTransaction] ([Date],[TotalAmount],[TransactionAmount],[LastUpdated],[LastUpdatedBy],[PersonID])" +
                                             "VALUES (@Date,@TotalAmount,@TransactionAmount,@LastUpdated,@LastUpdatedBy,@PersonID)";
                        insert.Parameters.AddWithValue("@TotalAmount", totalPoints - transactionAmount);
                        insert.Parameters.AddWithValue("@Date", newTransaction.getDate());
                        insert.Parameters.AddWithValue("@TransactionAmount", newTransaction.getTransactionAmount());
                        insert.Parameters.AddWithValue("@LastUpdated", newTransaction.getLUD());
                        insert.Parameters.AddWithValue("@LastUpdatedBy", newTransaction.getLUDB());
                        insert.Parameters.AddWithValue("@PersonID", newTransaction.getPersonID());
                        insert.ExecuteNonQuery();
                        //amount to pay billyjacks son, this is
                        Session["payProvider"]      = newTransaction.getTransactionAmount();
                        Session["providerToPaypal"] = "*****@*****.**";//sql statement to grab email of the provider of giftcard based on provider name of card - from/in table provider
                        //
                        string payp       = Session["PointsBalance"].ToString();
                        var    apiContext = Configuration.GetAPIContext();

                        // ### Initialize `Payout` Object
                        // Initialize a new `Payout` object with details of the batch payout to be created.
                        var payout = new Payout
                        {
                            // #### sender_batch_header
                            // Describes how the payments defined in the `items` array are to be handled.
                            sender_batch_header = new PayoutSenderBatchHeader
                            {
                                sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                                email_subject   = "You have a payment"
                            },
                            // #### items
                            // The `items` array contains the list of payout items to be included in this payout.
                            // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                            // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                            // array can contain more than one item.
                            items = new List <PayoutItem>
                            {
                                new PayoutItem
                                {
                                    recipient_type = PayoutRecipientType.EMAIL,
                                    amount         = new Currency
                                    {
                                        value    = payp,//paypalAmount.ToString(),
                                        currency = "USD"
                                    },
                                    receiver       = "*****@*****.**",//Session["providerToPaypal"].ToString(),
                                    note           = "Thank you.",
                                    sender_item_id = "item_1"
                                }//,
                                 //new PayoutItem
                                 //{
                                 //    recipient_type = PayoutRecipientType.EMAIL,
                                 //    amount = new Currency
                                 //    {
                                 //        value = "0.90",
                                 //        currency = "USD"
                                 //    },
                                 //    receiver = "*****@*****.**",
                                 //    note = "Thank you.",
                                 //    sender_item_id = "item_2"
                                 //},
                                 //new PayoutItem
                                 //{
                                 //    recipient_type = PayoutRecipientType.EMAIL,
                                 //    amount = new Currency
                                 //    {
                                 //        value = "2.00",
                                 //        currency = "USD"
                                 //    },
                                 //    receiver = "*****@*****.**",
                                 //    note = "Thank you.",
                                 //    sender_item_id = "item_3"
                                 //}
                            }
                        };

                        // ^ Ignore workflow code segment
                        //#region Track Workflow
                        //this.flow.AddNewRequest("Create payout", payout);
                        //#endregion

                        // ### Payout.Create()
                        // Creates the batch payout resource.
                        // `syncMode = false` indicates that this call will be performed **asynchronously**,
                        // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
                        // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
                        // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
                        var createdPayout = payout.Create(apiContext, false);
                        //RunSample();

                        //employee receipt
                        SqlCommand insertgcr = new SqlCommand();
                        insertgcr.Connection  = sc;
                        insertgcr.CommandText = "INSERT INTO [dbo].[GiftCardReceipt]([GiftCardID],[PersonID],[PurchaseDate],[LastUpdated],[LastUpdatedBy],[ConfirmationNumber]) VALUES ( @GiftCardID, @PersonID, @PurchaseDate, @LastUpdated, @LastUpdatedBy, @ConfirmationNumber)";


                        string giftcardID   = rblcashout.SelectedValue;
                        Random rnd          = new Random();
                        int    confirmation = rnd.Next(5, 100);


                        insertgcr.Parameters.AddWithValue("@GiftCardReceiptID", 1);
                        insertgcr.Parameters.AddWithValue("@GiftCardID", giftcardID);
                        insertgcr.Parameters.AddWithValue("@PersonID", Session["ID"]);
                        insertgcr.Parameters.AddWithValue("@PurchaseDate", DateTime.Now);
                        insertgcr.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
                        insertgcr.Parameters.AddWithValue("@LastUpdatedby", Session["loggedIn"].ToString());
                        insertgcr.Parameters.AddWithValue("@ConfirmationNumber", confirmation);

                        insertgcr.ExecuteNonQuery();



                        Response.Redirect("EmployeeReciept.aspx");
                        SqlCommand getItBoy = new SqlCommand();

                        //employee receipt end
                        sc.Close();
                        Response.Write("<script>alert('Transaction Submited')</script>");

                        rewardpool();
                    }
                    else
                    {
                        Response.Write("<script>alert('personal points not enough or Bank balance low')</script>");
                    }
                    SampleItem newPayout = new SampleItem {
                        Title = "Create a payout", ExecutePage = "PayoutCreate.aspx", HasSourcePage = true
                    };
                }
            }
        }
        public void payoutFunction(ApplicationCart cart)
        {
            // ### 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.
            var apiContext = PaypalConfiguration.GetAPIContext();

            // ### Initialize `Payout` Object
            // Initialize a new `Payout` object with details of the batch payout to be created.
            var payout = new Payout
            {
                // #### sender_batch_header
                // Describes how the payments defined in the `items` array are to be handled.
                sender_batch_header = new PayoutSenderBatchHeader
                {
                    sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                    email_subject   = "You have a payment"
                },
                // #### items
                // The `items` array contains the list of payout items to be included in this payout.
                // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
                // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
                // array can contain more than one item.
                items = new List <PayoutItem>
                {
                    new PayoutItem
                    {
                        recipient_type = PayoutRecipientType.EMAIL,
                        amount         = new Currency
                        {
                            value    = cart.TotalPrice.ToString(),
                            currency = cart.Currency
                        },
                        receiver       = "*****@*****.**",
                        note           = "Thank you for shopping.",
                        sender_item_id = "item_1"
                    },
                    //new PayoutItem
                    //{
                    //    recipient_type = PayoutRecipientType.EMAIL,
                    //    amount = new Currency
                    //    {
                    //        value = "7",
                    //        currency = "USD"
                    //    },
                    //    receiver = "*****@*****.**",
                    //    note = "Thank you for coming.",
                    //    sender_item_id = "item_2"
                    //},
                    //new PayoutItem
                    //{
                    //    recipient_type = PayoutRecipientType.EMAIL,
                    //    amount = new Currency
                    //    {
                    //        value = "2.00",
                    //        currency = "USD"
                    //    },
                    //    receiver = "ng-facilitator_api1.narola.email",
                    //    note = "Thank you.",
                    //    sender_item_id = "item_3"
                    //}
                }
            };
            // ### Payout.Create()
            // Creates the batch payout resource.
            // `syncMode = false` indicates that this call will be performed **asynchronously**,
            // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
            // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
            // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
            var createdPayout = payout.Create(apiContext);

            PayoutBatch payoutPayment = Payout.Get(apiContext, createdPayout.batch_header.payout_batch_id);
        }
    protected void Button1_Click1(object sender, EventArgs e)
    {
        var apiContext = Configuration.GetAPIContext();

        // Initialize a new `Payout` object with details of the batch payout to be created.
        var payout = new Payout
        {
            // #### sender_batch_header
            // Describes how the payments defined in the `items` array are to be handled.
            sender_batch_header = new PayoutSenderBatchHeader
            {
                sender_batch_id = "batch_" + System.Guid.NewGuid().ToString().Substring(0, 8),
                email_subject   = "You have a payment"
            },
            // #### items
            // The `items` array contains the list of payout items to be included in this payout.
            // If `syncMode` is set to `true` when calling `Payout.Create()`, then the `items` array must only
            // contain **one** item.  If `syncMode` is set to `false` when calling `Payout.Create()`, then the `items`
            // array can contain more than one item.
            items = new List <PayoutItem>
            {
                new PayoutItem
                {
                    recipient_type = PayoutRecipientType.EMAIL,
                    amount         = new Currency
                    {
                        value    = "5",
                        currency = "USD"
                    },
                    receiver       = "*****@*****.**",
                    note           = "Thank you.",
                    sender_item_id = "item_1"
                }
                //new PayoutItem
                //{
                //    recipient_type = PayoutRecipientType.EMAIL,
                //    amount = new Currency
                //    {
                //        value = "0.10",
                //        currency = "USD"
                //    },
                //    receiver = "*****@*****.**",
                //    note = "Thank you.",
                //    sender_item_id = "item_2"
                //},
                //new PayoutItem
                //{
                //    recipient_type = PayoutRecipientType.EMAIL,
                //    amount = new Currency
                //    {
                //        value = "0.10",
                //        currency = "USD"
                //    },
                //    receiver = "*****@*****.**",
                //    note = "Thank you.",
                //    sender_item_id = "item_3"
                //}
            }
        };

        // ^ Ignore workflow code segment
        //#region Track Workflow
        //this.flow.AddNewRequest("Create payout", payout);
        //#endregion

        // ### Payout.Create()
        // Creates the batch payout resource.
        // `syncMode = false` indicates that this call will be performed **asynchronously**,
        // and will return a `payout_batch_id` that can be used to check the status of the payouts in the batch.
        // `syncMode = true` indicates that this call will be performed **synchronously** and will return once the payout has been processed.
        // > **NOTE**: The `items` array can only have **one** item if `syncMode` is set to `true`.
        var createdPayout = payout.Create(apiContext, true);

        Label1.Text = createdPayout.batch_header.payout_batch_id;



        var payoutBatchId = Label1.Text;



        var payoutt = Payout.Get(apiContext, payoutBatchId);

        //var payoutItemId = Label1.Text;

        //var payoutItemDetails = PayoutItem.Get(apiContext, payoutItemId);
        Label2.Text = payoutt.batch_header.batch_status;
    }