I'm trying to create an API call to create a split payment. Upon creating the AdaptivePaymentService and calling the Pay method, it returns a PayResponse that shows SUCCESS. However, when I get the payKey and open the page at https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=, it brings me to some random page that usually says some error along the lines of "This transaction has already been approved. Please visit your PayPal Account Overview to see the details.", and in the top right, it'll show "Fiverr.com" or some other random webpage. I've verified that the payKey I am receiving is sent along with aSUCCESS message, so I don't understand why this is invalid. The following code is what I am using.
ReceiverList receiverList = new ReceiverList();
receiverList.receiver = new List<Receiver>();
RequestEnvelope requestEnvelope = new RequestEnvelope("en_US");
Dictionary<string, string> configurationMap = new Dictionary<string, string>();
configurationMap.Add("account1.apiUsername", "----");
configurationMap.Add("account1.apiPassword", "----");
configurationMap.Add("account1.apiSignature", "----");
configurationMap.Add("account1.applicationId", "APP-80W284485P519543T");
configurationMap.Add("mode", "sandbox");
Receiver receiver1 = new Receiver();
receiver1.amount = ((decimal?)9.00);
receiver1.email = "rbxtrade-seller#gmail.com";
receiverList.receiver.Add(receiver1);
Receiver receiver2 = new Receiver();
receiver2.amount = ((decimal?)2.00);
receiver2.email = "rbxtrade-buyer#gmail.com";
receiverList.receiver.Add(receiver2);
PayRequest request = new PayRequest(requestEnvelope, "PAY", "https://devtools-paypal.com/guide/ap_parallel_payment/dotnet?cancel=true", "USD", receiverList, "https://devtools-paypal.com/guide/ap_parallel_payment/dotnet?success=true");
AdaptivePaymentsService service = new AdaptivePaymentsService(configurationMap);
PayResponse response = service.Pay(request);
if (!response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
{
Process.Start("https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" + response.payKey); //opens the webpage
}
else
{
Console.WriteLine("E:" + String.Join("\n", response.error.Select((x) => x.message)));
}
I am currently facing this problem in java.
Try returning to this: "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + paykey. It is supposed to work with this.
It's all I found, but it DIDN'T work for me.
Related
I have an api that returns values from the database to populate our footer dynamically. These footer values are stored as keys in Redis at the endpoint and then in the main application I'm getting the url of the current page and creating a Hash with the key being the current url and the 5 returned redis key/values from the api as HashEntries. I've shown the code below and right where the HashSet is (at the end) is where the error starts, but if I remove the cache.Hashset, the code runs fine. Do I need to prepopulate the hash or am I missing something obvious here?
//Get relative url after .com/
var url = HttpContext.Current.Request.Url.ToString();
var urlSplit = url.Split(new string[] { ".com/" }, StringSplitOptions.None);
var finalUrl = urlSplit[1];
//TODO: If url isn't in Redis, want to hit endpoint and load it into Redis
//in the background with worker service/async call.
var cache = RedisHelper.Connection.GetDatabase();
var hashExists = cache.HashExists(finalUrl, "footer:recent-content");
if (hashExists)
{
recentContent = cache.HashGet(finalUrl, "footer:recent-content");
topPages = cache.HashGet(finalUrl, "footer:top-pages");
featuredContent = cache.HashGet(finalUrl, "footer:featured-content");
topIntegrations = cache.HashGet(finalUrl, "footer:top-integrations");
featuredIntegrations = cache.HashGet(finalUrl, "footer:featured-integrations");
}
else
{
recentContent = cache.StringGet("footer:general:recent-content");
topPages = cache.StringGet("footer:general:top-pages");
featuredContent = cache.StringGet("footer:general:featured-content");
topIntegrations = cache.StringGet("footer:general:top-integrations");
featuredIntegrations = cache.StringGet("footer:general:featured-integrations");
HashEntry[] redisFooterHash =
{
new HashEntry("footer:recent-content", recentContent),
new HashEntry("footer:top-pages", topPages),
new HashEntry("footer:featured-content", featuredContent),
new HashEntry("footer:top-integrations", topIntegrations),
new HashEntry("footer:featured-integrations", featuredIntegrations)
};
cache.HashSet(finalUrl, redisFooterHash);
}
Also, the reason the keys are footer:recent-content and footer:general... is that in the future we want each page to have a dynamic footer based on it's content.
I am trying to use the Direct Line v3.0 NuGet package to send a message to my bot. I am following the sample on Github, but I'm not getting the behavior I expect.
Here is the sample code:
DirectLineClient client = new DirectLineClient(directLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
while (true)
{
string input = Console.ReadLine().Trim();
if (input.ToLower() == "exit")
{
break;
}
else
{
if (input.Length > 0)
{
Activity userMessage = new Activity
{
From = new ChannelAccount(fromUser),
Text = input,
Type = ActivityTypes.Message
};
await client.Conversations.PostActivityAsync(conversation.ConversationId, userMessage);
}
}
}
And here is my code:
var directLineSecret = "MY_SECRET";
var client = new DirectLineClient(directLineSecret);
var conversation = await client.Conversations.StartConversationAsync();
var testActivity = new Activity
{
From = new ChannelAccount(name: "Proactive-Engine"),
Type = ActivityTypes.Message,
Text = "Hello from the PCE!"
};
var response = await client.Conversations.PostActivityAsync(conversation.ConversationId, testActivity);
I'm logging all the messages my bot receives. I can talk to the bot at its endpoint on Azure using the Bot Emulator, so I have confidence that it's working through the web chat API. However when I run the code above, the bot logs only a conversationUpdate message. The message I send does not get logged, and the value of response is null.
I'm hoping someone can help me find out where I'm going wrong here. Thanks!
Look at how the demo instantiates ChannelAccount:
new ChannelAccount(fromUser)
Then look at the ChannelAccount constructor signature:
public ChannelAccount(string id = null, string name = null)
This means that fromUser is passed as id. But look at how you instantiated ChannelAccount:
new ChannelAccount(name: "Proactive-Engine")
That code doesn't pass an id, it passes a name. So, you can change it like this:
new ChannelAccount("Proactive-Engine")
If your chatbot needs the name, then instantiate like this:
new ChannelAccount("MyChatbotID", "MyChatbotName")
As per the docs, to send an SMS for single number, we need not create SNS topic.
Clearly, they have given a sample code which shows we can set phone number for publish request method
http://docs.aws.amazon.com/sns/latest/dg/sms_publish-to-phone.html
As per the java docs, I can clearly see that method.
http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/sns/model/PublishRequest.html#setPhoneNumber-java.lang.String-
But, how do we implement same in c#? I couldn't find any method to send an sms without creating an SNS topic.
Can someone guide me how do I send an SMS without creating an SNS topic from C# SDK?
I hope this helps:
var smsAttributes = new Dictionary<string, MessageAttributeValue>();
MessageAttributeValue senderID = new MessageAttributeValue();
senderID.DataType = "String";
senderID.StringValue = "mySenderId";
MessageAttributeValue sMSType = new MessageAttributeValue();
sMSType.DataType = "String";
sMSType.StringValue = "Promotional";
////MessageAttributeValue maxPrice = new MessageAttributeValue();
////maxPrice.DataType = "Number";
////maxPrice.StringValue = "0.1";
CancellationTokenSource source = new CancellationTokenSource();
CancellationToken token = source.Token;
smsAttributes.Add("AWS.SNS.SMS.SenderID", senderID);
smsAttributes.Add("AWS.SNS.SMS.SMSType", sMSType);
////smsAttributes.Add("AWS.SNS.SMS.MaxPrice", maxPrice);
PublishRequest publishRequest = new PublishRequest();
publishRequest.Message = vm.Message;
publishRequest.MessageAttributes = smsAttributes;
publishRequest.PhoneNumber = vm.PhoneNumber;
AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient(vm.AccessKey, vm.SecretKey, config);
AmazonSNSResponse resp = new AmazonSNSResponse();
await client.PublishAsync(publishRequest);
AmazonSNSResponse response = new AmazonSNSResponse();
response.Status = HttpStatusCode.OK.ToString();
response.Message = "Success";
return response;
I believe you'll find the answer here: https://forums.aws.amazon.com/thread.jspa?threadID=250183&tstart=0
Basically what is saying and quote: "...PhoneNumber property was added in version 3.1.1.0 of AWSSDK.SimpleNotificationService..."
I haven't put example code since the PhoneNumber property is what is missing in the request, the rest should work as similar to Java Example :D.
See Publish(PublishRequest).
Amazon.SimpleNotificationService.Model.PublishRequest has a PhoneNumber property, used for setting the number when sending a direct SMS message.
After two days of testing, googling and so on, I decided to write here. I'm sorry for my bad English :)
I downloaded the PayPal Adaptive Payments SDK for .NET from http://paypal.github.io/sdk/#adaptive-payments and I opened the solution with Visual Studio Ultimate 2012 to try the samples. Unfortunately the Chained example doesn't works, with the following error:
Invalid request parameter: action type PAY_PRIMARY can only be used in chained payments
I studied documentation and tried several changes, without any result.
I created new project with this code https://devtools-paypal.com/guide/ap_chained_payment/dotnet?interactive=ON&env=sandbox
My code is
ReceiverList receiverList = new ReceiverList();
receiverList.receiver = new List<Receiver>();
Receiver secondaryReceiver = new Receiver((decimal?)1.00);
secondaryReceiver.email = "platfo_1255170694_biz#gmail.com";
secondaryReceiver.primary = false;
secondaryReceiver.paymentType = "SERVICE";
receiverList.receiver.Add(secondaryReceiver);
Receiver primaryReceiver = new Receiver((decimal?)2.00);
primaryReceiver.email = "platfo_1255612361_per#gmail.com";
primaryReceiver.primary = true;
primaryReceiver.paymentType = "GOODS";
primaryReceiver.invoiceId = "123456789";
receiverList.receiver.Add(primaryReceiver);
RequestEnvelope requestEnvelope = new RequestEnvelope("it_IT");
string actionType = "PAY";
string returnUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?success=true";
string cancelUrl = "https://devtools-paypal.com/guide/ap_chained_payment/dotnet?cancel=true";
string currencyCode = "EUR";
PayRequest payRequest = new PayRequest(requestEnvelope, actionType, cancelUrl, currencyCode, receiverList, returnUrl);
payRequest.ipnNotificationUrl = "http://replaceIpnUrl.com";
payRequest.feesPayer = "PRIMARYRECEIVER";
payRequest.trackingId = "123456789";
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", "sandbox");
sdkConfig.Add("account1.apiUsername", "jb-us-seller_api1.paypal.com");
sdkConfig.Add("account1.apiPassword", "WX4WTU3S8MY44S7F");
sdkConfig.Add("account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31A7yDhhsPUU2XhtMoZXsWHFxu-RWy");
sdkConfig.Add("account1.applicationId", "APP-80W284485P519543T");
AdaptivePaymentsService service = new AdaptivePaymentsService(sdkConfig);
PayResponse response = service.Pay(payRequest);
string redirectUrl = null;
if (!response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILURE.ToString()) && !response.responseEnvelope.ack.ToString().Trim().ToUpper().Equals(AckCode.FAILUREWITHWARNING.ToString()))
{
redirectUrl = "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=" + response.payKey;
}
I tried to set the property feesPayer to PRIMARYRECEIVER with the following error:
The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified
The Request of this code is
requestEnvelope.errorLanguage=it_IT&
actionType=PAY
cancelUrl=https://devtools-paypal.com/guide/ap_chained_payment/dotnet?cancel=true&
currencyCode=EUR&
feesPayer=PRIMARYRECEIVER&
ipnNotificationUrl=http://replaceIpnUrl.com&
receiverList.receiver(0).amount=1&
receiverList.receiver(0).email=platfo_1255170694_biz#gmail.com&
receiverList.receiver(0).primary=False&
receiverList.receiver(0).paymentType=SERVICE&
receiverList.receiver(1).amount=2&
receiverList.receiver(1).email=platfo_1255612361_per#gmail.com&
receiverList.receiver(1).primary=True&
receiverList.receiver(1).invoiceId=123456789&
receiverList.receiver(1).paymentType=GOODS&
returnUrl=https://devtools-paypal.com/guide/ap_chained_payment/dotnet?success=true&
trackingId=123456789&
The Response is
responseEnvelope.timestamp=2014-05-08T09:05:04.204-07:00&
responseEnvelope.ack=Failure&
responseEnvelope.correlationId=1a4d172eb110d&
responseEnvelope.build=10680030&
error(0).errorId=580023&
error(0).domain=PLATFORM&
error(0).subdomain=Application&
error(0).severity=Error&
error(0).category=Application&
error(0).message=The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified&
error(0).parameter(0)=feesPayer&
error(0).parameter(1)=PRIMARYRECEIVER
The line primaryReceiver.primary = true; in my C# code seems not to work... any ideas please? Has anyone had this type of problem?
Thank you in advance.
My facebook app uses the Facebook C# SDK to publish to a user's Facebook profile. I'm currently publishing multiple posts with one attachment, but I'd much rather publish one summary post with multiple attachments. I've done this with the JavaScript API, but is it possible with the C# SDK?
This is my current publish code:
FacebookApp app = new FacebookApp(user.AccessToken);
string userFeedPath = String.Format("/{0}/feed/", user.FacebookUserId);
string message = String.Format("{0} earned an achievement in {1}",
user.SteamUserId, achievement.Game.Name);
dynamic parameters = new ExpandoObject();
parameters.link = achievement.Game.StatsUrl;
parameters.message = message;
parameters.name = achievement.Name;
parameters.description = achievement.Description;
parameters.picture = achievement.ImageUrl;
app.Api(userFeedPath, parameters, HttpMethod.Post);
We currently don't support multiple attachments. As far as I know you can't publish multiple attachments with either the graph or rest api. If you have a sample that shows how to do it, I will get it implemented in the SDK.
i have the same code as yours but it doesent work for me. I am trying this:
public void plesni()
{
try
{
dynamic parameters = new ExpandoObject();
parameters.message = "xxxxxxx";
parameters.link = "xxxxxxxx";
// parameters.picture=""
parameters.name = "xxxxxx";
parameters.caption = "xxxxxxx";
parameters.description = "xxxxxxxxxx";
parameters.actions = new
{
name = "xxxxxxx",
link = "http://www.xxxxxxxxxxxxxx.com",
};
parameters.privacy = new
{
value = "ALL_FRIENDS",
};
parameters.targeting = new
{
countries = "US",
regions = "6,53",
locales = "6",
};
dynamic result = app.Api("/uid/feed/", parameters, HttpMethod.Post);
// app.Api("/uid/feed", parameters);
Response.Write("Sucess");
}
catch (FacebookOAuthException)
{
Response.Write("...... <br/>");
}
}
if instead of uid I put me it works fine.
I am hoping for your help.
Have a good day.