Error in PayPal Chained Adaptive Payments - c#

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.

Related

How to use SMS-Authentication in DocuSign

I'm trying to implement the SMS authentication with the aid of the DocuSign-SDK library.
var signer = new Signer {...};
signer.RequireIdLookup = "true";
signer.IdCheckConfigurationName = "SMS Auth $";
signer.SmsAuthentication = new RecipientSMSAuthentication {
SenderProvidedNumbers = new List<string> {
"0171*******"
}
};
When I try to send this envelope to the DocuSign API it will reply with the following error message:
Error calling CreateEnvelope:
{"errorCode":"INVALIDAUTHENTICATIONSETUP","message":"Recipient phone
number is invalid. Phone number for SMS Authentication: provided is
invalid. }
INVALIDAUTHENTICATIONSETUP: Authentication is not setup correctly for the recipient.
Is there something I have to enable on the DocuSign Admin page? I couldn't find any feature or something like that I need to enable.
Did I implement it the wrong way? Maybe someone can give me some suggestions.
Thanks
BTW: The given phone number should be valid.
EDIT:
When I'm using the new method as #Inbar wrote, I can't get the needed workflowId from the AccountsApi.
var client = new ApiClient(ApiClient.Demo_REST_BasePath);
var token = "eyJ1...";
client.Configuration.DefaultHeader.Add("Authorization", "Bearer " + token);
var accountsApi = new AccountsApi(client);
var response = accountsApi.GetAccountIdentityVerification(accountId);
var result = response.IdentityVerification; // Is empty. Why?
It seems that I have no IdentityVerification options which I can use for the authentication.
How can I enable such IdentityVerification options?
Or what else do I need to pay attention to?
Your code is using the older method, the new method code is provided in GitHub, I'll post it here too. You can find the article on Dev Center.
string workflowId = phoneAuthWorkflow.WorkflowId;
EnvelopeDefinition env = new EnvelopeDefinition()
{
EnvelopeIdStamping = "true",
EmailSubject = "Please Sign",
EmailBlurb = "Sample text for email body",
Status = "Sent"
};
byte[] buffer = System.IO.File.ReadAllBytes(docPdf);
// Add a document
Document doc1 = new Document()
{
DocumentId = "1",
FileExtension = "pdf",
Name = "Lorem",
DocumentBase64 = Convert.ToBase64String(buffer)
};
// Create your signature tab
env.Documents = new List<Document> { doc1 };
SignHere signHere1 = new SignHere
{
AnchorString = "/sn1/",
AnchorUnits = "pixels",
AnchorXOffset = "10",
AnchorYOffset = "20"
};
// Tabs are set per recipient/signer
Tabs signer1Tabs = new Tabs
{
SignHereTabs = new List<SignHere> { signHere1 }
};
string workflowId = workflowId;
RecipientIdentityVerification workflow = new RecipientIdentityVerification()
{
WorkflowId = workflowId,
InputOptions = new List<RecipientIdentityInputOption> {
new RecipientIdentityInputOption
{
Name = "phone_number_list",
ValueType = "PhoneNumberList",
PhoneNumberList = new List<RecipientIdentityPhoneNumber>
{
new RecipientIdentityPhoneNumber
{
Number = phoneNumber,
CountryCode = countryAreaCode,
}
}
}
}
};
Signer signer1 = new Signer()
{
Name = signerName,
Email = signerEmail,
RoutingOrder = "1",
Status = "Created",
DeliveryMethod = "Email",
RecipientId = "1", //represents your {RECIPIENT_ID},
Tabs = signer1Tabs,
IdentityVerification = workflow,
};
Recipients recipients = new Recipients();
recipients.Signers = new List<Signer> { signer1 };
env.Recipients = recipients;
I've created a new developer account on DocuSign and created a small test app in order to request identity verification options. Fortunately, that was working now and I got all available options but I do not understand why this is not working for my other developer account ("old").
When I compare both accounts I don't see the "Identity Verification" setting in the "old" account.
It is possible to activate this "Identity Verification" setting for my "old" dev account?
I guess that enabling this feature would solve the problem.
EDIT:
Ok, I've solved the problem.
I figured out that no IDV was configured for my developer account. In that case, the identity_verification call will return an empty array.
see: https://developers.docusign.com/docs/esign-rest-api/how-to/id-verification/
Also, I have read the following note in the DocuSign documentation:
Note: Phone authentication may not be enabled for some older developer
accounts. If you cannot choose to use phone authentication for your
account, contact support to request access. see:
https://developers.docusign.com/docs/esign-rest-api/esign101/concepts/recipients/auth/#id-verification-idv
So I contacted DocuSign support and they give me access to the IDV accordingly.
Now it is working fine.

