I'm trying to get delayed chained payments working through PayPal's Adaptive Payments API in C#.
The error I'm getting doesn't make any sense and I can't find anything on the .NET to resolve the issue.
The error message is:
Invalid request: More than one field cannot be used to specify a receiver
Here's the request I'm sending:
&cancelUrl=http%3a%2f%2flocalhost%2fccc%2fProgramsandServices%2fCommunityFundingInitiative%2fOopsSome thingWentWrong!.aspx ¤cyCode=USD
I specified two receivers, one is Primary other is not.
What am I missing?
I've tried both PAY and PAY_PRIMARY as the action types. Same results for either one.
If I only use ONE reciever, it works.
Here's the code:
WebClient webClient = new WebClient();
ReceiverList receiverList = new ReceiverList();
// Primary Receiver
Receiver receiver = new Receiver();
receiver.accountId = null;
receiver.amount = Convert.ToDecimal(txtPledgeAmount.Text.Trim());
receiver.invoiceId = Convert.ToString(SelectedProjectId) + "|" + Convert.ToString(PortalSettings.AdministratorId) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime());
//receiver.paymentSubType = null;
receiver.paymentType = "GOODS";
receiver.primary = true;
receiver.phone = new PhoneNumberType();new PhoneNumberType("001",PRIMARY_RECEIVER_PHONE_NUMBER);
receiver.email = PRIMARY_RECEIVER_EMAIL_ADDRESS;
// Secondary Receiver
string receiverEmail = "";
string receiverPhone = VALID_PHONE_NUMBER;
String receiverUserName = MembershipServices.Business.SharedFunctions.GetUserNameEmail(PortalId, SelectedProject.ProjectOwnerID, MembershipServices.SharedEnums.DisplayNameFormat_Type.FullName, ref receiverEmail);
Receiver receiver2 = new Receiver(Decimal.Parse(this.txtPledgeAmount.Text.Trim()) * SECONDARY_RECEIVER_PERCENTAGE);
receiver2.phone = receiver.phone = new PhoneNumberType("001", receiverPhone);
receiver2.email = receiverEmail;
receiver2.primary = Boolean.Parse("false");
receiver2.invoiceId = Convert.ToString(SelectedProjectId) + "|" + Convert.ToString(SelectedProject.ProjectOwnerID) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime()); ;
receiver2.paymentType = "GOODS";
String PortalAlias = PortalSettings.PortalAlias.HTTPAlias;
PortalAlias = PortalAlias + "/";
PortalAlias = @"https://" + PortalAlias;
PortalAlias = @"http://" + PortalAlias;
string actionType = "PAY_PRIMARY";
PayRequest req = new PayRequest(new RequestEnvelope("en_US"), actionType,
PortalAlias + CANCEL_URL, SharedEnums.CurrencyCode_Type.USD.ToString(),
receiverList, PortalAlias + RETURN_URL);
req.ipnNotificationUrl = PortalAlias + IPN_NOTIFICATION_URL;
//(Optional) A note associated with the payment (text, not HTML).
// Maximum length: 1000 characters, including newline characters
req.memo = txtPledgeMessage.Text.Trim();
req.memo = null;
// set optional parameters
//(Optional) Whether to reverse parallel payments if an error occurs with a payment.
//Allowable values are:
//true – Each parallel payment is reversed if an error occurs
//false – Only incomplete payments are reversed (default)
req.reverseAllParallelPaymentsOnError = false;
req.feesPayer = "EACHRECEIVER";
// Sender's email address
=req.senderEmail = SENDER_EMAIL_ADDRESS;
//(Optional) A unique ID that you specify to track the payment.
//Note: You are responsible for ensuring that the ID is unique.
//Maximum length: 127 characters
string trackingId = Convert.ToString(SelectedProjectId + "|" + Convert.ToString(SelectedUserId) + "|" + Convert.ToString(DateTime.Now.ToUniversalTime()));
req.trackingId = trackingId;
// All set. Fire the request
AdaptivePaymentsService service = new AdaptivePaymentsService();
PayResponse resp = null;
resp = service.Pay(req);
catch (System.Exception e)
If you've worked through this or can spot the error, please let me know!
Removing the phone number fields returns a successful response. I'm not certain if phone number fields are not supposed to be available in a Delayed Chained Payment transaction. I'm going to have to reach out to the product team for Adaptive Payments and find out from them.
Edit: The phone number has to be a confirmed mobile one. The error you're getting is because the phone number field can also be used to define the receiver so you're actually attempting to define the receivers twice.
The request I tested with (the same as yours but has Sandbox e-mail addresses set) -
requestEnvelope.errorLanguage=en_US actionType=PAY_PRIMARY cancelUrl=http://localhost/ccc/ProgramsandServices/CommunityFundingInitiative/OopsSomethingWentWrong!.aspx currencyCode=USD feesPayer=EACHRECEIVER ipnNotificationUrl=http://localhost/ccc/desktopmodules/UCU_ProjectManagement/PayPalIPN.aspx receiverList.receiver(0).amount=10.00 receiverList.receiver(0)[email protected] receiverList.receiver(0).primary=true receiverList.receiver(0).invoiceId=51|1|6/16/2013 4:35:56 PM receiverList.receiver(0).paymentType=GOODS receiverList.receiver(1).amount=9.50 receiverList.receiver(1)[email protected] receiverList.receiver(1).primary=false receiverList.receiver(1).invoiceId=51|1|6/16/2013 4:35:56 PM receiverList.receiver(1).paymentType=GOODS reverseAllParallelPaymentsOnError=false [email protected] returnUrl=http://localhost/ccc/ProgramsandServices/CommunityFundingInitiative/ThankYouforYourDonation.aspx trackingId=51|0|6/16/2013 4:35:56 PM