Multiple shipping methods with smart buttons

iacopoermacora
Contributor
Contributor

Hi, I've been trying to integrate the smart payments button to my website. The main problem that I have is that i'd like for the user to be able to select the shipping methods he likes inside the paypal checkout, and update the shipping cost accordingly. By exploring (a lot) the documentation I understand the solution is somewhere in between the "shipping_option" of the ORDERS API and the "onShippingChange", but I can't understand how... can someone help me? I'm pretty lost and online you can only find deprecated solutions...

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

iacopoermacora
Contributor
Contributor

I eventually resolved my problem like this:

paypal.Buttons({
 createOrder: function(data, actions) {
  return actions.order.create({
   purchase_units: [{
    amount: {
    currency_code: "EUR",
    value: "y", //y=x+10
   breakdown: {
    item_total: {
     currency_code: "EUR",
     value: "x" //x = value
    },
  shipping: {
   currency_code: "EUR",
   value: "x"
  }
}
},
items: [
 // items details
],
shipping: {
  options: [
   {
     id: 'STANDARD',
     label: 'Spedizione Standard',
     type: 'SHIPPING',
     selected: true,
       amount: {
       value: '10.00',
       currency_code: 'EUR'
       }
     },
     {
       id: 'CONSEGNA_A_MANO',
       label: 'Consegna a mano - Solo Milano',
       type: 'SHIPPING',
       selected: false,
     amount: {
       value: '0.00',
       currency_code: 'EUR'
     }
    },
    {
      id: 'RITIRO_A_MANO',
      label: 'Ritiro a mano - Solo Milano',
      type: 'PICKUP',
      selected: false,
   amount: {
    value: '3.00',
    currency_code: 'EUR'
   }
  }
  ]
 }
}]
});
},

View solution in original post

Login to Me Too
2 REPLIES 2

peterpan321
New Community Member

Did you find out how this works? I'm also interested.

Login to Me Too
Solved

iacopoermacora
Contributor
Contributor

I eventually resolved my problem like this:

paypal.Buttons({
 createOrder: function(data, actions) {
  return actions.order.create({
   purchase_units: [{
    amount: {
    currency_code: "EUR",
    value: "y", //y=x+10
   breakdown: {
    item_total: {
     currency_code: "EUR",
     value: "x" //x = value
    },
  shipping: {
   currency_code: "EUR",
   value: "x"
  }
}
},
items: [
 // items details
],
shipping: {
  options: [
   {
     id: 'STANDARD',
     label: 'Spedizione Standard',
     type: 'SHIPPING',
     selected: true,
       amount: {
       value: '10.00',
       currency_code: 'EUR'
       }
     },
     {
       id: 'CONSEGNA_A_MANO',
       label: 'Consegna a mano - Solo Milano',
       type: 'SHIPPING',
       selected: false,
     amount: {
       value: '0.00',
       currency_code: 'EUR'
     }
    },
    {
      id: 'RITIRO_A_MANO',
      label: 'Ritiro a mano - Solo Milano',
      type: 'PICKUP',
      selected: false,
   amount: {
    value: '3.00',
    currency_code: 'EUR'
   }
  }
  ]
 }
}]
});
},
Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.