Amazon SMS for single number from c# sdk without creating topic

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.

Paypal payKey brings me to incorrect payment

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.

INTERNAL_SERVICE_ERROR while creating payment in PayPal SandBox, MVC

I have ran out of ideas and none of the answers for the similar question was helpful, hence I am desperate now. I am trying to integrate paypal payment into my app. I have set negative testing to off in my sandbox account. I am using visual studio 2013, here is my example code:
Address billingAddress = new Address();
billingAddress.line1 = "52 N Main ST";
billingAddress.city = "Johnstown";
billingAddress.country_code = "US";
billingAddress.postal_code = "43210";
billingAddress.state = "OH";
CreditCard creditCard = new CreditCard();
creditCard.number = "4417119669820331";
creditCard.type = "visa";
creditCard.expire_month = 11;
creditCard.expire_year = 2018;
creditCard.cvv2 = "874";
creditCard.first_name = "Joe";
creditCard.last_name = "Shopper";
creditCard.billing_address = billingAddress;
var amountDetails = new Details();
amountDetails.subtotal = "7.41";
amountDetails.tax = "0.03";
amountDetails.shipping = "0.03";
Amount amount = new Amount();
amount.total = "7.47";
amount.currency = "USD";
amount.details = amountDetails;
Transaction transaction = new Transaction();
transaction.amount = amount;
transaction.description = "This is the payment transaction description.";
List<Transaction> transactions = new List<Transaction>();
transactions.Add(transaction);
FundingInstrument fundingInstrument = new FundingInstrument();
fundingInstrument.credit_card = creditCard;
List<FundingInstrument> fundingInstruments = new List<FundingInstrument>();
fundingInstruments.Add(fundingInstrument);
Payer payer = new Payer();
payer.funding_instruments = fundingInstruments;
payer.payment_method = "credit_card";
Payment payment = new Payment();
payment.intent = "sale";
payment.payer = payer;
payment.transactions = transactions;
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
try
{
var apiContext = new APIContext(accessToken);
var createdPayment = payment.Create(apiContext);
}
catch (PayPal.HttpException e)
{
return Json(e.InnerException, JsonRequestBehavior.AllowGet);
}
Now each time I am attempting to create the payment, I am getting the following:
"{\"name\":\"INTERNAL_SERVICE_ERROR\",\"message\":\"An internal service error has occurred\",\"information_link\":\"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR\",\"debug_id\":\"f0d2f70ac4693\"}"
debug_id changes each time i attempt. any help would be hugely appreciated.
Try changing the credit card number you're using to a different number. This error has been happening a lot in the recent weeks on PayPal's sandbox environment and is (most of the time) related to overusing a credit card number. The best thing to try would be to create a new Sandbox test account via the Developer Dashboard and generate a new credit card number there.
The PayPal payments team is currently working on a solution on sandbox to return a more meaningful error when this happens.
EDIT:
As an alternative to creating a new Sandbox test account to get a new credit card number for testing, you can also try the credit card number generator available in the following FAQ on the PayPal Technical Support site:
Sandbox - Generate an Additional Credit Card Number for a Sandbox account.
Scroll down to Step 4 on that page to find the generator.

How to publish a post with multiple attachments to a user's facebook profile?

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.

Categories

Resources