/** * */ public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq BMCreateButtonReq, string apiUsername) { setStandardParams(BMCreateButtonReq.BMCreateButtonRequest); string resp = call("BMCreateButton", BMCreateButtonReq.toXMLString(), apiUsername); return(new BMCreateButtonResponseType(resp)); }
/** * AUTO_GENERATED */ public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq bMCreateButtonReq, string apiUserName) { setStandardParams(bMCreateButtonReq.BMCreateButtonRequest); string response = Call("BMCreateButton", bMCreateButtonReq.ToXMLString(), apiUserName); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(response); XmlNode xmlNode = xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='BMCreateButtonResponse']"); return(new BMCreateButtonResponseType(xmlNode)); }
/// <summary> /// /// </summary> ///<param name="bMCreateButtonReq"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq bMCreateButtonReq, ICredential credential) { setStandardParams(bMCreateButtonReq.BMCreateButtonRequest); DefaultSOAPAPICallHandler defaultHandler = new DefaultSOAPAPICallHandler(this.config, bMCreateButtonReq.ToXMLString(null, "BMCreateButtonReq"), null, null); IAPICallPreHandler apiCallPreHandler = new MerchantAPICallPreHandler(this.config, defaultHandler, credential); ((MerchantAPICallPreHandler)apiCallPreHandler).SDKName = SDKName; ((MerchantAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion; ((MerchantAPICallPreHandler)apiCallPreHandler).PortName = "PayPalAPI"; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(Call(apiCallPreHandler)); return(new BMCreateButtonResponseType( xmlDocument.SelectSingleNode("*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='BMCreateButtonResponse']") )); }
/// <summary> /// /// </summary> ///<param name="bMCreateButtonReq"></param> public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq bMCreateButtonReq) { return(BMCreateButton(bMCreateButtonReq, (string)null)); }
public BMCreateButtonResponseType BMCreateButton(BMCreateButtonReq BMCreateButtonReq) { return(BMCreateButton(BMCreateButtonReq, null)); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BMCreateButtonRequestType request = new BMCreateButtonRequestType(); ButtonTypeType selectedButtonType = (ButtonTypeType) Enum.Parse(typeof(ButtonTypeType), buttonType.SelectedValue); request.ButtonType = selectedButtonType; request.ButtonCode = (ButtonCodeType) Enum.Parse(typeof(ButtonCodeType), buttonCode.SelectedValue); /* Add HTML standard button variables that control what is posted to * PayPal when a user clicks on the created button. Refer the * "HTML Variables for Website Payments Standard" guide for more. */ List <String> buttonVars = new List <String>(); buttonVars.Add("item_name=" + itemName.Value); buttonVars.Add("return=" + returnURL.Value); buttonVars.Add("business=" + businessMail.Value); buttonVars.Add("amount=" + amount.Value); request.ButtonVar = buttonVars; /* Construct rest of the request values according to the buttontype * that the user chose. Consult the ButtonManager documentation * for a complete list of supported arguments for the different * button types */ if (selectedButtonType.Equals(ButtonTypeType.PAYMENTPLAN)) { InstallmentDetailsType insType = new InstallmentDetailsType(); insType.TotalBillingCycles = Int32.Parse(billingCycles.Value); insType.Amount = installmentAmt.Value; insType.BillingFrequency = Int32.Parse(billingFreq.Value); insType.BillingPeriod = (BillingPeriodType) Enum.Parse(typeof(BillingPeriodType), billingPeriod.SelectedValue); List <InstallmentDetailsType> insList = new List <InstallmentDetailsType>(); insList.Add(insType); OptionSelectionDetailsType detailsType = new OptionSelectionDetailsType("CreateButton"); detailsType.OptionType = (OptionTypeListType) Enum.Parse(typeof(OptionTypeListType), optionType.SelectedValue); detailsType.PaymentPeriod = insList; List <OptionSelectionDetailsType> optSelectList = new List <OptionSelectionDetailsType>(); optSelectList.Add(detailsType); OptionDetailsType optType = new OptionDetailsType("CreateButton"); optType.OptionSelectionDetails = optSelectList; List <OptionDetailsType> optList = new List <OptionDetailsType>(); optList.Add(optType); request.OptionDetails = optList; } else if (selectedButtonType.Equals(ButtonTypeType.AUTOBILLING)) { buttonVars.Add("min_amount=" + minAmt.Value); } else if (selectedButtonType.Equals(ButtonTypeType.GIFTCERTIFICATE)) { buttonVars.Add("shopping_url=" + shoppingUrl.Value); } else if (selectedButtonType.Equals(ButtonTypeType.PAYMENT)) { buttonVars.Add("subtotal=" + subTotal.Value); } else if (selectedButtonType.Equals(ButtonTypeType.SUBSCRIBE)) { buttonVars.Add("a3=" + subAmt.Value); buttonVars.Add("p3=" + subPeriod.Value); buttonVars.Add("t3=" + subInterval.SelectedValue); } // Invoke the API BMCreateButtonReq wrapper = new BMCreateButtonReq(); wrapper.BMCreateButtonRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); BMCreateButtonResponseType response = service.BMCreateButton(wrapper); // Check for API return status setKeyResponseObjects(service, response); }
public async Task <IHttpActionResult> Post(ProcessData processData) { Data data = new Data(processData); HttpResponseMessage resp = await client.PostAsJsonAsync("https://sepruleapi.azurewebsites.net/policy", data); String json = ""; if (resp.IsSuccessStatusCode) { json = await resp.Content.ReadAsStringAsync(); } data = JsonConvert.DeserializeObject <Data>(json); Realizacija_osiguranja ro = dataToRO(processData, data); try { db.Realizacija_osiguranja.Add(ro); db.SaveChanges(); }catch (Exception e) { Console.Write(e); //Mozda ipak u neki log, hm? return(BadRequest()); } #region Debug /* * PDFCreator creator = new PDFCreator(); * * var fullPath = System.Web.HttpContext.Current.Server.MapPath("../fonts/logo.png"); * Document doc = creator.createDocument(ro, fullPath); * PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true); * pdfRenderer.Document = doc; * pdfRenderer.RenderDocument(); * * * MemoryStream ms = new MemoryStream(); * pdfRenderer.Save(ms, false); * ms.Position = 0; * * * NetworkCredential basicCredential = new NetworkCredential("*****@*****.**", "hasansakic"); * MailMessage mail = new MailMessage(); * SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); * * mail.From = new MailAddress("*****@*****.**"); * mail.To.Add("*****@*****.**"); * mail.Subject = "Polisa osiguranja - Holiday Guard"; * mail.Body = "Pozdrav, \n šaljemo vam vašu polisu jer ste naznačeni kao nosilac. Za sve informacije možete se obratiti na telefon 021/ 4540 021. \n Svako dobro, \n Vaš Holiday Guard!"; * mail.Attachments.Add(new Attachment(ms, "polisa.pdf", "application/pdf")); * * * SmtpServer.Port = 587; * SmtpServer.Credentials = basicCredential; * SmtpServer.EnableSsl = true; * * * SmtpServer.Send(mail); * * ms.Close(); */ #endregion //Paypal button generation BMCreateButtonRequestType request = new BMCreateButtonRequestType(); request.ButtonType = ButtonTypeType.BUYNOW; request.ButtonCode = ButtonCodeType.ENCRYPTED; String policyId = ro.Id_Realizacija_osiguranja.ToString(); String price = ro.Ukupna_vrednost_Realizacija_osiguranja.ToString(); String converter = "https://globalcurrencies.xignite.com/xGlobalCurrencies.json/ConvertRealTimeValue?From=RSD&To=EUR&Amount=" + price + "&_token=" + key; HttpResponseMessage resp2 = await client.GetAsync(converter); String json2 = ""; if (resp2.IsSuccessStatusCode) { json2 = await resp2.Content.ReadAsStringAsync(); } Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(json2); String priceEur = (String)o["Result"]; int dot = priceEur.IndexOf('.'); if (dot != -1) { priceEur = priceEur.Substring(0, dot + 3); } List <string> buttonVars = new List <string>(); buttonVars.Add("return=" + RETURN_ADDRESS); buttonVars.Add("item_name=" + POLICY_NAME); buttonVars.Add("item_number=" + policyId); buttonVars.Add("amount=" + priceEur); buttonVars.Add("currency_code=" + "EUR");// Ne moze u dinarima. buttonVars.Add("business=" + ACCOUNT_EMAIL); request.ButtonVar = buttonVars; // Invoke the API BMCreateButtonReq wrapper = new BMCreateButtonReq(); wrapper.BMCreateButtonRequest = request; Dictionary <string, string> configurationMap = SEP_Osiguranje.PayPalData.PayPalConfiguration.GetAcctAndConfig(); PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); BMCreateButtonResponseType response = service.BMCreateButton(wrapper); DataForPreview dfp = new DataForPreview(ro, response.Website); return(Ok(dfp)); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object BMCreateButtonRequestType request = new BMCreateButtonRequestType(); // (Required) The kind of button you want to create. It is one of the following values: // BUYNOW - Buy Now button // CART - Add to Cart button // GIFTCERTIFICATE - Gift Certificate button // SUBSCRIBE - Subscribe button // DONATE - Donate button // UNSUBSCRIBE - Unsubscribe button // VIEWCART - View Cart button // PAYMENTPLAN - Installment Plan button; since version 63.0 // AUTOBILLING - Automatic Billing button; since version 63.0 // PAYMENT - Pay Now button; since version 65.1 // Note: Do not specify BUYNOW if BUTTONCODE=TOKEN; specify PAYMENT instead. // Do not specify PAYMENT if BUTTONCODE=HOSTED. ButtonTypeType selectedButtonType = (ButtonTypeType) Enum.Parse(typeof(ButtonTypeType), buttonType.SelectedValue); request.ButtonType = selectedButtonType; // (Optional) The kind of button code to create. It is one of the following values: // HOSTED - A secure button stored on PayPal; default for all buttons except View Cart, Unsubscribe, and Pay Now // ENCRYPTED - An encrypted button, not stored on PayPal; default for View Cart button // CLEARTEXT - An unencrypted button, not stored on PayPal; default for Unsubscribe button // TOKEN - A secure button, not stored on PayPal, used only to initiate the Hosted Solution checkout flow; // default for Pay Now button. Since version 65.1 request.ButtonCode = (ButtonCodeType) Enum.Parse(typeof(ButtonCodeType), buttonCode.SelectedValue); /* Add HTML standard button variables that control what is posted to * PayPal when a user clicks on the created button. Refer the * "HTML Variables for Website Payments Standard" guide for more. */ List <string> buttonVars = new List <string>(); buttonVars.Add("item_name=" + itemName.Value); buttonVars.Add("return=" + returnURL.Value); buttonVars.Add("business=" + businessMail.Value); buttonVars.Add("notify_url=" + notifyURL.Value.Trim()); request.ButtonVar = buttonVars; /* Construct rest of the request values according to the buttontype * that the user chose. Consult the ButtonManager documentation * for a complete list of supported arguments for the different * button types */ if (selectedButtonType.Equals(ButtonTypeType.PAYMENTPLAN)) { InstallmentDetailsType insType = new InstallmentDetailsType(); // (Optional) The total number of billing cycles, // regardless of the duration of a cycle; 1 is the default insType.TotalBillingCycles = Convert.ToInt32(billingCycles.Value); // (Optional) The base amount to bill for the cycle. insType.Amount = installmentAmt.Value; // (Optional) The installment cycle frequency in units, e.g. // if the billing frequency is 2 and the billing period is Month, // the billing cycle is every 2 months. The default billing frequency is 1. insType.BillingFrequency = Convert.ToInt32(billingFreq.Value); //(Optional) The installment cycle unit, which is one of the following values: // NoBillingPeriodType - None (default) // Day // Week // SemiMonth // Month // Year insType.BillingPeriod = (BillingPeriodType) Enum.Parse(typeof(BillingPeriodType), billingPeriod.SelectedValue); List <InstallmentDetailsType> insList = new List <InstallmentDetailsType>(); insList.Add(insType); OptionSelectionDetailsType detailsType = new OptionSelectionDetailsType("CreateButton"); // (Optional) The installment option type for an OPTIONnNAME, // which is one of the following values: // FULL - Payment in full // VARIABLE - Variable installments // EMI - Equal installments detailsType.OptionType = (OptionTypeListType) Enum.Parse(typeof(OptionTypeListType), optionType.SelectedValue); // (Optional) Information about an installment option detailsType.PaymentPeriod = insList; List <OptionSelectionDetailsType> optSelectList = new List <OptionSelectionDetailsType>(); optSelectList.Add(detailsType); OptionDetailsType optType = new OptionDetailsType("CreateButton"); optType.OptionSelectionDetails = optSelectList; List <OptionDetailsType> optList = new List <OptionDetailsType>(); optList.Add(optType); request.OptionDetails = optList; } else if (selectedButtonType.Equals(ButtonTypeType.AUTOBILLING)) { // (Optional) HTML standard button variables buttonVars.Add("min_amount=" + minAmt.Value); } else if (selectedButtonType.Equals(ButtonTypeType.GIFTCERTIFICATE)) { // (Optional) HTML standard button variables buttonVars.Add("shopping_url=" + shoppingUrl.Value); } else if (selectedButtonType.Equals(ButtonTypeType.PAYMENT)) { // (Optional) HTML standard button variables buttonVars.Add("subtotal=" + subTotal.Value); } else if (selectedButtonType.Equals(ButtonTypeType.SUBSCRIBE)) { // (Optional) HTML standard button variables buttonVars.Add("a3=" + subAmt.Value); buttonVars.Add("p3=" + subPeriod.Value); buttonVars.Add("t3=" + subInterval.SelectedValue); } // Invoke the API BMCreateButtonReq wrapper = new BMCreateButtonReq(); wrapper.BMCreateButtonRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // (https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters) Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Creating service wrapper object to make an API call by loading configuration map. PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); BMCreateButtonResponseType response = service.BMCreateButton(wrapper); // Check for API return status setKeyResponseObjects(service, response); }