public override bool Insert(TransactionManager transactionManager, PayoutItem entity) { SqlDatabase database = new SqlDatabase(this._connectionString); DbCommand command = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_Insert", this._useStoredProcedure); database.AddInParameter(command, "@PayoutItemCode", DbType.AnsiString, entity.PayoutItemCode); database.AddInParameter(command, "@PayoutCode", DbType.AnsiString, entity.PayoutCode); database.AddInParameter(command, "@PaymentItemCode", DbType.AnsiString, entity.PaymentItemCode); database.AddInParameter(command, "@PayoutMoney", DbType.Decimal, entity.PayoutMoney.HasValue ? ((object)entity.PayoutMoney) : ((object)DBNull.Value)); database.AddInParameter(command, "@SubjectCode", DbType.AnsiString, entity.SubjectCode); database.AddInParameter(command, "@Remark", DbType.AnsiString, entity.Remark); database.AddInParameter(command, "@AlloType", DbType.AnsiString, entity.AlloType); database.AddInParameter(command, "@IsManualAlloc", DbType.Int32, entity.IsManualAlloc.HasValue ? ((object)entity.IsManualAlloc) : ((object)DBNull.Value)); database.AddInParameter(command, "@PayoutCash", DbType.Decimal, entity.PayoutCash.HasValue ? ((object)entity.PayoutCash) : ((object)DBNull.Value)); database.AddInParameter(command, "@MoneyType", DbType.AnsiString, entity.MoneyType); database.AddInParameter(command, "@ExchangeRate", DbType.Decimal, entity.ExchangeRate.HasValue ? ((object)entity.ExchangeRate) : ((object)DBNull.Value)); database.AddInParameter(command, "@PayoutMoneyType", DbType.AnsiString, entity.PayoutMoneyType); database.AddInParameter(command, "@PayoutExchangeRate", DbType.Decimal, entity.PayoutExchangeRate.HasValue ? ((object)entity.PayoutExchangeRate) : ((object)DBNull.Value)); int num = 0; if (transactionManager != null) { num = Utility.ExecuteNonQuery(transactionManager, command); } else { num = Utility.ExecuteNonQuery(database, command); } entity.OriginalPayoutItemCode = entity.PayoutItemCode; entity.AcceptChanges(); return(Convert.ToBoolean(num)); }
public void PayoutItemDetailsCancelTest() { try { var apiContext = TestingUtil.GetApiContext(); this.RecordConnectionDetails(); // Create a single synchronous payout with an invalid email address. // This will cause the status to be marked as 'UNCLAIMED', allowing // us to cancel the payout. var payoutBatch = PayoutTest.CreateSingleSynchronousPayoutBatch(apiContext); this.RecordConnectionDetails(); Assert.IsNotNull(payoutBatch); Assert.IsNotNull(payoutBatch.items); Assert.IsTrue(payoutBatch.items.Count > 0); var payoutItem = payoutBatch.items[0]; if (payoutItem.transaction_status == PayoutTransactionStatus.UNCLAIMED) { var payoutItemDetails = PayoutItem.Cancel(apiContext, payoutItem.payout_item_id); this.RecordConnectionDetails(); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(PayoutTransactionStatus.RETURNED, payoutItemDetails.transaction_status); } } catch (ConnectionException) { this.RecordConnectionDetails(false); throw; } }
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(); // ### Batch Payout Item ID // The ID of the batch payout item to lookup. var payoutItemId = "Q7DWNN5Y733CQ"; // ^ Ignore workflow code segment #region Track Workflow this.flow.AddNewRequest("Retrieve payout item details", description: "ID: " + payoutItemId); #endregion // ### PayoutItemDetails.Get() // Retrieves the details of the specified batch payout item. var payoutItemDetails = PayoutItem.Get(apiContext, payoutItemId); // ^ Ignore workflow code segment #region Track Workflow this.flow.RecordResponse(payoutItemDetails); #endregion // For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/). }
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)); }
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 void PayoutItemGetTest() { var payoutItemId = "G2CFT8SJRB7RN"; var payoutItemDetails = PayoutItem.Get(TestingUtil.GetApiContext(), payoutItemId); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(payoutItemId, payoutItemDetails.payout_item_id); Assert.AreEqual("8NX77PFLN255E", payoutItemDetails.payout_batch_id); }
public void PayoutItemGetTest() { try { var payoutItemId = "G2CFT8SJRB7RN"; var payoutItemDetails = PayoutItem.Get(TestingUtil.GetApiContext(), payoutItemId); this.RecordConnectionDetails(); Assert.IsNotNull(payoutItemDetails); Assert.AreEqual(payoutItemId, payoutItemDetails.payout_item_id); Assert.AreEqual("8NX77PFLN255E", payoutItemDetails.payout_batch_id); } catch (ConnectionException) { this.RecordConnectionDetails(false); } }
public static PayoutItem CreatePayoutItem(string payoutItemPayoutItemCode, string payoutItemPayoutCode, string payoutItemPaymentItemCode, decimal?payoutItemPayoutMoney, string payoutItemSubjectCode, string payoutItemRemark, string payoutItemAlloType, int?payoutItemIsManualAlloc, decimal?payoutItemPayoutCash, string payoutItemMoneyType, decimal?payoutItemExchangeRate, string payoutItemPayoutMoneyType, decimal?payoutItemPayoutExchangeRate) { PayoutItem item = new PayoutItem(); item.PayoutItemCode = payoutItemPayoutItemCode; item.PayoutCode = payoutItemPayoutCode; item.PaymentItemCode = payoutItemPaymentItemCode; item.PayoutMoney = payoutItemPayoutMoney; item.SubjectCode = payoutItemSubjectCode; item.Remark = payoutItemRemark; item.AlloType = payoutItemAlloType; item.IsManualAlloc = payoutItemIsManualAlloc; item.PayoutCash = payoutItemPayoutCash; item.MoneyType = payoutItemMoneyType; item.ExchangeRate = payoutItemExchangeRate; item.PayoutMoneyType = payoutItemPayoutMoneyType; item.PayoutExchangeRate = payoutItemPayoutExchangeRate; return(item); }
public virtual PayoutItem Copy() { PayoutItem item = new PayoutItem(); item.PayoutItemCode = this.PayoutItemCode; item.OriginalPayoutItemCode = this.OriginalPayoutItemCode; item.PayoutCode = this.PayoutCode; item.PaymentItemCode = this.PaymentItemCode; item.PayoutMoney = this.PayoutMoney; item.SubjectCode = this.SubjectCode; item.Remark = this.Remark; item.AlloType = this.AlloType; item.IsManualAlloc = this.IsManualAlloc; item.PayoutCash = this.PayoutCash; item.MoneyType = this.MoneyType; item.ExchangeRate = this.ExchangeRate; item.PayoutMoneyType = this.PayoutMoneyType; item.PayoutExchangeRate = this.PayoutExchangeRate; item.AcceptChanges(); return(item); }
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" } } }; // ^ Ignore workflow code segment #region Track Workflow this.flow.AddNewRequest("Create single, synchronous 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); // ^ Ignore workflow code segment #region Track Workflow this.flow.RecordResponse(createdPayout); #endregion var payoutItem = createdPayout.items[0]; // ^ Ignore workflow code segment #region Track Workflow this.flow.AddNewRequest("Cancel the payout item", description: "ID: " + payoutItem.payout_item_id); #endregion // ### Payout.Cancel() // Call Payout.Cancel() to cancel the payout item. var cancelledPayoutItem = PayoutItem.Cancel(apiContext, payoutItem.payout_item_id); // ^ Ignore workflow code segment #region Track Workflow this.flow.RecordResponse(cancelledPayoutItem); #endregion // For more information, please visit [PayPal Developer REST API Reference](https://developer.paypal.com/docs/api/). }