protected void Submit_Click(object sender, EventArgs e) { // Create request object MassPayRequestType request = new MassPayRequestType(); ReceiverInfoCodeType receiverInfoType = (ReceiverInfoCodeType) Enum.Parse(typeof(ReceiverInfoCodeType), receiverType.SelectedValue); request.ReceiverType = receiverInfoType; if (emailSubject.Value != "") { request.EmailSubject = emailSubject.Value; } // Processing a single masspay receiver. // You can add upto 250 receivers in one call MassPayRequestItemType massPayItem = new MassPayRequestItemType(); CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); massPayItem.Amount = new BasicAmountType(currency, amount.Value); if (receiverInfoType.Equals(ReceiverInfoCodeType.EMAILADDRESS) && emailId.Value != "") { massPayItem.ReceiverEmail = emailId.Value; } else if (receiverInfoType.Equals(ReceiverInfoCodeType.PHONENUMBER) && phoneNumber.Value != "") { massPayItem.ReceiverPhone = phoneNumber.Value; } else if (receiverInfoType.Equals(ReceiverInfoCodeType.USERID) && receiverId.Value != "") { massPayItem.ReceiverID = receiverId.Value; } if (note.Value != "") { massPayItem.Note = note.Value; } if (uniqueId.Value != "") { massPayItem.UniqueId = uniqueId.Value; } request.MassPayItem.Add(massPayItem); // Invoke the API MassPayReq wrapper = new MassPayReq(); wrapper.MassPayRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); MassPayResponseType massPayResponse = service.MassPay(wrapper); // Check for API return status processResponse(service, massPayResponse); }
// # MassPay API Operation // The MassPay API operation makes a payment to one or more PayPal account holders. public MassPayResponseType MassPayAPIOperation() { // Create the MassPayResponseType object MassPayResponseType responseMassPayResponseType = new MassPayResponseType(); try { // # MassPayReq // Details of each payment. // `Note: // A single MassPayRequest can include up to 250 MassPayItems.` MassPayReq massPay = new MassPayReq(); List <MassPayRequestItemType> massPayItemList = new List <MassPayRequestItemType>(); // `Amount` for the payment which contains // // * `Currency Code` // * `Amount` BasicAmountType amount1 = new BasicAmountType(CurrencyCodeType.USD, "4.00"); MassPayRequestItemType massPayRequestItem1 = new MassPayRequestItemType(amount1); // Email Address of receiver massPayRequestItem1.ReceiverEmail = "*****@*****.**"; // `Amount` for the payment which contains // // * `Currency Code` // * `Amount` BasicAmountType amount2 = new BasicAmountType(CurrencyCodeType.USD, "3.00"); MassPayRequestItemType massPayRequestItem2 = new MassPayRequestItemType(amount2); // Email Address of receiver massPayRequestItem2.ReceiverEmail = "*****@*****.**"; // `Amount` for the payment which contains // // * `Currency Code` // * `Amount` BasicAmountType amount3 = new BasicAmountType(CurrencyCodeType.USD, "7.00"); MassPayRequestItemType massPayRequestItem3 = new MassPayRequestItemType(amount3); // Email Address of receiver massPayRequestItem3.ReceiverEmail = "*****@*****.**"; massPayItemList.Add(massPayRequestItem2); massPayItemList.Add(massPayRequestItem1); massPayItemList.Add(massPayRequestItem3); MassPayRequestType massPayRequest = new MassPayRequestType(massPayItemList); massPay.MassPayRequest = massPayRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the massPay method in service wrapper object responseMassPayResponseType = service.MassPay(massPay); if (responseMassPayResponseType != null) { // Response envelope acknowledgement string acknowledgement = "MassPay API Operation - "; acknowledgement += responseMassPayResponseType.Ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseMassPayResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { logger.Info("Acknowledgement : " + responseMassPayResponseType.Ack.ToString() + "\n"); Console.WriteLine("Acknowledgement : " + responseMassPayResponseType.Ack.ToString() + "\n"); } // # Error Values else { List <ErrorType> errorMessages = responseMassPayResponseType.Errors; foreach (ErrorType error in errorMessages) { logger.Debug("API Error Message : " + error.LongMessage); Console.WriteLine("API Error Message : " + error.LongMessage + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return(responseMassPayResponseType); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object MassPayRequestType request = new MassPayRequestType(); ReceiverInfoCodeType receiverInfoType = (ReceiverInfoCodeType) Enum.Parse(typeof(ReceiverInfoCodeType), receiverType.SelectedValue); request.ReceiverType = receiverInfoType; // (Optional) The subject line of the email that PayPal sends when the transaction completes. The subject line is the same for all recipients. if (emailSubject.Value != string.Empty) { request.EmailSubject = emailSubject.Value; } // (Required) Details of each payment. // Note: // A single MassPayRequest can include up to 250 MassPayItems. MassPayRequestItemType massPayItem = new MassPayRequestItemType(); CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); massPayItem.Amount = new BasicAmountType(currency, amount.Value); // (Optional) How you identify the recipients of payments in this call to MassPay. It is one of the following values: // * EmailAddress // * UserID // * PhoneNumber if (receiverInfoType.Equals(ReceiverInfoCodeType.EMAILADDRESS) && emailId.Value != string.Empty) { massPayItem.ReceiverEmail = emailId.Value; } else if (receiverInfoType.Equals(ReceiverInfoCodeType.PHONENUMBER) && phoneNumber.Value != string.Empty) { massPayItem.ReceiverPhone = phoneNumber.Value; } else if (receiverInfoType.Equals(ReceiverInfoCodeType.USERID) && receiverId.Value != string.Empty) { massPayItem.ReceiverID = receiverId.Value; } if (note.Value != string.Empty) { massPayItem.Note = note.Value; } if (uniqueId.Value != string.Empty) { massPayItem.UniqueId = uniqueId.Value; } request.MassPayItem.Add(massPayItem); // Invoke the API MassPayReq wrapper = new MassPayReq(); wrapper.MassPayRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary <string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the MassPay method in service wrapper object MassPayResponseType massPayResponse = service.MassPay(wrapper); // Check for API return status processResponse(service, massPayResponse); }