/// <summary> /// Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items. /// </summary> /// <param name="apiContext">APIContext used for the API call.</param> /// <param name="payout">Payout object to be created as a PayPal resource.</param> /// <param name="syncMode">A value of true will provide an immediate, synchronous response. Without this query keyword or if the value is false, the response will be a background batch mode.</param> /// <returns>PayoutCreateResponse</returns> public static PayoutBatch Create(APIContext apiContext, Payout payout, bool syncMode = false) { // Validate the arguments to be used in the request ArgumentValidator.ValidateAndSetupAPIContext(apiContext); ArgumentValidator.Validate(syncMode, "syncMode"); var queryParameters = new QueryParameters(); queryParameters["sync_mode"] = syncMode.ToString(); // Configure and send the request var resourcePath = "v1/payments/payouts" + queryParameters.ToUrlFormattedString(); return PayPalResource.ConfigureAndExecute<PayoutBatch>(apiContext, HttpMethod.POST, resourcePath, payout.ConvertToJson()); }
public ActionResult TestPayout() { var payout = new PayPal.Api.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 = "0.99", currency = "USD" }, receiver = "*****@*****.**", 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 = "4532216992026816", note = "Thank you.", sender_item_id = "item_3" } } }; var createdPayout = payout.Create(PaypalConfig.GetAPIContext(), false); return(Success(1)); }
/// <summary> /// Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items. /// </summary> /// <param name="apiContext">APIContext used for the API call.</param> /// <param name="payout">Payout object to be created as a PayPal resource.</param> /// <param name="syncMode">A value of true will provide an immediate, synchronous response. Without this query keyword or if the value is false, the response will be a background batch mode.</param> /// <returns>PayoutCreateResponse</returns> public static PayoutBatch Create(APIContext apiContext, Payout payout, bool syncMode = false) { // Validate the arguments to be used in the request ArgumentValidator.ValidateAndSetupAPIContext(apiContext); ArgumentValidator.Validate(syncMode, "syncMode"); var queryParameters = new QueryParameters(); queryParameters["sync_mode"] = syncMode.ToString(); // Configure and send the request var resourcePath = "v1/payments/payouts" + queryParameters.ToUrlFormattedString(); return(PayPalResource.ConfigureAndExecute <PayoutBatch>(apiContext, HttpMethod.POST, resourcePath, payout.ConvertToJson())); }
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 = "0.99", currency = "USD" }, receiver = "*****@*****.**", 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/). }
/// <summary> /// Create a payout batch resource by passing a sender_batch_header and an items array to the request URI. The sender_batch_header contains payout parameters that describe the handling of a batch resource while the items array conatins payout items. /// </summary> /// <param name="apiContext">APIContext used for the API call.</param> /// <param name="syncMode">A value of true will provide an immediate, synchronous response. Without this query keyword or if the value is false, the response will be a background batch mode.</param> /// <returns>PayoutCreateResponse</returns> public PayoutBatch Create(APIContext apiContext, bool syncMode = false) { return(Payout.Create(apiContext, this, syncMode)); }