Skip to main content

PayPal Community

  • Dashboard
  • Send and Request
  • Wallet
  • Business
  • Help
Log in

Le forum de Communauté ne sera plus disponible à partir du 30 Juin 2025. Le Forum de la communauté n’est pas disponible pour les nouveaux messages ou les réponses; les articles précédents restent disponibles pour vérification. Afin de connaître les options d’assistance complètes, rendez-vous sur PayPal.com/HelpCenter

Si vous souhaitez signaler du contenu illégal et contraire au Règlement sur les services numériques de l’Union Européenne (DSA), veuillez cliquer ici.

since ‎Mar-25-2019
Country: Australia
Type: Personal
natewallis
natewallis Contributor
Contributor
2
Posts
0
Kudos
0
Solutions
Liked
Your PayPal Anniversary
Active
The Return
View all
Latest Contributions by natewallis
  • Topics natewallis has Participated In
  • Latest Contributions by natewallis

Paypal smart payments - PATCH

by natewallis Contributor in PayPal Reporting
‎May-08-2019 05:51 PM
‎May-08-2019 05:51 PM
Hi,    I am having issues with using the smart payments buttons and having the patch function update the paypal total.  The code is working, but the value reflected to the user seems to always be out of sync.    I have two test addresses saved against my sandbox user account.  One with a post code of 7000 and one with a post code of 3350.   After detecting a shipping change, I make a call to my server to update the users post code, which will in turn update the shipping total.  I then follow the documentation and return actions.order.patch() with appropriate parameters.  However, the value reflected in the paypal window is out of sync with the selected shipping address.     E.g.  When I select my 7000 shipping address, I can see my cart total changing in the background on our ecommerce platform (so I know that is working) and paypal says "Address has been updated" , but the total charged to the customer does not change.  However if I then go and select the 3350 address, again, I see my website update to the correct value and in a grey box I see the order total that relates to when the 7000 post code was selected.    This suggests to me that the patch is working (on some level), but it isn't reflecting immediately in the paypal payments window..    Any thoughts?   Here is my code:   paypal.Buttons({ style: { branding: true, label: 'buynow', layout: 'horizontal', tagline: false }, createOrder: (data, actions) => { let order_data = { purchase_units: [ { amount: this.generate_purchase_units_amount() } ] }; return actions.order.create(order_data); }, onCancel: function (data) { //alert('order cancelled'); }, onError: function (err) { //alert ("there was a paypal error"); }, onShippingChange: (data, actions) => { if (data.shipping_address.country_code !== 'AU') { return actions.reject(); } this.$store.dispatch('update_user_data', { ['s_zipcode']: data.shipping_address.postal_code }).then(response => { console.log(this.generate_purchase_units_amount()); return actions.order.patch([ { op: 'replace', path: "/purchase_units/@reference_id=='default'/amount", value: this.generate_purchase_units_amount() } ]); }); } }).render('#paypal-button-container'); generate_purchase_units_amount(){ return { currency_code: 'AUD', value: this.$store.getters.cart_total, breakdown: { item_total: { currency_code: 'AUD', value: this.$store.getters.cart_subtotal }, shipping: { currency_code: 'AUD', value: this.$store.getters.cart_shipping_total } } }; }, ... View more

Paypal smart payments - PATCH

by natewallis Contributor in PayPal Payments Standard
‎Apr-09-2019 01:17 AM
‎Apr-09-2019 01:17 AM
Hi,    I have implemented the paypal smart buttons inside a vue.js component (don't think this matters) so that I can access my global vuex data for use in creating the buttons.   Here is my code, I have a short helper function that I reuse to generate the JSON for the create order request and also in the onShippingChange handler.    The issue I am having is that the "Review your payment" does not display the changes in the patch until I refresh the page.  I would have expected the page to update after the patch  request is complete.     generation_paypal_buttons() is called when my vue.js component is mounted()...      So basically what happens is that I have 2 test addresses, one with a post code 3350, one with a post code 7000.   3350 shipping is equal to $40 and 7000 shipping is $80. When I change addresses to 3350, I see a new order value that includes $80 and when I change to 7000, I see $40.... which suggests to me that the patch operation works (on the paypal server), but it is not reflected immediately in the client window.    If you have any suggestions, please let me know... Thankyou.      generate_purchase_units_amount(){ return { currency_code: 'AUD', value: this.$store.getters.cart_total, breakdown: { item_total: { currency_code: 'AUD', value: this.$store.getters.cart_subtotal }, shipping: { currency_code: 'AUD', value: this.$store.getters.cart_shipping_total } } }; },     generate_paypal_buttons(){ paypal.Buttons({ style: { branding: true, label: 'buynow', layout: 'horizontal', tagline: false }, createOrder: (data, actions) => { let order_data = { purchase_units: [ { amount: this.generate_purchase_units_amount() } ] }; return actions.order.create(order_data); }, onCancel: function (data) { //alert('order cancelled'); }, onError: function (err) { //alert ("there was a paypal error"); }, onShippingChange: (data, actions) => { if (data.shipping_address.country_code !== 'AU') { return actions.reject(); } this.$store.dispatch('update_user_data', { ['s_zipcode']: data.shipping_address.postal_code }).then(response => { return actions.order.patch([ { op: 'replace', path: "/purchase_units/@reference_id=='default'/amount", value: this.generate_purchase_units_amount() } ]); }); } }).render('#paypal-button-container'); } It appear   ... View more
Labels:
  • Labels:
  • PayPal HTML Buttons
Paypal Logo
  • Help
  • Contact Us
  • Security
  • Fees
  • © 1999-2025 PayPal, Inc. All rights reserved.
  • Privacy
  • Legal
  • Cookies
  • Policy Updates

The money in your balance is eligible for pass-through FDIC insurance.

The PayPal Cash Mastercard is issued by The Bancorp Bank pursuant to a license by Mastercard International Incorporated. The Bancorp Bank; Member FDIC.

Powered by Khoros