Note that there are some explanatory texts on larger screens.

plurals
  1. POPass in an array of PaymentDetailsItemType to PayPalAPI
    primarykey
    data
    text
    <p>I am using the PayPal sandbox in ASP.Net C# 4.0. I added the following web reference:</p> <pre><code> https://www.paypalobjects.com/wsdl/PayPalSvc.wsdl </code></pre> <p>If i have 1 item (gimme 2 t-shirts please) i can pass it to the PayPal object and complete my transactions with no problems whatsoever:</p> <pre><code> var item = new PayPalAPIHelper.PayPalWS.PaymentDetailsItemType { Quantity = 2, //etc...etc }; var paymentDetails = new PayPalAPIHelper.PayPalWS.PaymentDetailsType(); paymentDetails.PaymentDetailsItem = new PaymentDetailsItemType[]{item}; </code></pre> <p>Now my dilemma is when a customer wants different items (1 t-shirt, 1 pair of pants). Now i need multiple PaymentDetailsItemType objects to pass to the paymentDetails object. I tried this:</p> <pre><code> //now i have an array of different items var items = new PayPalAPIHelper.PayPalWS.PaymentDetailsItemType[3]; items[0].Description = "T-shirt"; items[1].Description = "Jeans"; paymentDetails.PaymentDetailsItem = new PaymentDetailsItemType[]{items}; </code></pre> <p>I get this error:</p> <pre><code> Cannot implicitly convert type 'PayPalAPIHelper.PayPalWS.PaymentDetailsItemType[]' to 'PayPalAPIHelper.PayPalWS.PaymentDetailsItemType' </code></pre> <p>I can do this and it compiles:</p> <pre><code> paymentDetails.PaymentDetailsItem = new PaymentDetailsItemType[]{items[0],items[1]}; </code></pre> <p>But when I run it, i get Data type '' mismatch in element 'Quantity' when i call the PayPal service:</p> <pre><code> PayPalAPIHelper.PayPalWS.PaymentDetailsType paymentDetails = new PayPalAPIHelper.PayPalWS.PaymentDetailsType(); paymentDetails.PaymentDetailsItem = new PayPalAPIHelper.PayPalWS.PaymentDetailsItemType[] { items[0],items[1] }; reqDetails.PaymentDetails = new PayPalAPIHelper.PayPalWS.PaymentDetailsType[] { paymentDetails }; PayPalAPIHelper.PayPalWS.SetExpressCheckoutReq req = new PayPalAPIHelper.PayPalWS.SetExpressCheckoutReq() { SetExpressCheckoutRequest = new PayPalAPIHelper.PayPalWS.SetExpressCheckoutRequestType() { Version = Version, SetExpressCheckoutRequestDetails = reqDetails } }; // query PayPal and get token //error occurs here PayPalAPIHelper.PayPalWS.SetExpressCheckoutResponseType resp = BuildPayPalWebservice().SetExpressCheckout(req); //this is where the error occurs </code></pre> <p>How do i pass multiple types to the PayPal API web service so the user can order different items? Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload