Modika
Modika

Reputation: 6282

Sending Cart items to Paypal using the SOAP API in ASP.Net

I am going a little insane working with the PayPal SOAP API. the actual process is working fine, by that i mean i redirect to Paypal and the process redirects back and i cant take an order and process it.

The issue i am having is i cant seem to send over the contents of my cart to the paypal page to give an overview of what they are paying for. I tried using the PaymentDetails array, and this kind of worked for one item, but mutliple items (and multiple paymentDetail objects) failed as i thinks i am trying to take payments from multiple sellers, which makes sense, but i am not.

Does anyone know how this works with .Net, or has any idea on where i should be putting these items, i found some documentation on customising the espress checkout process but this is for the NVP API and i cant seem to find the same information for the SOAP API.

Upvotes: 2

Views: 1212

Answers (1)

Modika
Modika

Reputation: 6282

i was looking in the right area, wrong focus. The PaymentDetails Object contains a PaymentDetailsItem array where the items go, code needs to be neatened up, but should give the general idea if anyone else needs it.

    PaymentDetailsType[] pmtDetails = new PaymentDetailsType[1];
    pmtDetails[0] = new PaymentDetailsType();
    var pmtIndex = 0;

    PaymentDetailsItemType[] items = new PaymentDetailsItemType[cartItems.Count];

    foreach (var item in cartItems)
    {
        var i = new PaymentDetailsItemType()
        {
            Name = item.productName,
            Number = item.productID.ToString(),
            Quantity = item.quantity.ToString(),
            Amount = new BasicAmountType(){ currencyID = CurrencyCodeType.GBP, Value = item.productPrice.ToString() }
        };
        items[pmtIndex] = i;
        pmtIndex++;
    }
    //reqDetails.p
    //reqDetails.PaymentDetails = pmtDetails;
    //hOrderTotal.Value
    // 
    pmtDetails[0].PaymentDetailsItem = items;
    pmtDetails[0].OrderTotal = new BasicAmountType() { currencyID = CurrencyCodeType.GBP, Value = HttpContext.Current.Session["_OrderTotalLessShippingAmount"].ToString() };
    reqDetails.PaymentDetails = pmtDetails;

Upvotes: 1

Related Questions