protected void Page_Load(object sender, EventArgs e) { // Get collection id Int32 id = Convert.ToInt32(Request["id"]); if (id != 0) { try { // Create Payments helper PaymentsHelper ph = new PaymentsHelper(); // Create a token for the API's calls Token token = ph.CreateAccessToken(Properties.Settings.Default.ClientId, Properties.Settings.Default.ClientSecret); ph.AccessToken = token.AccessToken; // Get Collection Notification CollectionNotification cn = ph.GetCollectionNotification(id); // Here goes your code: do something with the notification! // Remember: IPN system waits for your reply about 500ms. If this method times out that threshold it will retry the // notification again. So prepare your code to be fast enough and/or to support retries (ask if the collection was // already processed!). // In this example: Show collection's json Response.Write(cn.ToJSON().ToString()); } catch (Exception ex) { } } }
private void LoadSearchGrid(int offset, int pageSize) { // Set PaymentHelper PaymentsHelper ph = GetPaymentsHelper(); // Get Collections List <KeyValuePair <string, string> > args = new List <KeyValuePair <string, string> >(); args.Add(new KeyValuePair <string, string>("sort", "date_created")); args.Add(new KeyValuePair <string, string>("criteria", "desc")); args.Add(new KeyValuePair <string, string>("offset", (offset - 1).ToString())); args.Add(new KeyValuePair <string, string>("limit", pageSize.ToString())); SearchPage <Collection> searchPage = ph.SearchCollections(args); List <Collection> collections = searchPage.Results; // Bind this info to the grid view CollectionsGridView.DataSource = collections; CollectionsGridView.DataBind(); // Set pager info PagerFrom.Text = offset.ToString(); PagerTo.Text = (offset + collections.Count - 1).ToString(); PagerTotal.Text = searchPage.Total.ToString(); PagerPanel.Visible = true; }
private PaymentsHelper GetPaymentsHelper() { // Check api token if (_token == null) { // Create new token for api calls _token = AuthHelper.CreateAccessToken(ClientIdTxt.Text, ClientSecretTxt.Text); } else { // Check token expiration time if (_token.DateExpired.CompareTo(DateTime.Now) <= 0) { // Regenerate token _token = AuthHelper.CreateAccessToken(ClientIdTxt.Text, ClientSecretTxt.Text); } } // Set PaymentHelper if (_ph == null) { _ph = new PaymentsHelper(); } _ph.AccessToken = _token.AccessToken; return(_ph); }
public void OnPayment(object sender, EventArgs e) { if (DBHelper.Instance.GetToken() != null) { var token = new PaymentsHelper().GetClientToken(); if (token.Status == System.Net.HttpStatusCode.OK) { DependencyService.Get <IPaymentDropIn>().ShowInit(token.Token); } } }
private void btnInsert_Click(object sender, EventArgs e) { if (tCardNumber.Text.Length != 16 && tCVV.Text.Length != 3) { MessageBox.Show("Cardnumber cannot be shorter or longer than 16 digits"); } else { PaymentsHelper.CreatePayment(int.Parse(tCustomerID.Text), tFirstName.Text, tLastName.Text, tCreditCard.Text, tCardNumber.Text, tCVV.Text, tExpirationDate.Text); } dataGridView1.DataSource = PaymentsHelper.LoadPaymentsData(); }
/// <summary> /// Recursively tries to get a collections page from the MP API. /// </summary> public static SearchPage <Collection> GetCollectionsPage(Int32 offset, Int32 limit, OAuthResponse authorization, DateTime dateFrom, DateTime dateTo, int retryNumber = 0) { PaymentsHelper ph = new PaymentsHelper(); // Set access token ph.AccessToken = GetAccessToken(authorization); // Prepare API call arguments List <KeyValuePair <string, string> > args = new List <KeyValuePair <string, string> >(); if (authorization.IsAdmin) { args.Add(new KeyValuePair <string, string>("collector_id", authorization.UserId.ToString())); } // Try optimize the query by site id, taking advantage of the search sharding if (authorization.SiteId != null) { args.Add(new KeyValuePair <string, string>("site_id", authorization.SiteId)); } args.Add(new KeyValuePair <string, string>("sort", "date_created")); args.Add(new KeyValuePair <string, string>("criteria", "desc")); args.Add(new KeyValuePair <string, string>("offset", offset.ToString())); args.Add(new KeyValuePair <string, string>("limit", limit.ToString())); args.Add(new KeyValuePair <string, string>("range", "date_created")); args.Add(new KeyValuePair <string, string>("begin_date", HttpUtility.UrlEncode(dateFrom.GetDateTimeFormats('s')[0].ToString() + ".000Z"))); args.Add(new KeyValuePair <string, string>("end_date", HttpUtility.UrlEncode(dateTo.GetDateTimeFormats('s')[0].ToString() + ".000Z"))); SearchPage <Collection> searchPage = null; try { // Search the API searchPage = ph.SearchCollections(args); } catch (RESTAPIException raex) { // Retries the same call until max is reached if (retryNumber <= MAX_RETRIES) { LogHelper.WriteLine("SearchCollections breaks. Retry num: " + retryNumber.ToString()); BackendHelper.GetCollectionsPage(offset, limit, authorization, dateFrom, dateTo, retryNumber + 1); } else { // then breaks throw raex; } } return(searchPage); }
async void OnPay(object sender, EventArgs e) { var token = new PaymentsHelper().GetClientToken(); if (token.Status == System.Net.HttpStatusCode.OK) { var res = await DependencyService.Get <IPaymentDropIn>().ShowPay(token.Token, booking.Id.Value); if (res) { Start(); } } }
private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (e.ColumnIndex == 6 || e.ColumnIndex == 7) { if (e.Value != null) { e.Value = PaymentsHelper.MaskCardNumberAndCVV(e.Value.ToString()); e.FormattingApplied = true; } else { e.FormattingApplied = false; } } }
protected void CancelCollectionButton_Click(object sender, EventArgs e) { // Set PaymentHelper PaymentsHelper ph = GetPaymentsHelper(); // Try cancel the collection try { ph.CancelCollection(Convert.ToInt32(ColIdCancelColText.Text)); ShowLabelMessageOk(CancelCollectionResult); } catch (Exception ex) { ShowLabelMessageError(CancelCollectionResult, ex.Message); } }
private void FillSettings(AccessDataEntity accessData, uint projectId, string transactionId) { accessData.settings = new AccessDataEntity.Settings { project_id = projectId, currency = "USD", mode = XsollaSettings.IsSandbox ? "sandbox" : null, external_id = transactionId, xsolla_product_tag = PaymentsHelper.GetAdditionalInformation("simplified"), ui = new AccessDataEntity.Settings.UI { size = "medium", theme = PaystationThemeHelper.ConvertToSettings(XsollaSettings.PaystationTheme) } }; }
/// <summary> /// Отмена платежа /// </summary> public void PaymentCancel(PaymentKeyInfo paymentKeyInfo) { try { //ApplicationConfiguration.Instance.ConnectionString = Host.GetConnectionString(); if (AutorizationHelper.CheckAutorizaton()) { PaymentsHelper.DoPaymentCancel(paymentKeyInfo); } } catch (Exception ex) { LogManager.CurrentLogger.Error("PaymentCancel", ex); MessageBox.Show(String.Format("Произошла непредвиденная ошибка, свяжитесь с службой поддержки \"Электронный платеж\"")); throw ex; } }
/// <summary> /// Получает список платежей /// </summary> public List <PaymentInfo> RecievePayments(RecievePaymentParameters recievePaymentParameters) { try { //ApplicationConfiguration.Instance.ConnectionString = Host.GetConnectionString(); if (AutorizationHelper.CheckAutorizaton()) { return(PaymentsHelper.DoRecievePayments(recievePaymentParameters)); } return(new List <PaymentInfo>()); } catch (Exception ex) { LogManager.CurrentLogger.Error("RecievePayments error", ex); MessageBox.Show(String.Format("Произошла непредвиденная ошибка, свяжитесь с службой поддержки \"Электронный платеж\"")); return(new List <PaymentInfo>()); } }
protected void ChangeExternalReferenceButton_Click(object sender, EventArgs e) { // Set PaymentHelper PaymentsHelper ph = GetPaymentsHelper(); // Try change the collection's external reference try { Collection collection = new Collection(); collection.Id = Convert.ToInt32(ColIdChangeExtRefText.Text); collection.ExternalReference = NewExternalReferenceText.Text; ph.UpdateCollection(collection); ShowLabelMessageOk(ChangeExternalReferenceResult); } catch (Exception ex) { ShowLabelMessageError(ChangeExternalReferenceResult, ex.Message); } }
public IActionResult GetPayments(string userid) { using (var db = new db()) { var payments = (from payment in db.payments where payment.UserId == userid select payment).ToList(); if (payments != null || payments.Count > 0) { PaymentsHelper helper = new PaymentsHelper(payments); double balance = helper.Balance; PaymentsResponseDto response = new PaymentsResponseDto(); response.AccountBalance = balance; response.Payments = payments; return(Ok(response)); } } return(NotFound()); }
/// <summary> /// Executes a CloudScript function. /// This cloud script allows to open purchase url with one item. /// </summary> /// <see cref="https://docs.microsoft.com/ru-ru/rest/api/playfab/client/server-side-cloud-script/executecloudscript?view=playfab-rest"/> /// <param name="itemId">Unique identifier of the item to purchase.</param> /// <param name="orderId">Purchase order identifier.</param> /// <param name="onSuccess">Success operation callback.</param> /// <param name="onError">Failed operation callback.</param> private void ExecuteCloudScript(string itemId, string orderId, [NotNull] Action <CloudScriptResultEntity> onSuccess, [CanBeNull] Action <Error> onError = null) { var url = PlayfabApi.GetFormattedUrl(URL_CLOUD_SCRIPT); var headers = new List <WebRequestHeader> { PlayfabApi.Instance.GetAuthHeader() }; WebRequestHelper.Instance.PostRequest(url, new CloudScriptRequestEntity { FunctionName = CLOUD_SCRIPT_DEMO_METHOD, FunctionParameter = new CloudScriptRequestEntity.CloudScriptArgs { sku = itemId, amount = ITEMS_QUANTITY_FOR_CLOUD_SCRIPT, orderId = orderId, sdkTag = PaymentsHelper.GetAdditionalInformation("playfab"), theme = PaystationThemeHelper.ConvertToSettings(XsollaSettings.PaystationTheme), sandbox = XsollaSettings.IsSandbox } }, headers, (CloudScriptResponseEntity response) => onSuccess?.Invoke(response.data), onError); }
public List <Int32> GetPendingCollections(Int32?lastProcessedCollectionId) { // Set payments helper PaymentsHelper ph = new PaymentsHelper(); ph.AccessToken = this.AccessToken; // Prepare API call arguments List <KeyValuePair <string, string> > args = new List <KeyValuePair <string, string> >(); args.Add(new KeyValuePair <string, string>("sort", "id")); args.Add(new KeyValuePair <string, string>("criteria", "desc")); args.Add(new KeyValuePair <string, string>("offset", "0")); args.Add(new KeyValuePair <string, string>("limit", "5")); // Set environment MercadoPagoSDK.Environment.Scope = _environmentScope; // Call API SearchPage <Collection> searchPage = ph.SearchCollections(args); List <Collection> collections = searchPage.Results; // Populate pending ids List <Int32> pendingIds = new List <int>(); foreach (Collection collection in collections) { if (lastProcessedCollectionId != null) { if (lastProcessedCollectionId == collection.Id) { break; } } pendingIds.Add(collection.Id.Value); } return(pendingIds); }
private void findBookingBtn_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(tPaymentID.Text)) { try { var paymentData = PaymentsHelper.GetById(tPaymentID.Text); if (paymentData != null) { SetTextBoxesToData(paymentData); dataGridView1.DataSource = PaymentsHelper.LoadPaymentsWithId(paymentData.Payments_ID.ToString()); SetTextBoxesToEmpty(); } } catch (Exception) { MessageBox.Show("No record found with this id", "No data Found", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter booking id ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OnActivityResult(int requestCode, Result resultCode, Intent data) { var context = Forms.Context; var activity = (MainActivity)context; activity.ActivityResult -= OnActivityResult; // process result if (resultCode != Result.Ok) { Complete.TrySetResult(true); } // this.Complete.TrySetResult(false); else { var result = data.GetParcelableExtra(DropInResult.ExtraDropInResult) as DropInResult; if (bookingId != null) { var res = new PaymentsHelper().PayForBooking(result.PaymentMethodNonce.Nonce, bookingId.Value); if (res.Status == System.Net.HttpStatusCode.OK) { Complete.TrySetResult(true); } else { Complete.TrySetResult(false); } } else { new PaymentsHelper().InitPayments(result.PaymentMethodNonce.Nonce); } // this.Complete.TrySetResult(true); } }
public IActionResult PurchaseCredits([FromBody] CreditPurchaseDto purchaseDetails) { using (var db = new db()) { var constants = new ServiceConstants(); var payments = (from payment in db.payments where payment.UserId == purchaseDetails.UserID select payment).ToList(); if (payments == null) { return(NotFound("You have no enough topup to fund this purchase")); } PaymentsHelper helper = new PaymentsHelper(payments); if (helper.CanPurchaseNameSearch(purchaseDetails.NumberOfCredits)) { Payment payment = new Payment(); payment.UserId = purchaseDetails.UserID; payment.PaymentId = Guid.NewGuid().ToString(); payment.Date = DateTime.Now.ToString(); payment.Description = purchaseDetails.Service + " Credit Purchase"; if (purchaseDetails.Service.Equals(constants.NAMESEARCH)) { payment.AmountDr = helper.getTotalNameSearchPrice(purchaseDetails.NumberOfCredits); } if (purchaseDetails.Service.Equals(constants.PVTLIMITEDENTITY)) { payment.AmountDr = helper.getTotalPvtPrice(purchaseDetails.NumberOfCredits); } List <Credit> credits = new List <Credit>(); if (db.Insert(payment) == 1) { for (var i = 0; i < purchaseDetails.NumberOfCredits; i++) { Credit credit = new Credit(); credit.UserId = purchaseDetails.UserID; credit.CreditId = Guid.NewGuid().ToString(); credit.PaymentId = payment.PaymentId; credit.Service = purchaseDetails.Service; DateTime expDate = DateTime.Now.AddDays(30); credit.ExpiryDate = expDate.ToString(); if (db.Insert(credit) == 1) { credits.Add(credit); continue; } else { return(BadRequest(payment)); } } payments.Add(payment); CreditPurchaseResponseDto response = new CreditPurchaseResponseDto(); response.payment = payment; response.credits = credits; return(Ok(response)); } } } return(BadRequest("You have no enough topup to fund this purchase")); }
public _Default() { _paymentsHelper = new PaymentsHelper(ConfigurationManager.ConnectionStrings["carcadeConnectionString"]?.ConnectionString); }
protected void Page_Load(object sender, EventArgs e) { // Get collection id Int32 id = Convert.ToInt32(Request["id"]); if (id != 0) { try { // Create Payments helper PaymentsHelper ph = new PaymentsHelper(); // Create a token for the API's calls // Remember 1st! // Change the property settings (Settings.settings) for the following variables: // Your ClientId, Your ClientSecret Token token = AuthHelper.CreateAccessToken(Properties.Settings.Default.ClientId, Properties.Settings.Default.ClientSecret); ph.AccessToken = token.AccessToken; // Get Collection Notification CollectionNotification cn = ph.GetCollectionNotification(id); // Here goes your code: do something with the notification! // Remember: IPN system waits for your reply about 500ms. If this method times out that threshold it will retry the // notification again. So prepare your code to be fast enough and/or to support retries (eg., ask if the collection was // already processed!). // This example just shows collection's attribute values Label1.Text = "<b>currency id:</b> " + cn.Collection.CurrencyId + "<br/>"; Label1.Text = Label1.Text + "<b>collector id:</b> " + cn.Collection.Collector.Id.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>collector first name:</b> " + cn.Collection.Collector.FirstName + "<br/>"; Label1.Text = Label1.Text + "<b>collector last name:</b> " + cn.Collection.Collector.LastName + "<br/>"; Label1.Text = Label1.Text + "<b>collector nickname:</b> " + cn.Collection.Collector.Nickname + "<br/>"; Label1.Text = Label1.Text + "<b>collector email:</b> " + cn.Collection.Collector.Email + "<br/>"; Label1.Text = Label1.Text + "<b>collector phone areacode:</b> " + cn.Collection.Collector.Phone.AreaCode + "<br/>"; Label1.Text = Label1.Text + "<b>collector phone number:</b> " + cn.Collection.Collector.Phone.Number + "<br/>"; Label1.Text = Label1.Text + "<b>collector phone extension:</b> " + cn.Collection.Collector.Phone.Extension + "<br/>"; Label1.Text = Label1.Text + "<b>date approved:</b> " + cn.Collection.DateApproved.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>date created:</b> " + cn.Collection.DateCreated.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>external reference:</b> " + cn.Collection.ExternalReference + "<br/>"; Label1.Text = Label1.Text + "<b>finance charge:</b> " + cn.Collection.FinanceCharge.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>id:</b> " + cn.Collection.Id.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>installments:</b> " + cn.Collection.Installments.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>last modified:</b> " + cn.Collection.LastModified.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>marketplace:</b> " + cn.Collection.Marketplace.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>mercadopago fee:</b> " + cn.Collection.MercadoPagoFee.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>money release date:</b> " + cn.Collection.MoneyReleaseDate.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>net received amount:</b> " + cn.Collection.NetReceivedAmount.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>operation type:</b> " + cn.Collection.OperationType + "<br/>"; Label1.Text = Label1.Text + "<b>order id:</b> " + cn.Collection.OrderId + "<br/>"; Label1.Text = Label1.Text + "<b>payer id:</b> " + cn.Collection.Payer.Id.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>payer first name:</b> " + cn.Collection.Payer.FirstName + "<br/>"; Label1.Text = Label1.Text + "<b>payer last name:</b> " + cn.Collection.Payer.LastName + "<br/>"; Label1.Text = Label1.Text + "<b>payer nickname:</b> " + cn.Collection.Payer.Nickname + "<br/>"; Label1.Text = Label1.Text + "<b>payer email:</b> " + cn.Collection.Payer.Email + "<br/>"; Label1.Text = Label1.Text + "<b>payer phone areacode:</b> " + cn.Collection.Payer.Phone.AreaCode + "<br/>"; Label1.Text = Label1.Text + "<b>payer phone number:</b> " + cn.Collection.Payer.Phone.Number + "<br/>"; Label1.Text = Label1.Text + "<b>payer phone extension:</b> " + cn.Collection.Payer.Phone.Extension + "<br/>"; Label1.Text = Label1.Text + "<b>payment type:</b> " + cn.Collection.PaymentType + "<br/>"; Label1.Text = Label1.Text + "<b>reason:</b> " + cn.Collection.Reason + "<br/>"; Label1.Text = Label1.Text + "<b>released:</b> " + cn.Collection.Released.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>shipping cost:</b> " + cn.Collection.ShippingCost.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>site id:</b> " + cn.Collection.SiteId + "<br/>"; Label1.Text = Label1.Text + "<b>status:</b> " + cn.Collection.Status + "<br/>"; Label1.Text = Label1.Text + "<b>status detail:</b> " + cn.Collection.StatusDetail + "<br/>"; Label1.Text = Label1.Text + "<b>total paid amount:</b> " + cn.Collection.TotalPaidAmount.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>transaction amount:</b> " + cn.Collection.TransactionAmount.ToString() + "<br/>"; Label1.Text = Label1.Text + "<b>json:</b> " + cn.ToJSON().ToString(); } catch (Exception ex) { throw ex; } } }
private void LoadAllButton_Click(object sender, EventArgs e) { dataGridView1.DataSource = PaymentsHelper.LoadPaymentsData(); }
public PaymentsController() { helper = new PaymentsHelper(); logger = log4net.LogManager.GetLogger(typeof(PaymentsController)); }