Code Monkey home page Code Monkey logo

Comments (2)

LeoCR avatar LeoCR commented on July 18, 2024 1

Hello @prakash-gangadharan

Thanks for your answer . I have 3 differents objects inside this.props.orders.orders,I noted that this code doesn't works:

        var items=[];
        var tempItem={};
        var tempSubtotal=0;
        this.props.orders.orders.forEach(function(order) {
            tempSubtotal+=order.quantity*order.price;
            tempItem.name=order.name.toString();
            tempItem.sku=order.id;
            tempItem.price=order.price;
            tempItem.currency=order.currency.toString();
            tempItem.quantity=order.quantity;
            items.push(tempItem);
        });
        this.setState({
            subtotal:tempSubtotal,
            items
        });

Inside this.props.orders.orders I have this data:

{
      category: "Soup",
      currency: "USD",
      description: "With beef stock base, slow-cooked caramelized onions,↵ French bread, gruyere and Parmesan cheese,especially with↵ a thick slice of toasted bread loaded with melty Gruyere cheese ↵ and lots of caramelized onions.",
      id: "5ENTR",
      name: "French Onion Soup",
      picture: "/img/entrees/french-onion-soup.png",
      price: "5.60",
      quantity: 2
},
{
       category: "Meat",
       currency: "USD",
       description: "Oybox tomatoes, basil seed vinaigrette .",
       id: "6ENTR",
       name: "Strips of Filet Mignon",
       picture: "/img/entrees/strips-of-filet-mignon.png",
       price: "6.50",
       quantity: 2
},
{
      category: "Fast Food",
      currency: "USD",
      description: "A hamburger, beefburger or burger is a sandwich consisting of one or more cooked patties of ground meat, usually↵ beef, placed inside a sliced bread roll or bun",
      id: "3BGD",
      name: "Hamburguer",
      picture: "/img/strong-dish/hamburger.png",
      price: "5.50",
     quantity: 2
}

from paypal-node-sdk.

prakash-gangadharan avatar prakash-gangadharan commented on July 18, 2024

Hi @LeoCR , with respect to the PayPal-Debug-ID : 3b1078db6e31
The request payload given by you to create payment is as below

{
  "intent": "order",
  "payer": {
    "payment_method": "paypal"
  },
  "transactions": [
    {
      "amount": {
        "total": "25.35",
        "currency": "USD",
        "details": {
          "subtotal": "24.20",
          "tax": "0.15",
          "shipping": "1"
        }
      },
      "description": "Hat for the best team ever.",
      "item_list": {
        "items": [
          {
            "name": "French Onion Soup",
            "sku": "5ENTR",
            "price": "5.60",
            "currency": "USD",
            "quantity": "2"
          },
          {
            "name": "French Onion Soup",
            "sku": "5ENTR",
            "price": "5.60",
            "currency": "USD",
            "quantity": "2"
          },
          {
            "name": "French Onion Soup",
            "sku": "5ENTR",
            "price": "5.60",
            "currency": "USD",
            "quantity": "2"
          }
        ]
      }
    }
  ],
  "redirect_urls": {
    "return_url": "https://localhost:49652/paypal/success",
    "cancel_url": "https://localhost:49652/paypal/cancel"
  }
}

Here the total and subtotal value is wrong with respect to the line item_list amounts.
It should be subtotal: "33.6" and total: "34.75". Can you check at your code that, what making these values as a wrong one?

Thanks!

from paypal-node-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.