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