I'm using C# and PayPal Rest API to Get an approved payment and execute it. But, I need to update the transactions associated with approved payment. The PayPal documentation reads:
Use this call to execute (complete) a PayPal payment that has been approved by the payer. You can optionally update transaction information when executing the payment by passing in one or more transactions.
Here's my code
//Update the payment details in case totals changed because of a new address/zipcode
Details amountDetails = new Details();
amountDetails.subtotal = ValidationHelper.GetString(prices[Order.CartPricesEnum.Subtotal], "0");
amountDetails.tax = ValidationHelper.GetString(prices[Order.CartPricesEnum.Tax], "0");
amountDetails.shipping = ValidationHelper.GetString(prices[Order.CartPricesEnum.Shipping], "0");
Amount amount = new Amount();
amount.total = ValidationHelper.GetString(prices[Order.CartPricesEnum.Total], "0");
amount.currency = "USD";
amount.details = amountDetails;
//update the transaction to make sure we have accounted for any updated prices
Transactions trn = new Transactions();
trn.amount = amount;
List<Transactions> trns = new List<Transactions>();
trns.Add(trn);
//Create a payment execution object
PaymentExecution paymentExecution = new PaymentExecution();
paymentExecution.payer_id = payPalPayerID;
paymentExecution.transactions = trns;
//Execute (complete) the payment
Payment newPayment = payment.Execute(accessToken, paymentExecution);
The problem is that when when this runs I get the following error:
{"name":"VALIDATION_ERROR","details":[{"field":"transactions[0].total","issue":"Required field missing"},{"field":"transactions[0].currency","issue":"Required field missing"},{"field":"transactions[0].amount","issue":"This field name is not defined for this resource type"}],"message":"Invalid request - see details","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#VALIDATION_ERROR","debug_id":"bcba38f3c56d7"}
This is telling me that I'm missing .total and .currency, and that the .amount field is not defined. However, you can plainly see that I am setting the total and currency, and the amount field is the ONLY field that you can set on the transactions object according to the PayPal API documentation:
transactions
array of transaction objects
Transactional details if updating a payment. Note that this instance of the transactions object accepts only the amount object.
So, my question is: How can I take an approved payment, update the price on the transaction of the payment and then execute that payment?