How can we return amount in same website by using Paypal Payflow pro account - asp.net

How can we return deduct amount in same website by using Paypal Payflow pro account?
I am using Paypal Payflow pro account for one of my application. It does transaction but doesn't return deduct amount detail. I am using first time Paypal Payflow account. So if anybody have done such kind of work before kindly share with me.

Hi i have done this, Anybody who needs solution see below:
protected NameValueCollection httpRequestVariables()
{
var post = Request.Form; // $_POST
var get = Request.QueryString; // $_GET
return Merge(post, get);
}
if (!IsPostBack)
{
string output = "";
if (httpRequestVariables()["RESULT"] != null)
{
HttpContext.Current.Session["payflowresponse"] = httpRequestVariables();
output += "<script type=\"text/javascript\">window.top.location.href = \"" + url + "\";</script>";
BodyContentDiv.InnerHtml = output;
return;
}
var payflowresponse = HttpContext.Current.Session["payflowresponse"] as NameValueCollection;
if (payflowresponse != null)
{
HttpContext.Current.Session["payflowresponse"] = null;
bool success = payflowresponse["RESULT"] == "0";
if (success)
{
output += "<span style='font-family:sans-serif;font-weight:bold;'>Transaction approved! Thank you for your order.</span>";
}
else
{
output += "<span style='font-family:sans-serif;'>Transaction failed! Please try again with another payment method.</span>";
}
output += "<p>(server response follows)</p>\n";
output += print_r(payflowresponse);
AdvancedDemoContent.InnerHtml = output;
public string print_r(Object obj)
{
string output = "<pre>\n";
if (obj is NameValueCollection)
{
NameValueCollection nvc = obj as NameValueCollection;
output += "RESULT" + "=" + nvc["RESULT"] + "\n";
output += "PNREF" + "=" + nvc["PNREF"] + "\n";
output += "RESPMSG" + "=" + nvc["RESPMSG"] + "\n";
output += "AUTHCODE" + "=" + nvc["AUTHCODE"] + "\n";
output += "CVV2MATCH" + "=" + nvc["CVV2MATCH"] + "\n";
output += "AMT" + "=" + nvc["AMT"] + "\n";
}
else
{
output += "UNKNOWN TYPE";
}
output += "</pre>";
return output;
}

go to your PayPal merchant account-->profile-->Selling Preferences-->Website Payment Preferences-->Auto Return for Website Payments turn radio button to on,default it should off.after transaction make sure the value are stored in your database.i hope this help you

Related

How to add file attachment to Email message sent from Razor page (with ASP.NET Core and MailKit)

The following is a method for sending an Email from a Razor page in ASP.NET Core. I need to use MailKit since System.Net.Mail is not available in ASP.NET Core.
Despite much research, I haven't been able to figure out a way to include the image to the Email. Note that it doesn't have to be an attachment - embedding the image will work.
public ActionResult Contribute([Bind("SubmitterScope, SubmitterLocation, SubmitterItem, SubmitterCategory, SubmitterEmail, SubmitterAcceptsTerms, SubmitterPicture")]
EmailFormModel model)
{
if (ModelState.IsValid)
{
try
{
var emailName= _appSettings.EmailName;
var emailAddress = _appSettings.EmailAddress;
var emailPassword = _appSettings.EmailPassword;
var message = new MimeMessage();
message.From.Add(new MailboxAddress(emailName, emailAddress));
message.To.Add(new MailboxAddress(emailName, emailAddress));
message.Subject = "Record Submission From: " + model.SubmitterEmail.ToString();
message.Body = new TextPart("plain")
{
Text = "Scope: " + model.SubmitterScope.ToString() + "\n" +
"Zip Code: " + model.SubmitterLocation.ToString() + "\n" +
"Item Description: " + model.SubmitterItem.ToString() + "\n" +
"Category: " + model.SubmitterCategory + "\n" +
"Submitted By: " + model.SubmitterEmail + "\n" +
// This is the file that should be attached.
//"Picture: " + model.SubmitterPicture + "\n" +
"Terms Accepted: " + model.SubmitterAcceptsTerms + "\n"
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587);
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
// Note: only needed if the SMTP server requires authentication
client.Authenticate(emailAddress, emailPassword);
client.Send(message);
client.Disconnect(true);
return RedirectToAction("Success");
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message + ": " + ex.StackTrace);
return RedirectToAction("Failure");
}
}
else
{
return View();
}
}
This is from the FAQ on Mailkit github repo, and seems to cover the full process.
https://github.com/jstedfast/MailKit/blob/master/FAQ.md#CreateAttachments
var message = new MimeMessage ();
message.From.Add (new MailboxAddress ("Joey", "joey#friends.com"));
message.To.Add (new MailboxAddress ("Alice", "alice#wonderland.com"));
message.Subject = "How you doin?";
// create our message text, just like before (except don't set it as the message.Body)
var body = new TextPart ("plain") {
Text = #"Hey Alice,
What are you up to this weekend? Monica is throwing one of her parties on
Saturday and I was hoping you could make it.
Will you be my +1?
-- Joey
"
};
// create an image attachment for the file located at path
var attachment = new MimePart ("image", "gif") {
ContentObject = new ContentObject (File.OpenRead (path), ContentEncoding.Default),
ContentDisposition = new ContentDisposition (ContentDisposition.Attachment),
ContentTransferEncoding = ContentEncoding.Base64,
FileName = Path.GetFileName (path)
};
// now create the multipart/mixed container to hold the message text and the
// image attachment
var multipart = new Multipart ("mixed");
multipart.Add (body);
multipart.Add (attachment);
// now set the multipart/mixed as the message body
message.Body = multipart;

MeteorJS allow injection of anchor tag

I have a basic chat that reads from a database. Each chat message is read from the database by this.
<span>{{formatChat text}}</span>
text being the message read.
And then I use the formatChat registerHelper to detect URLs.
Template.registerHelper('formatChat', function(text) {
var urlRegex = /https?:\/\/([a-zA-Z0-9\-\.]+)(\.[a-zA-Z0-9]+)((([a-zA-Z0-9\?\=\/])+)?((\#|\?)(.+)?)?)?$/
var urlRegexMini = /(www(\d{0,3})\.)?([a-zA-Z0-9\-\.]+)(\.(com|net|org|gov|co\.uk|edu|io\b)+)([a-zA-Z0-9\?\=\/]+((([a-zA-Z0-9\?\=\/])+)?((\#|\?)(.+)?)?)?)?$/
finalString = "";
//Parse every word individually
split = text.split(' ');
for (i = 0; i < split.length; i++) {
finalString += " ";
if (urlRegex.test(split[i])) {
finalString += "<a href='" + split[i] + "'>" + split[i] + "</a>";
}
else if (urlRegexMini.test(split[i])) {
finalString += "<a href='http://" + split[i] + "'>" + split[i] + "</a>";
}else{
finalString += split[i];
}
}
return finalString.substring(1,finalString.length);
});
The problem is that meteor doesn't allow injection, so it will literally show the anchor tag as plain text.
One solution that I thought of was to have a registerHelper for each individual word, but that seems rather foolish.
How can I efficiently get around this rule?
I believe this should do it:
{{{formatChat text}}}

Modifying Netsuite Object on loading

I am very new to Netsuite. I am trying to do encryption in Netsuite. It works when I add UserEvent Scripts beforeSubmit. But I wanted to decrypt the encrypted text in beforeLoad function. I am able to read the encrypted text and decrypt it successfully as well. But setting it back in the object fails and I see decrypted text in Netsuite UI. Any directions or help is appreciated.
thanks
// this function works
function beforeSubmit(type) {
var email = nlapiGetFieldValue('email');
var newEmail = 'LifeSpan.' + email;
nlapiSetFieldValue('email', newEmail );
nlapiLogExecution('DEBUG', 'Modified before Submit ' + email + ' to ' + newEmail);
}
// this printed "Modified before Submit customercare#abc.com to LifeSpan.customercare#abc.com"
// this function doesn't work; even though the correct value is printed correctly in the log
function beforeLoad(type, form, request) {
var email = nlapiGetFieldValue('email');
if(email.indexOf('SaaSSpan.') != -1) {
var newEmail = email.substring(9);
nlapiSetFieldValue('email', newEmail );
nlapiLogExecution('DEBUG', 'Modified before load ' + email + ' to ' + newEmail);
}
}
// this printed "Modified before load LifeSpan.customercare#abc.com to customercare#abc.com"...but I am still seeing LifeSpan.customercare#abc.com in the user interface
I will suggest you to try this code in a client script(PageInit and SaveRecord Events).
Works fine for me.
My Code :
function PageInit(type) {
try {
if (type == 'edit') {
var email = nlapiGetFieldValue('email');
if (email != null && email.indexOf('LifeSpan.') != -1) {
var newEmail = email.substring(9);
nlapiSetFieldValue('email', newEmail);
nlapiLogExecution('DEBUG', 'Modified before load ' + email + ' to ' + newEmail);
}
}
}
catch (err) {
nlapiLogExecution('ERROR', 'PageInit', err);
}}
function SaveRecord() {
try {
var email = nlapiGetFieldValue('email');
var newEmail = 'LifeSpan.' + email;
nlapiSetFieldValue('email', newEmail);
nlapiLogExecution('DEBUG', 'Modified before Submit ' + email + ' to ' + newEmail);
}
catch (err) {
nlapiLogExecution('ERROR', 'SaveRecord', err);
}
return true;}
nlapiSetFieldValue can be used in user event beforeLoad scripts to initialize field on new records or non-stored fields.

Regarding message send in singnal R

Hello friends I have developed many to many chat application using signal R it is working perfectly fine.But i am getting one problem in developing one thing..that is typing message to the reciever for example:- there are two user online user x and user y.now when user x is typing message..on user y window it should come.."user x is typing message.." but when i send this message to group it is getting displayed on both screen..I want to display it on reciever screen only
This is the code
public void Send(string message, string groupName, string Istypingmessage)
{
if (Clients != null)
{
string[] words = message.Split(':');
string trim = words[0].Trim();
string imagetag = "<img width=\"32px\" height=\"32px\" src=\"userimages/" + trim + ".jpg" + "\"" + "></img> ";
Clients.Group(groupName).addMessage(message, groupName, words[0], imagetag, Istypingmessage);
}
}
where here typing message=0 means normal message and 1 means "user x is typing that message"
This is the key press event
//keypress event of textbbox here..
$(".ChatText").live('keyup', function () {
if($(".ChatText").val().length > 0)
{
var messsage_typing=$("#hdnUserName").val() + " is typing...";
var strGroupName = $(this).parent().attr('groupname');
if (typeof strGroupName !== 'undefined' && strGroupName !== false)
chat.server.send($("#hdnUserName").val() + ' : ' + messsage_typing, $(this).parent().attr('groupname'),"1");
}
});
//end of keypress
and this is add message code
chat.client.addMessage = function (message, groupName,recievername,imagetag,Istypingmessage) {
if ($('div[groupname=' + groupName + ']').length == 0) {
var chatWindow = $("#divChatWindow").clone(true);
$(chatWindow).css('display', 'block');
$(chatWindow).attr('groupname', groupName);
$("#chatContainer").append(chatWindow);
//buggy code do not delete..
//remove all previous li
$('div[groupname=' + groupName + ']').find('ul li').remove();
//replace header tag with new name
$('div[groupname=' + groupName + ']').find('a').html(recievername);
$("#chatContainer").draggable();
$("#chatContainer").css('cursor','move');
}
if(Istypingmessage=="0")
{
var stringParts = message.split(":");
var username = stringParts[0];
var message = stringParts[1];
//this code is for continous message sent
var lastliusername=$('div[groupname=' + groupName + '] ul li').eq(-2).find('div.designnone').html();
if(lastliusername!=null && $.trim(username)==$.trim(lastliusername))
{
$('div[groupname=' + groupName + '] ul li').eq(-2).find('div.designmessage').append("<span class='spansameuser'>" + message + "</span>");
//end of this code is for continous message sent
}
else
{
$('div[groupname=' + groupName + ']').find('ul').append("<li><div class='design'>" + imagetag + "</div><div class='designnone'> " + username + "</div><div class='designmessage'> " + message + " </div></li><li class='cleardivbetweenmsg'></li>");
}
}
else
{
$('div[groupname=' + groupName + ']').find('ul').append("<li><span>Hellos</span></li>");
}
$("#messages").scrollTop($("#messages")[0].scrollHeight);
};
How can i display typing message to my reciever instead of on both screens..please help me out..In short i want to send my message only to reciever of group not to sender of the group
Thanks
If you want to send a message to all clients in a group except for the sender, you can use Clients.OthersInGroup:
Clients.OthersInGroup(groupName).addMessage(/*...*/);
This is the equivalent to passing the sender's connection ID as a second parameter to Clients.Group making it an excluded connection ID.
Clients.Group(groupName, Context.ConnectionId).addMessage(/*...*/);
The method signature for Clients.Group is: public dynamic Group(string groupName, params string[] excludeConnectionIds).

What is the best way to accept a credit card in ASP.NET? (Between ASP.NET and Authorize.NET)

I'm new to creating commerce websites, and now that I need to sell software over the internet, I'm not sure where to start.
I'm using ASP.NET and am considering using Authorize.NET to validate and process the credit cards.
I'm looking for a stable, trusted solution that I can install on a single server. My secondary goal (besides selling products online) is to become familiar with shopping cart software that is popular, and in use by large businesses. Perhaps I should start with MS Commerce server?
There are a million options here, but if you are writing the code, the easiest way code-wise is to use http://sharpauthorize.com/
Authorize.Net is Very easy to implement with ASP.NET
Basically you can make transaction in 3-4 ways:
Simple Checkout Through Button like Paypal (http://developer.authorize.net/api/simplecheckout/)
Direct Post : Suppose you little bit more customization than Simple CheckOut. Create a checkout form that posts directly to Authorize.Net http://developer.authorize.net/api/simplecheckout/
Eg:
<h1><%=ViewData["message"] %></h1>
<%using (Html.BeginSIMForm("http://YOUR_SERVER.com/home/sim",
1.99M,"YOUR_API_LOGIN","YOUR_TRANSACTION_KEY",true)){%>
<%=Html.CheckoutFormInputs(true)%>
<%=Html.Hidden("order_id","1234") %>
<input type = "submit" value = "Pay" />
<%}%>
SIM (Server Integration)
AIM (Advance Integration Method): Give full control & customization.
CIM ( store Customer card no & info on Auth.NET server with tokanization)
*Below is a sample of CIM function to make a transaction, AIM is very much similar to CIM only difference is tokanization *
using ProjName.AuthApiSoap; // USE AUth Webserice Reference
public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
{
CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
auth_capture.customerProfileId = profile_id;
auth_capture.customerPaymentProfileId = payment_profile_id;
auth_capture.amount = amt;//1.00m;
auth_capture.order = new CustomerProfileWS.OrderExType();
POSLib.POSManager objManager = new POSLib.POSManager();
auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
DateTime now = DateTime.Now;
auth_capture.order.description = "Service " + DDD;
CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
trans.Item = auth_capture;
CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);
string AuthTranMsg = "";
string AuthTranCode = "";
for (int i = 0; i < response.messages.Length; i++)
{
AuthTranMsg = response.messages[i].text; // To Get Message n for loop to check the [i] is not empty
}
for (int i = 0; i < response.messages.Length; i++)
{
AuthTranCode = response.messages[i].code; // To Get Code n for loop to check the [i] is not empty
}
var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
return tCompResp;
}
This is how to split the Reponse Msg (Format and Order will be FIXED for all transaction/ on web service responsed )
var tResp = objManager.CreateTransaction(profID, paymProfID, Convert.ToDecimal(PmtToday), DDD);
string respCCNo = "";
string RespCCType = "";
string InvoiceNo = "";
string transType = "";
string approvalCode = "";
string AmtRequested = "";
string respName = "";
string respReasonText = "";
string respMD5Hash = "";
string respEmailId = "";
string respReasonCode = "";
string respMethod = "";
string respAVSResultCode = "";
string responseCode = "";
string transactionId = "0";
if (!string.IsNullOrEmpty(tCompResp.Item3))
{
string[] arrRespParts = tCompResp.Item3.Replace("|", "").Split(',');
responseCode = arrRespParts[0];
respReasonCode = arrRespParts[2];
respReasonText = arrRespParts[3];
approvalCode = arrRespParts[4];
respAVSResultCode = arrRespParts[5];
transactionId = arrRespParts[6].Replace("|", "");
InvoiceNo = arrRespParts[7];
AmtRequested = arrRespParts[9];
transType = arrRespParts[10];
respMethod = arrRespParts[11];
respName = arrRespParts[13] + " " + arrRespParts[14];
respEmailId = arrRespParts[23];
respMD5Hash = arrRespParts[37];
respCCNo = arrRespParts[50];
RespCCType = arrRespParts[51];
}
==================================AIM Code
public Tuple<string, string, string> ECheckCreateTransAIM(string amount, string bankRoutingNo, string bankAccNo, string bankAccType, string bankName, string bankAccName, string echeckType, bool isCustomerEmail, string customerEmail, string mechantEMail)
{
//CustomValidator1.ErrorMessage = "";
string AuthNetVersion = "3.1"; // Contains CCV support
WebClient webClientRequest = new WebClient();
System.Collections.Specialized.NameValueCollection InputObject = new System.Collections.Specialized.NameValueCollection(30);
System.Collections.Specialized.NameValueCollection ReturnObject = new System.Collections.Specialized.NameValueCollection(30);
byte[] ReturnBytes;
string[] ReturnValues;
string ErrorString;
InputObject.Add("x_version", AuthNetVersion);
InputObject.Add("x_delim_data", "True");
InputObject.Add("x_login", MERCHANT_NAME);
InputObject.Add("x_tran_key", TRANSACTION_KEY);
InputObject.Add("x_relay_response", "False");
//----------------------Set to False to go Live--------------------
InputObject.Add("x_test_request", "False");
//---------------------------------------------------------------------
InputObject.Add("x_delim_char", ",");
InputObject.Add("x_encap_char", "|");
if (isCustomerEmail)
{
InputObject.Add("x_email", customerEmail);
InputObject.Add("x_email_customer", "TRUE"); //Emails Customer
}
InputObject.Add("x_merchant_email", mechantEMail);
// FOR echeck
InputObject.Add("x_bank_aba_code", bankRoutingNo);
InputObject.Add("x_bank_acct_num", bankAccNo);
InputObject.Add("x_bank_acct_type", bankAccType);
InputObject.Add("x_bank_name", bankName);
InputObject.Add("x_bank_acct_name", bankAccName);
InputObject.Add("x_method", "ECHECK");
InputObject.Add("x_type", "AUTH_CAPTURE");
InputObject.Add("x_amount", string.Format("{0:c2}", Convert.ToDouble(amount)));
// Currency setting. Check the guide for other supported currencies
//needto change it to Actual Server URL
//Set above Testmode=off to go live
webClientRequest.BaseAddress = eCheckBaseAddress; //"https://apitest.authorize.net/soap/v1/Service.asmx"; //"https://secure.authorize.net/gateway/transact.dll";
ReturnBytes = webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject);
ReturnValues = System.Text.Encoding.ASCII.GetString(ReturnBytes).Split(",".ToCharArray());
if (ReturnValues[0].Trim(char.Parse("|")) == "1") // Succesful Transaction
{
//AuthNetCodeLabel.Text = ReturnValues[4].Trim(char.Parse("|")); // Returned Authorisation Code
//AuthNetTransIDLabel.Text = ReturnValues[6].Trim(char.Parse("|")); // Returned Transaction ID
var tCompResp = new Tuple<string, string, string>("I00001", ReturnValues[3].Trim(char.Parse("|")), string.Join(",", ReturnValues));
return tCompResp;
}
else
{
// Error!
ErrorString = ReturnValues[3].Trim(char.Parse("|")) + " (" + ReturnValues[2].Trim(char.Parse("|")) + ")";
if (ReturnValues[2].Trim(char.Parse("|")) == "45")
{
if (ErrorString.Length > 1)
ErrorString += "<br />n";
// AVS transaction decline
ErrorString += "Address Verification System (AVS) " +
"returned the following error: ";
switch (ReturnValues[5].Trim(char.Parse("|")))
{
case "A":
ErrorString += " the zip code entered does not match the billing address.";
break;
case "B":
ErrorString += " no information was provided for the AVS check.";
break;
case "E":
ErrorString += " a general error occurred in the AVS system.";
break;
case "G":
ErrorString += " the credit card was issued by a non-US bank.";
break;
case "N":
ErrorString += " neither the entered street address nor zip code matches the billing address.";
break;
case "P":
ErrorString += " AVS is not applicable for this transaction.";
break;
case "R":
ErrorString += " please retry the transaction; the AVS system was unavailable or timed out.";
break;
case "S":
ErrorString += " the AVS service is not supported by your credit card issuer.";
break;
case "U":
ErrorString += " address information is unavailable for the credit card.";
break;
case "W":
ErrorString += " the 9 digit zip code matches, but the street address does not.";
break;
case "Z":
ErrorString += " the zip code matches, but the address does not.";
break;
}
}
}
var tCompRespFail = new Tuple<string, string, string>(ReturnValues[6].ToString(), ErrorString, string.Join(",", ReturnValues));
return tCompRespFail;
}
CIM CODE (Tokanisation (Card not present method)
public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
{
CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
auth_capture.customerProfileId = profile_id;
auth_capture.customerPaymentProfileId = payment_profile_id;
auth_capture.amount = amt;//1.00m;
auth_capture.order = new CustomerProfileWS.OrderExType();
POSLib.POSManager objManager = new POSLib.POSManager();
auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
DateTime now = DateTime.Now;
auth_capture.order.description = "Service " + DDD;
CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
trans.Item = auth_capture;
CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);
string AuthTranMsg = "";
string AuthTranCode = "";
for (int i = 0; i < response.messages.Length; i++)
{
AuthTranMsg = response.messages[i].text; // To Get Message n for loop to check the [i] is not empty
}
for (int i = 0; i < response.messages.Length; i++)
{
AuthTranCode = response.messages[i].code; // To Get Code n for loop to check the [i] is not empty
}
var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
return tCompResp;
}

Resources