我使用C#和PayPal Rest API來獲得批准的付款並執行付款。但是,我需要更新與已批准付款相關的交易。貝寶的文件上寫着:PayPal Rest API - 使用更新的交易信息執行付款
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.
這裏是我的代碼
//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);
的問題是,當在運行此我得到以下錯誤:
{"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"}
這是告訴我,我m缺少.total和.currency,並且.amount字段未定義。但是,你可以清楚地看到,我設置了總與貨幣,金額字段是唯一的字段,你可以對交易對象設置根據PayPal的API文檔:
transactions
array of transaction objects
Transactional details if updating a payment. Note that this instance of the transactions object accepts only the amount object.
所以,我的問題是:如何獲得批准的付款,更新付款交易的價格,然後執行該付款?
有沒有這個工作? – Rivka
實際上,PayPal Rest API目前不支持我想要做的事情。我必須使用遺留框架重寫所有內容。在與PayPal支持交談後,我想到了這一點。該部分的文檔不太清楚。 – sheibeck
謝謝,我最終與遺留庫一起進行了其他限制(例如,在批准的交易中檢索貨件信息)。 – Rivka