Skip to main content

PayPal Community

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

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 ‎Jul-21-2021
DKTim
DKTim
New Community Member
2
Posts
0
Kudos
1
Solution
Helper
Ice Breaker
Active
View all
Latest Contributions by DKTim
  • Topics DKTim has Participated In
  • Latest Contributions by DKTim

Re: Javascript SDK and discount/coupons/promos

by DKTim in SDKs
‎Jul-22-2021 02:52 AM
‎Jul-22-2021 02:52 AM
Rubber ducking really is a thing. I just managed to solve my own problem, which was that the line-item is the original price (4.99) and the amount value should be the original price (4.99) minus the discount (1.23), which is 3.76 This code works:   // Set up the transaction createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ description: "My awesome product", amount: { currency_code: "USD", value: "3.76", breakdown: { item_total: { currency_code: 'USD', value: "4.99" }, discount: { currency_code: "USD", value: "1.23" } } }, custom_id: "ORDER-0001234" }], application_context: { shipping_preference: "NO_SHIPPING" } }); },      And for anyone else wanting to know how to get discounts working for subscriptions, you are able to specify some plan details to override the specified plan:   createSubscription: function(data, actions) { return actions.subscription.create({ /* Creates the subscription */ plan_id: 'MY PLAN ID', custom_id: "ORDER-00001234", plan: { billing_cycles: [ { frequency: { interval_unit: "MONTH", interval_count: 1 }, tenure_type: "REGULAR", sequence: "1", pricing_scheme: { fixed_price: { value: "10", currency_code: "USD" } } }] }, application_context: { shipping_preference: "NO_SHIPPING" } }); },   See: https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_create An inline plan object to customise the subscription. You can override plan level default attributes by providing customised values for the subscription in this object.   ... View more

Javascript SDK and discount/coupons/promos

by DKTim in SDKs
‎Jul-22-2021 02:41 AM
‎Jul-22-2021 02:41 AM
I am struggling to get "discount" to work in the "breakdown" field when I am creating an order via the Javascript SDK (smart payment buttons).         // Set up the transaction createOrder: function(data, actions) { return actions.order.create({ purchase_units: [{ description: "My awesome product", amount: { currency_code: "USD", value: "4.99", breakdown: { item_total: { currency_code: 'USD', value: "3.76" }, discount: { currency_code: "USD", value: "1.23" } } }, custom_id: "ORDER-0001234" }], application_context: { shipping_preference: "NO_SHIPPING" } }); },           The error I see is "AMOUNT_MISMATCH". According to the API documentation https://developer.paypal.com/docs/api/orders/v2/#definition-amount_breakdown  And this Github ticket https://github.com/paypal/paypal-checkout-components/issues/1016 The functionality should be available since 1 April 2020. Any suggestions on what I am doing wrong? ... View more
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