public RefundTransaction ( |
||
refundTransactionReq | ||
return |
protected void Submit_Click(object sender, EventArgs e) { // Create request object RefundTransactionRequestType request = new RefundTransactionRequestType(); request.TransactionID = transactionId.Value; if (refundType.SelectedIndex != 0) { request.RefundType = (RefundType) Enum.Parse(typeof(RefundType), refundType.SelectedValue); if (request.RefundType.Equals(RefundType.PARTIAL) && refundAmount.Value != "") { CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); request.Amount = new BasicAmountType(currency, refundAmount.Value); } } if (memo.Value != "") { request.Memo = memo.Value; } if (retryUntil.Text != "") { request.RetryUntil = retryUntil.Text; } if (refundSource.SelectedIndex != 0) { request.RefundSource = (RefundSourceCodeType) Enum.Parse(typeof(RefundSourceCodeType), refundSource.SelectedValue); } // Invoke the API RefundTransactionReq wrapper = new RefundTransactionReq(); wrapper.RefundTransactionRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); RefundTransactionResponseType refundTransactionResponse = service.RefundTransaction(wrapper); // Check for API return status processResponse(service, refundTransactionResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object RefundTransactionRequestType request = new RefundTransactionRequestType(); // (Required) Unique identifier of the transaction to be refunded. // Note: Either the transaction ID or the payer ID must be specified. request.TransactionID = transactionId.Value; // Type of refund you are making. It is one of the following values: // * Full – Full refund (default). // * Partial – Partial refund. // * ExternalDispute – External dispute. (Value available since version 82.0) // * Other – Other type of refund. (Value available since version 82.0) if (refundType.SelectedIndex != 0) { request.RefundType = (RefundType) Enum.Parse(typeof(RefundType), refundType.SelectedValue); // (Optional) Refund amount. The amount is required if RefundType is Partial. // Note: If RefundType is Full, do not set the amount. if (request.RefundType.Equals(RefundType.PARTIAL) && refundAmount.Value != string.Empty) { CurrencyCodeType currency = (CurrencyCodeType) Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue); request.Amount = new BasicAmountType(currency, refundAmount.Value); } } // (Optional) Custom memo about the refund. if (memo.Value != string.Empty) { request.Memo = memo.Value; } // (Optional) Maximum time until you must retry the refund. if (retryUntil.Text != string.Empty) { request.RetryUntil = retryUntil.Text; } // (Optional)Type of PayPal funding source (balance or eCheck) that can be used for auto refund. It is one of the following values: // * any – The merchant does not have a preference. Use any available funding source. // * default – Use the merchant's preferred funding source, as configured in the merchant's profile. // * instant – Use the merchant's balance as the funding source. // * eCheck – The merchant prefers using the eCheck funding source. If the merchant's PayPal balance can cover the refund amount, use the PayPal balance. // Note: This field does not apply to point-of-sale transactions. if (refundSource.SelectedIndex != 0) { request.RefundSource = (RefundSourceCodeType) Enum.Parse(typeof(RefundSourceCodeType), refundSource.SelectedValue); } // Invoke the API RefundTransactionReq wrapper = new RefundTransactionReq(); wrapper.RefundTransactionRequest = request; // Configuration map containing signature credentials and other required configuration. // For a full list of configuration parameters refer in wiki page // [https://github.com/paypal/sdk-core-dotnet/wiki/SDK-Configuration-Parameters] Dictionary<string, string> configurationMap = Configuration.GetAcctAndConfig(); // Create the PayPalAPIInterfaceServiceService service object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap); // # API call // Invoke the RefundTransaction method in service wrapper object RefundTransactionResponseType refundTransactionResponse = service.RefundTransaction(wrapper); // Check for API return status processResponse(service, refundTransactionResponse); }
public override RefundProcessPaymentResult RefundProcessPayment(RefundProcessPaymentEvaluationContext context) { if (context == null || context.Payment == null) throw new ArgumentNullException("paymentEvaluationContext"); RefundProcessPaymentResult retVal = new RefundProcessPaymentResult(); if (context.Payment.IsApproved && (context.Payment.PaymentStatus == PaymentStatus.Paid || context.Payment.PaymentStatus == PaymentStatus.Cancelled)) { try { var config = GetConfigMap(); var service = new PayPalAPIInterfaceServiceService(config); RefundTransactionReq refundTransctionRequest = GetRefundTransactionRequest(context.Payment); service.RefundTransaction(refundTransctionRequest); } catch(Exception ex) { retVal.ErrorMessage = ex.Message; } } return new RefundProcessPaymentResult { ErrorMessage = "Not implemented yet" }; }
// # RefundTransaction API Operation // The RefundTransaction API operation issues a refund to the PayPal account holder associated with a transaction public RefundTransactionResponseType RefundTransactionAPIOperation() { // Create the RefundTransactionResponseType object RefundTransactionResponseType responseRefundTransactionResponseType = new RefundTransactionResponseType(); try { // Create the RefundTransactionReq object RefundTransactionReq refundTransaction = new RefundTransactionReq(); RefundTransactionRequestType refundTransactionRequest = new RefundTransactionRequestType(); // Either the `transaction ID` or the `payer ID` must be specified. // PayerID is unique encrypted merchant identification number // For setting `payerId`, // `refundTransactionRequest.PayerID = "A9BVYX8XCR9ZQ";` // Unique identifier of the transaction to be refunded. refundTransactionRequest.TransactionID = "1GF88795WC5643301"; // Type of refund you are making. It is one of the following values: // // * `Full` - Full refund (default). // * `Partial` - Partial refund. // * `ExternalDispute` - External dispute. (Value available since version // 82.0) // * `Other` - Other type of refund. (Value available since version 82.0) refundTransactionRequest.RefundType = RefundType.PARTIAL; // `Refund amount`, which contains // // * `Currency Code` // * `Amount` // The amount is required if RefundType is Partial. // `Note: // If RefundType is Full, do not set the amount.` BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "1.00"); refundTransactionRequest.Amount = amount; refundTransaction.RefundTransactionRequest = refundTransactionRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the RefundTransaction method in service wrapper object responseRefundTransactionResponseType = service.RefundTransaction(refundTransaction); if (responseRefundTransactionResponseType != null) { // Response envelope acknowledgement string acknowledgement = "RefundTransaction API Operation - "; acknowledgement += responseRefundTransactionResponseType.Ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseRefundTransactionResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Unique transaction ID of the refund logger.Info("Refund Transaction ID : " + responseRefundTransactionResponseType.RefundTransactionID + "\n"); Console.WriteLine("Refund Transaction ID : " + responseRefundTransactionResponseType.RefundTransactionID + "\n"); } // # Error Values else { List<ErrorType> errorMessages = responseRefundTransactionResponseType.Errors; foreach (ErrorType error in errorMessages) { logger.Debug("API Error Message : " + error.LongMessage); Console.WriteLine("API Error Message : " + error.LongMessage + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message logger.Debug("Error Message : " + ex.Message); Console.WriteLine("Error Message : " + ex.Message); } return responseRefundTransactionResponseType; }