本文整理匯總了C#中PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService.DoCapture方法的典型用法代碼示例。如果您正苦於以下問題:C# PayPalAPIInterfaceServiceService.DoCapture方法的具體用法?C# PayPalAPIInterfaceServiceService.DoCapture怎麽用?C# PayPalAPIInterfaceServiceService.DoCapture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService
的用法示例。
在下文中一共展示了PayPalAPIInterfaceServiceService.DoCapture方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Submit_Click
protected void Submit_Click(object sender, EventArgs e)
{
// Create request object
DoCaptureRequestType request =
new DoCaptureRequestType();
request.AuthorizationID = authorizationId.Value;
CurrencyCodeType currency = (CurrencyCodeType)
Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
request.Amount = new BasicAmountType(currency, amount.Value);
if (completeType.SelectedIndex != 0)
{
request.CompleteType = (CompleteCodeType)
Enum.Parse(typeof(CompleteCodeType), completeType.SelectedValue);
}
if (note.Value != "")
{
request.Note = note.Value;
}
if (invoiceId.Value != "")
{
request.InvoiceID = invoiceId.Value;
}
if (softDescriptor.Value != "")
{
request.Descriptor = softDescriptor.Value;
}
// Invoke the API
DoCaptureReq wrapper = new DoCaptureReq();
wrapper.DoCaptureRequest = request;
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
DoCaptureResponseType doCaptureResponse =
service.DoCapture(wrapper);
// Check for API return status
setKeyResponseObjects(service, doCaptureResponse);
}
示例2: CaptureOrder
public ActionResult CaptureOrder(string authorizationId)
{
var service = new PayPalAPIInterfaceServiceService();
var request = new GetTransactionDetailsReq
{
GetTransactionDetailsRequest = new GetTransactionDetailsRequestType
{
TransactionID = authorizationId
}
};
var transactionDetailsResponse = service.GetTransactionDetails(request);
if (transactionDetailsResponse.Ack == AckCodeType.SUCCESS)
{
//if(transactionDetailsResponse.PaymentTransactionDetails.PaymentInfo.PaymentStatus == PaymentStatusCodeType.)
var captureRequest = new DoCaptureReq
{
DoCaptureRequest = new DoCaptureRequestType
{
AuthorizationID = authorizationId,
Amount = transactionDetailsResponse.PaymentTransactionDetails.PaymentInfo.GrossAmount
}
};
var captureResponse = service.DoCapture(captureRequest);
if (captureResponse.Ack == AckCodeType.SUCCESS)
{
return RedirectToAction("OrderSuccessful", new { transactionId = captureResponse.DoCaptureResponseDetails.PaymentInfo.TransactionID });
}
else
{
foreach (var error in captureResponse.Errors)
{
ModelState.AddModelError("__FORM", error.LongMessage);
}
}
}
else
{
foreach (var error in transactionDetailsResponse.Errors)
{
ModelState.AddModelError("__FORM", error.LongMessage);
}
}
return View("Error");
}
示例3: Submit_Click
protected void Submit_Click(object sender, EventArgs e)
{
// Create request object
DoCaptureRequestType request =
new DoCaptureRequestType();
// (Required) Authorization identification number of the payment you want to capture. This is the transaction ID returned from DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For point-of-sale transactions, this is the transaction ID returned by the CheckOut call when the payment action is Authorization.
request.AuthorizationID = authorizationId.Value;
// (Required) Amount to capture.
// Note: You must set the currencyID attribute to one of the three-character currency codes for any of the supported PayPal currencies.
CurrencyCodeType currency = (CurrencyCodeType)
Enum.Parse(typeof(CurrencyCodeType), currencyCode.SelectedValue);
request.Amount = new BasicAmountType(currency, amount.Value);
// (Required) Indicates whether or not this is your last capture. It is one of the following values:
// * Complete – This is the last capture you intend to make.
// * NotComplete – You intend to make additional captures.
if (completeType.SelectedIndex != 0)
{
request.CompleteType = (CompleteCodeType)
Enum.Parse(typeof(CompleteCodeType), completeType.SelectedValue);
}
// (Optional) An informational note about this settlement that is displayed to the buyer in email and in their transaction history.
if (note.Value != string.Empty)
{
request.Note = note.Value;
}
// (Optional) Your invoice number or other identification number that is displayed to you and to the buyer in their transaction history. The value is recorded only if the authorization you are capturing is an Express Checkout order authorization.
// Note: This value on DoCapture overwrites a value previously set on DoAuthorization.
if (invoiceId.Value != string.Empty)
{
request.InvoiceID = invoiceId.Value;
}
// (Optional) Per transaction description of the payment that is passed to the buyer's credit card statement.
//If you provide a value in this field, the full descriptor displayed on the buyer's statement has the following format:
//<PP * | PAYPAL *><Merchant descriptor as set in the Payment Receiving Preferences><1 space><soft descriptor>
//Character length and limitations: The soft descriptor can contain only the following characters:
//Alphanumeric characters
//- (dash)
//* (asterisk)
//. (period)
//{space}
//If you pass any other characters (such as ","), PayPal returns an error code.
//The soft descriptor does not include the phone number, which can be toggled between your customer service number and PayPal's Customer Service number.
//The maximum length of the soft descriptor is 22 characters. Of this, the PayPal prefix uses either 4 or 8 characters of the data format. Thus, the maximum length of the soft descriptor information that you can pass in this field is:
//22 - len(<PP * | PAYPAL *>) - len(<Descriptor set in Payment Receiving Preferences> + 1)
//For example, assume the following conditions:
//The PayPal prefix toggle is set to PAYPAL * in PayPal's administration tools.
//The merchant descriptor set in the Payment Receiving Preferences is set to EBAY.
//The soft descriptor is passed in as JanesFlowerGifts LLC.
//The resulting descriptor string on the credit card is:
//PAYPAL *EBAY JanesFlow
if (softDescriptor.Value != string.Empty)
{
request.Descriptor = softDescriptor.Value;
}
// Invoke the API
DoCaptureReq wrapper = new DoCaptureReq();
wrapper.DoCaptureRequest = 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 DoCapture method in service wrapper object
DoCaptureResponseType doCaptureResponse =
service.DoCapture(wrapper);
// Check for API return status
setKeyResponseObjects(service, doCaptureResponse);
}
示例4: DoCaptureAPIOperation
// # DoCapture API Operation
// Captures an authorized payment.
public DoCaptureResponseType DoCaptureAPIOperation()
{
// Create the DoCaptureResponseType object
DoCaptureResponseType responseDoCaptureResponseType = new DoCaptureResponseType();
try
{
// Create the DoCapture object
DoCaptureReq doCapture = new DoCaptureReq();
// `Amount` to capture which takes mandatory params:
//
// * `currencyCode`
// * `amount`
BasicAmountType amount = new BasicAmountType(CurrencyCodeType.USD, "4.00");
// `DoCaptureRequest` which takes mandatory params:
//
// * `Authorization ID` - Authorization identification number of the
// payment you want to capture. This is the transaction ID returned from
// DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
// point-of-sale transactions, this is the transaction ID returned by
// the CheckOut call when the payment action is Authorization.
// * `amount` - Amount to capture
// * `CompleteCode` - Indicates whether or not this is your last capture.
// It is one of the following values:
// * Complete – This is the last capture you intend to make.
// * NotComplete – You intend to make additional captures.
// `Note:
// If Complete, any remaining amount of the original authorized
// transaction is automatically voided and all remaining open
// authorizations are voided.`
DoCaptureRequestType doCaptureRequest = new DoCaptureRequestType("O-4VR15106P7416533H", amount, CompleteCodeType.NOTCOMPLETE);
doCapture.DoCaptureRequest = doCaptureRequest;
// Create the service wrapper object to make the API call
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
// # API call
// Invoke the DoCapture method in service wrapper object
responseDoCaptureResponseType = service.DoCapture(doCapture);
if (responseDoCaptureResponseType != null)
{
// Response envelope acknowledgement
string acknowledgement = "DoCapture API Operation - ";
acknowledgement += responseDoCaptureResponseType.Ack.ToString();
logger.Info(acknowledgement + "\n");
Console.WriteLine(acknowledgement + "\n");
// # Success values
if (responseDoCaptureResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
{
// Authorization identification number
logger.Info("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");
Console.WriteLine("Authorization ID : " + responseDoCaptureResponseType.DoCaptureResponseDetails.AuthorizationID + "\n");
}
// # Error Values
else
{
List<ErrorType> errorMessages = responseDoCaptureResponseType.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 responseDoCaptureResponseType;
}
示例5: CaptureProcessPayment
public override CaptureProcessPaymentResult CaptureProcessPayment(CaptureProcessPaymentEvaluationContext context)
{
if (context == null || context.Payment == null)
throw new ArgumentNullException("paymentEvaluationContext");
CaptureProcessPaymentResult retVal = new CaptureProcessPaymentResult();
if (!context.Payment.IsApproved && (context.Payment.PaymentStatus == PaymentStatus.Authorized || context.Payment.PaymentStatus == PaymentStatus.Cancelled))
{
try
{
var config = GetConfigMap();
var service = new PayPalAPIInterfaceServiceService(config);
DoCaptureReq doCaptureRequest = GetDoCaptureRequest(context.Payment);
var doCaptureResponse = service.DoCapture(doCaptureRequest);
CheckResponse(doCaptureResponse);
if(doCaptureResponse.DoCaptureResponseDetails.PaymentInfo.PaymentStatus == PaymentStatusCodeType.COMPLETED)
{
retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Paid;
context.Payment.CapturedDate = DateTime.UtcNow;
context.Payment.IsApproved = true;
retVal.IsSuccess = true;
}
}
catch(Exception ex)
{
retVal.ErrorMessage = ex.Message;
}
}
return retVal;
}
示例6: DoCapture
/// <summary>
/// Handles DoCapture
/// </summary>
/// <param name="contextHttp"></param>
private void DoCapture(HttpContext contextHttp)
{
NameValueCollection parameters = contextHttp.Request.Params;
// 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();
// Creating service wrapper object to make an API call by loading configuration map.
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);
// ## DoCaptureReq
DoCaptureReq req = new DoCaptureReq();
// 'Amount' to capture which takes mandatory params:
//
// * 'currencyCode'
// * 'amount'
BasicAmountType amount = new BasicAmountType(((CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"])), parameters["amt"]);
// 'DoCaptureRequest' which takes mandatory params:
//
// * 'Authorization ID' - Authorization identification number of the
// payment you want to capture. This is the transaction ID returned from
// DoExpressCheckoutPayment, DoDirectPayment, or CheckOut. For
// point-of-sale transactions, this is the transaction ID returned by
// the CheckOut call when the payment action is Authorization.
// * 'amount' - Amount to capture
// * 'CompleteCode' - Indicates whether or not this is your last capture.
// It is one of the following values:
// * Complete – This is the last capture you intend to make.
// * NotComplete – You intend to make additional captures.
// 'Note:
// If Complete, any remaining amount of the original authorized
// transaction is automatically voided and all remaining open
// authorizations are voided.'
DoCaptureRequestType reqType = new DoCaptureRequestType
(
parameters["authID"],
amount,
(CompleteCodeType)Enum.Parse(typeof(CompleteCodeType), parameters["completeCodeType"])
);
req.DoCaptureRequest = reqType;
DoCaptureResponseType response = null;
try
{
response = service.DoCapture(req);
}
catch (System.Exception ex)
{
contextHttp.Response.Write(ex.StackTrace);
return;
}
Dictionary<string, string> responseValues = new Dictionary<string, string>();
string redirectUrl = null;
responseValues.Add("Acknowledgement", response.Ack.ToString().Trim().ToUpper());
Display(contextHttp, "DoCapture", "DoCapture", responseValues, service.getLastRequest(), service.getLastResponse(), response.Errors, redirectUrl);
}