I am trying to integrate Paypal payments in a .NET 4.0 C# WinForm application doing a DirectPayment (without opening the browser with the paypal site) trought an asmx webservices calling this method from a WebMethod
public DoDirectPaymentResponseType DoDirectPaymentAPIOperation(string
amountinUSDollar, string creditCardType, string creditCardNumber, int
exp_month, int exp_year, string firstName, string middleName, string
lastName, string address1, string address2, string city, string state,
string zip, string phoneNumber, string CVV2)
{
DoDirectPaymentResponseType response = new
DoDirectPaymentResponseType();
DoDirectPaymentReq wrapper = new DoDirectPaymentReq();
DoDirectPaymentRequestType request = new DoDirectPaymentRequestType();
DoDirectPaymentRequestDetailsType requestDetails = new
DoDirectPaymentRequestDetailsType();
requestDetails.PaymentAction = (PaymentActionCodeType)
Enum.Parse(typeof(PaymentActionCodeType), "SALE");
CreditCardDetailsType creditCard = new CreditCardDetailsType();
PayerInfoType cardOwner = new PayerInfoType();
PersonNameType payer = new PersonNameType();
payer.FirstName = firstName;
payer.MiddleName = middleName;
payer.LastName = lastName;
cardOwner.PayerName = payer;
creditCard.CardOwner = cardOwner;
creditCard.CreditCardNumber = creditCardNumber;
if (creditCardType == "VISA")
{
creditCard.CreditCardType = CreditCardTypeType.VISA;
}
else if (creditCardType == "MasterCard")
{
creditCard.CreditCardType = CreditCardTypeType.MASTERCARD;
}
creditCard.CVV2 = CVV2;
creditCard.ExpMonth = exp_month;
creditCard.ExpYear = exp_year;
requestDetails.PaymentDetails = new PaymentDetailsType();
requestDetails.PaymentDetails.NotifyURL = "http://IPNhost";
BasicAmountType paymentAmount = new
BasicAmountType(CurrencyCodeType.USD, amountinUSDollar);
requestDetails.PaymentDetails.OrderTotal = paymentAmount;
wrapper.DoDirectPaymentRequest = request;
Dictionary<string, string> config = getConfigDict();
PayPalAPIInterfaceServiceService service = new
PayPalAPIInterfaceServiceService(config);
response = service.DoDirectPayment(wrapper);
}
When it try to make the call to the API, in the last line of the code I get this error:
"Exception in HttpConnection Execute: Invalid HTTP response The request was aborted: Could not create SSL/TLS secure channel."} System.Exception {PayPal.Exception.PayPalException}.
I had a .NET 4.5 WebForm web application with Paypal integrated in which I had to define this
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
in its Global.asax file and it solves the problem for that specific application and I have found I have to use this
ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072;
for .NET 4.0 but my question is:
If this would be the solution to may problem, where should I put this line in my code? Because there is no Global.asax in my asmx webservice.
Outlining the source of the reported issue above as per the comments in the OP. The exception was thrown because the NotifyURL wasn't in https.
Related
I am totally new to SalesForce Marketing cloud.
We have a “Triggered Send” created using “Content Builder” with an email body with HTML attribuites. For eg. %%=v(#EVENT)=%% Invitation
There is a Customer_key for this TriggerSendDefinition
I am using FuelSDK – to TriggerSend this email.
I have NUget Package manager install Fuel SDK in my Visual studio 2019 project.
The App.config has the “clientId” and “clientSecret” values in the FuelSDK config section.
Here is my code below.
public void TestInvitationSend(string CustomerKey)
{
string myName = "John Adams";
string myEvent = "13989";
string fullurl = baseAPIAuthURL + AuthTokenUrl; // Values passed in
NameValueCollection parameters = new NameValueCollection();
parameters.Add("clientId", clientId);
parameters.Add("clientSecret",clientSecret);
parameters.Add("accountId", "account123");
**ETClient myclient = new ETClient(parameters);**
TriggeredSendDefinition definition = new TriggeredSendDefinition();
definition.CustomerKey = customerKey;
//subscriber to whom email is sent
Subscriber subscriber = new Subscriber();
subscriber.EmailAddress = myTest#test.com;
subscriber.SubscriberKey = myTest#test.com;
TriggeredSend triggeredsend = new TriggeredSend();
triggeredsend.TriggeredSendDefinition = definition;
triggeredsend.AuthStub = myclient;
triggeredsend.CustomerKey = customerKey;
triggeredsend.Subscribers = new Subscriber[] { subscriber };
SendReturn results = triggeredsend.Send();
Console.WriteLine("Send Status: " + results.Status.ToString());
}
I am getting a 404 error at the line in “bold” when initializing myClient and unable to pass-in values dynamically. Could not find much documentation for email send through code.
Can you point me to some examples of TriggerSend emails using REST API ?
Thanks
I've having difficulty following this guide
http://dotnetbyexample.blogspot.co.uk/2011/03/sharepoint-client-object-model-sites.html
I've created the helper class as advised:
namespace TestSharepoint
{
public class SharepointHelper
{
private ClientContext clientContext;
private Web rootWeb;
public SharepointHelper(string url, string username, string password)
{
clientContext = new ClientContext(url);
var credentials = new NetworkCredential(username, password, "oshirowanen.com");
clientContext.Credentials = credentials;
rootWeb = clientContext.Web;
clientContext.Load(rootWeb);
}
}
}
However, I do not want to create another site, as I already have a site, so I wanted to test the next part by retrieving the existing sites title:
public Web GetWebByTitle(string siteTitle)
{
var query = clientContext.LoadQuery(
rootWeb.Webs.Where(p => p.Title == siteTitle));
clientContext.ExecuteQuery();
return query.FirstOrDefault();
}
and added this to the form load event:
var sh = new SharepointHelper("https://sharepoint.oshirowanen.com/sites/oshirodev/", "sharepoint_admin_user", "sharepoint_admin_password");
var w = sh.GetWebByTitle("Oshirowanen SharePoint");
Console.WriteLine(w.Title);
What I am getting confused about is, why I am typing in the title of the site which I want to receive the title of??? So I think I am not using this properly?
The error I get is:
An unhandled exception of type 'System.NullReferenceException' occurred in SharePointProgramming.exe
Additional information: Object reference not set to an instance of an object.
Any idea what I am doing wrong?
The username and password I have used has full SharePoint privileges.
I am using Visual Studio 2013, C#, .NET 4.0, and SharePoint 2010.
To fetch the title of the site your just need the value of the variable web.title.
namespace TestSharepoint
{
public class SharepointHelper
{
private ClientContext clientContext;
private Web rootWeb;
public SharepointHelper(string url, string username, string password)
{
clientContext = new ClientContext(url);
var credentials = new NetworkCredential(username, password, "oshirowanen.com");
clientContext.Credentials = credentials;
rootWeb = clientContext.Web;
clientContext.Load(rootWeb,web=>web.title);
clientContent.ExecuteQuery();
string siteTitle=web.title;
}
}
}
I'm trying to send the Unicode value to WCF web service from Android app but I keep getting the string value as ????? in WCF web service. Below are the android code and C# code for web service.
GTPostData gtPostData = new GTPostData(); //DTO Object
Gson gson = new Gson();
String post = "イメージお願いし";
gtPostData.setPortalId(portalId);
gtPostData.setPost(post);
gtPostData.setProjectId(data.getProjectId());
gtPostData.setQuestionId(data.getQuestionId());
gtPostData.setUserId(panelistId);
GTPostDataRequest request = new GTPostDataRequest();
request.setGtPostData(gtPostData);//creating the request object
JSONObject jsonObject = new JSONObject(gson.toJson(request));
String webServiceUrl= ResourcePicker.getServiceURL(session.getPortal(),session.getPortalId(),true);
String addGtPostMethod = ResourcePicker.getString(portal, "add_gt_post");
AsyncPostRequest asyncRequest = new AsyncPostRequest();
asyncRequest.setServiceMethod(addGtPostMethod);
asyncRequest.setServiceUrl(webServiceUrl);
asyncRequest.setPostObject(jsonObject);//set object for post call
SendGtPostAsyncService asyncService = new SendGtPostAsyncService(asyncRequest, context, session, db, data.getPostId());
asyncService.execute();//call the async task
WCF web service call (C#)
public bool AddGTPost(GTPostData GtPostData)
{
bool isAdded = false;
try
{
sci.Debug(frendlyName, screenName, "", "Enter AddGTPost ->> " + GtPostData);//These are trace methods which will print the results in txt file.
sci.Debug(frendlyName, screenName, "", "Enter AddGTPost - Unicode Post ->> " + GtPostData.post);//These are trace methods which will print the results in txt file. Here I'm getting results as "??????"
So please some one help me what is my mistake here?
For your webservice I hope you are not missing UTF-16 format
also in the configuration you are using :
Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);
GlobalizationSection configSection = (GlobalizationSection)config.GetSection("system.web/globalization");
configSection.RequestEncoding = Encoding.Unicode;
configSection.ResponseEncoding = Encoding.Unicode;
Using the IPP.NET SDK v2.0.1, having an issue where simple requests are failing with generic error messages specifically when connecting to a QuickBooks Desktop instance.
Online works fine.
Connection Method:
public QBClient(string appToken, string companyId, string accessToken, string accessTokenSecret, string consumerKey, string consumerSecret, ServiceType qbService)
{
AppToken = appToken;
CompanyID = companyId;
AccessToken = accessToken;
AccessTokenSecret = accessTokenSecret;
ConsumerKey = consumerKey;
ConsumerSecret = consumerSecret;
IntuitServicesType ist = IntuitServicesType.QBO;
if (qbService == ServiceType.QBDesktop)
{
ist = IntuitServicesType.QBD;
}
_oAuthValidator = new OAuthRequestValidator(AccessToken, AccessTokenSecret, ConsumerKey, ConsumerSecret);
_serviceContext = new ServiceContext(AppToken, CompanyID, ist, _oAuthValidator);
string ticket = _serviceContext.Ticket;
this.DataService = new Intuit.Ipp.DataService.DataService(_serviceContext);
}
The connection method above throws no exceptions. However, the following call:
DataService.FindAll<Intuit.Ipp.Data.Customer>(customer, 1, 1000);
produces the following request / response captured in Fiddler:
Request:
URL: POST https://quickbooks.api.intuit.com/v3/company/COMPANY-ID-REMOVED/query
Body: select * from Customer startPosition 1 maxResults 1000
Response:
{"Fault":{"Error":[{"Message":"Operation failed, see details for error","code":"1000"}],"type":"Validation"},"time":"2013-11-16T00:20:30.739Z"}
What should be changed to successfully query QuickBooks Desktop?
V3 QBD can return at max 500 results in a time unlike V3 QBO which can return 1000. Please alter your query. We have an enhancement request up for this.
I have a client who is implementing customer portals in Sharepoint 2013 Online. The current program distributes documents to the customers by mail. Now we have to upload the documents to the customer portal.
I try to use the copy webservice in sharepoint. I created a test project and added the webservice as Web Reference and wrote the following testcode:
static void Main(string[] args)
{
string baseUrl = "https://mycustomer.sharepoint.com/sites/";
string customer = "customerportalname";
string serviceUrl = "/_vti_bin/copy.asmx";
string destinationDirectory = "/folder/";
string fileName = "uploaded.xml";
string username = "username#outlook.com";
string password = "password";
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml("<fiets><onderdeel>voorwiel</onderdeel><onderdeel>achterwiel</onderdeel><onderdeel>trappers</onderdeel><onderdeel>stuur</onderdeel><onderdeel>frame</onderdeel></fiets>");
byte[] xmlByteArray;
using (MemoryStream memoryStream = new MemoryStream())
{
xmlDocument.Save(memoryStream);
xmlByteArray = memoryStream.ToArray();
}
string destinationUrl = string.Format("{0}{1}{2}{3}", baseUrl, customer, destinationDirectory, fileName);
string[] destinationUrlArray = new string[] { destinationUrl };
FieldInformation fieldInfo = new FieldInformation();
FieldInformation[] fields = { fieldInfo };
CopyResult[] resultsArray;
using (Copy copyService = new Copy())
{
copyService.PreAuthenticate = true;
copyService.Credentials = new NetworkCredential(username, password);
copyService.Url = string.Format("{0}{1}", baseUrl, serviceUrl);
copyService.Timeout = 600000;
uint documentId = copyService.CopyIntoItems(destinationUrl , destinationUrlArray, fields, xmlByteArray, out resultsArray);
}
}
When I execute the code I recieve the following error:
The request failed with the error message:
--
<html><head><title>Object moved</title></head><body>
<h2>Object moved to here.</h2>
</body></html>
--
It looks like I'm not authenticated and get redirected. The credentials however are correct.
Does anyone have an idea? Thanks in advance!
UPDATE
To be able to connect to SharePoint 2013 Online you have to attach the Office 365 authentication cookies as explained in this post.
My problem however is that there is also an ADFS involved. How can I autheticate against the ADFS?
This error most probably occurs due to incorrect authentication mode.
Since SharePoint Online (SPO) uses claims-based authentication, NetworkCredential Class can not be utilized for authentication in SPO.
In order to perform the authentication against the ADFS in SPO you could utilize SharePointOnlineCredentials class from SharePoint Online Client Components SDK.
How to authenticate SharePoint Web Services in SharePoint Online (SPO)
The following example demonstrates how to retrieve authentication cookies:
private static CookieContainer GetAuthCookies(Uri webUri, string userName, string password)
{
var securePassword = new SecureString();
foreach (var c in password) { securePassword.AppendChar(c); }
var credentials = new SharePointOnlineCredentials(userName, securePassword);
var authCookie = credentials.GetAuthenticationCookie(webUri);
var cookieContainer = new CookieContainer();
cookieContainer.SetCookies(webUri, authCookie);
return cookieContainer;
}
Example
string sourceUrl = "https://contoso.sharepoint.com/Documents/SharePoint User Guide.docx";
string destinationUrl = "https://contoso.sharepoint.com/Documents/SharePoint User Guide 2013.docx";
FieldInformation[] fieldInfos;
CopyResult[] result;
byte[] fileContent;
using(var proxyCopy = new Copy())
{
proxyCopy.Url = webUri + "/_vti_bin/Copy.asmx";
proxyCopy.CookieContainer = GetAuthCookies(webUri, userName, password);
proxyCopy.GetItem(sourceUrl,out fieldInfos,out fileContent);
proxyCopy.CopyIntoItems(sourceUrl,new []{ destinationUrl}, fieldInfos, fileContent, out result);
}
References
Remote Authentication in SharePoint Online Using Claims-Based
Authentication
SharePoint Online Client Components SDK
In my case (on premise) i have that error. when i changed at iis SharePoint authentication for web application , and disable "Forms Authentication". Now, i can´t enter to SharePoint by UI, but the Web Service works... So I have revert and I have been looking and...
[Paul stork] The Web Application for this site is running in Classic Mode rather than Claims mode. This can happen if you create the web app using Powershell or upgrade from 2010. You can use PowerShell to change it.
http://technet.microsoft.com/en-us/library/gg251985.aspx
I have tried the Web Service in another new application created by UI in Central Administration (in same farm) and it had worked. The problem was the web application.
To try:
http://sharepointyankee.com/2011/01/04/the-request-failed-with-the-error-message-object-moved-sharepoint-2010-web-services-fba/
Extend your mixed authentication web application, and create a zone just for Windows Authentication, then change the Web Reference URL in the properties of your web service, to use that extended URL and port. You should have no issues of this kind anymore.