本文整理匯總了C#中PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService.DoExpressCheckoutPayment方法的典型用法代碼示例。如果您正苦於以下問題:C# PayPalAPIInterfaceServiceService.DoExpressCheckoutPayment方法的具體用法?C# PayPalAPIInterfaceServiceService.DoExpressCheckoutPayment怎麽用?C# PayPalAPIInterfaceServiceService.DoExpressCheckoutPayment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PayPal.PayPalAPIInterfaceService.PayPalAPIInterfaceServiceService
的用法示例。
在下文中一共展示了PayPalAPIInterfaceServiceService.DoExpressCheckoutPayment方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Submit_Click
protected void Submit_Click(object sender, EventArgs e)
{
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
GetExpressCheckoutDetailsReq getECWrapper = new GetExpressCheckoutDetailsReq();
getECWrapper.GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token.Value);
GetExpressCheckoutDetailsResponseType getECResponse = service.GetExpressCheckoutDetails(getECWrapper);
// Create request object
DoExpressCheckoutPaymentRequestType request = new DoExpressCheckoutPaymentRequestType();
DoExpressCheckoutPaymentRequestDetailsType requestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
request.DoExpressCheckoutPaymentRequestDetails = requestDetails;
requestDetails.PaymentDetails = getECResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails;
requestDetails.Token = token.Value;
requestDetails.PayerID = payerId.Value;
requestDetails.PaymentAction = (PaymentActionCodeType)
Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue);
// Invoke the API
DoExpressCheckoutPaymentReq wrapper = new DoExpressCheckoutPaymentReq();
wrapper.DoExpressCheckoutPaymentRequest = request;
DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(wrapper);
// Check for API return status
setKeyResponseObjects(service, doECResponse);
}
示例2: ComplitePayment
public IPaymentResult ComplitePayment(IInvoice invoice, IPayment payment, string token, string payerId)
{
var config = new Dictionary<string, string>
{
{"mode", "sandbox"},
{"account1.apiUsername", _settings.ApiUsername},
{"account1.apiPassword", _settings.ApiPassword},
{"account1.apiSignature", _settings.ApiSignature}
};
var service = new PayPalAPIInterfaceServiceService(config);
var getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq
{
GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token)
};
var expressCheckoutDetailsResponse = service.GetExpressCheckoutDetails(getExpressCheckoutDetails);
if (expressCheckoutDetailsResponse != null)
{
if (expressCheckoutDetailsResponse.Ack == AckCodeType.SUCCESS)
{
// do express checkout
var doExpressCheckoutPayment = new DoExpressCheckoutPaymentReq();
var doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType
{
Token = token,
PayerID = payerId,
PaymentDetails = new List<PaymentDetailsType> {GetPaymentDetails(invoice)}
};
var doExpressCheckoutPaymentRequest =
new DoExpressCheckoutPaymentRequestType(doExpressCheckoutPaymentRequestDetails);
doExpressCheckoutPayment.DoExpressCheckoutPaymentRequest = doExpressCheckoutPaymentRequest;
var doExpressCheckoutPaymentResponse = service.DoExpressCheckoutPayment(doExpressCheckoutPayment);
if (doExpressCheckoutPaymentResponse != null)
{
if (doExpressCheckoutPaymentResponse.Ack == AckCodeType.SUCCESS)
{
payment.Authorized = true;
payment.Collected = true;
return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, true);
}
}
}
}
return new PaymentResult(Attempt<IPayment>.Succeed(payment), invoice, false);
}
示例3: Submit_Click
protected void Submit_Click(object sender, EventArgs e)
{
// 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);
GetExpressCheckoutDetailsReq getECWrapper = new GetExpressCheckoutDetailsReq();
// (Required) A timestamped token, the value of which was returned by SetExpressCheckout response.
// Character length and limitations: 20 single-byte characters
getECWrapper.GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token.Value);
// # API call
// Invoke the GetExpressCheckoutDetails method in service wrapper object
GetExpressCheckoutDetailsResponseType getECResponse = service.GetExpressCheckoutDetails(getECWrapper);
// Create request object
DoExpressCheckoutPaymentRequestType request = new DoExpressCheckoutPaymentRequestType();
DoExpressCheckoutPaymentRequestDetailsType requestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
request.DoExpressCheckoutPaymentRequestDetails = requestDetails;
requestDetails.PaymentDetails = getECResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails;
// (Required) The timestamped token value that was returned in the SetExpressCheckout response and passed in the GetExpressCheckoutDetails request.
requestDetails.Token = token.Value;
// (Required) Unique PayPal buyer account identification number as returned in the GetExpressCheckoutDetails response
requestDetails.PayerID = payerId.Value;
// (Required) How you want to obtain payment. It is one of the following values:
// * Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
// * Order – This payment is an order authorization subject to settlement with PayPal Authorization and Capture.
// * Sale – This is a final sale for which you are requesting payment.
// Note: You cannot set this value to Sale in the SetExpressCheckout request and then change this value to Authorization in the DoExpressCheckoutPayment request.
requestDetails.PaymentAction = (PaymentActionCodeType)
Enum.Parse(typeof(PaymentActionCodeType), paymentAction.SelectedValue);
// Invoke the API
DoExpressCheckoutPaymentReq wrapper = new DoExpressCheckoutPaymentReq();
wrapper.DoExpressCheckoutPaymentRequest = request;
// # API call
// Invoke the DoExpressCheckoutPayment method in service wrapper object
DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(wrapper);
// Check for API return status
setKeyResponseObjects(service, doECResponse);
}
示例4: DoExpressCheckout
public DoExpressCheckoutPaymentResponseType DoExpressCheckout(HttpResponseBase response, string token)
{
var getCheckoutRequest = new GetExpressCheckoutDetailsRequestType();
getCheckoutRequest.Token = token;
var getCheckOutInfo = new GetExpressCheckoutDetailsReq();
getCheckOutInfo.GetExpressCheckoutDetailsRequest = getCheckoutRequest;
var service = new PayPalAPIInterfaceServiceService();
var getResponse = service.GetExpressCheckoutDetails(getCheckOutInfo);
var doRequest = new DoExpressCheckoutPaymentRequestType();
var requestInfo = new DoExpressCheckoutPaymentRequestDetailsType();
doRequest.DoExpressCheckoutPaymentRequestDetails = requestInfo;
requestInfo.PaymentDetails = getResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails;
requestInfo.Token = token;
requestInfo.PayerID = getResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID;
requestInfo.PaymentAction = PaymentActionCodeType.SALE;
var wrapper = new DoExpressCheckoutPaymentReq();
wrapper.DoExpressCheckoutPaymentRequest = doRequest;
return service.DoExpressCheckoutPayment(wrapper);
}
示例5: ProcessPayment
public string ProcessPayment(string token, string PayerID)
{
string result = "success";
GetExpressCheckoutDetailsRequestType request = new GetExpressCheckoutDetailsRequestType();
request.Version = "104.0";
request.Token = token;
GetExpressCheckoutDetailsReq wrapper = new GetExpressCheckoutDetailsReq();
wrapper.GetExpressCheckoutDetailsRequest = request;
Dictionary<string, string> sdkConfig = new Dictionary<string, string>();
sdkConfig.Add("mode", appMode);
sdkConfig.Add("account1.apiUsername", username);
sdkConfig.Add("account1.apiPassword", password);
sdkConfig.Add("account1.apiSignature", signature);
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(sdkConfig);
GetExpressCheckoutDetailsResponseType ecResponse = service.GetExpressCheckoutDetails(wrapper);
PaymentDetailsType paymentDetail = new PaymentDetailsType();
paymentDetail.NotifyURL = "http://replaceIpnUrl.com";
paymentDetail.PaymentAction = (PaymentActionCodeType)EnumUtils.GetValue("Sale", typeof(PaymentActionCodeType));
paymentDetail.OrderTotal = new BasicAmountType((CurrencyCodeType)EnumUtils.GetValue("USD", typeof(CurrencyCodeType)), this.TotalPrice);
paymentDetail.OrderDescription = PaypalComment;
List<PaymentDetailsType> paymentDetails = new List<PaymentDetailsType>();
paymentDetails.Add(paymentDetail);
DoExpressCheckoutPaymentRequestType request2 = new DoExpressCheckoutPaymentRequestType();
request.Version = "104.0";
DoExpressCheckoutPaymentRequestDetailsType requestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
requestDetails.PaymentDetails = paymentDetails;
requestDetails.Token = token;
requestDetails.PayerID = PayerID;
request2.DoExpressCheckoutPaymentRequestDetails = requestDetails;
DoExpressCheckoutPaymentReq wrapper2 = new DoExpressCheckoutPaymentReq();
wrapper2.DoExpressCheckoutPaymentRequest = request2;
Dictionary<string, string> sdkConfig2 = new Dictionary<string, string>();
sdkConfig2.Add("mode", appMode);
sdkConfig2.Add("account1.apiUsername", username);
sdkConfig2.Add("account1.apiPassword", password);
sdkConfig2.Add("account1.apiSignature", signature);
PayPalAPIInterfaceServiceService service2 = new PayPalAPIInterfaceServiceService(sdkConfig);
DoExpressCheckoutPaymentResponseType doECResponse = service2.DoExpressCheckoutPayment(wrapper2);
this.PaymentConfirmationID = doECResponse.CorrelationID;
return result;
}
示例6: ProcessPayment
/// <summary>
/// Processes the payment. Can be used for both positive and negative transactions.
/// </summary>
/// <param name="payment">The payment.</param>
/// <param name="message">The message.</param>
/// <returns></returns>
public override bool ProcessPayment(Payment payment, ref string message)
{
try
{
payment.Status = PaymentStatus.Processing.ToString();
//ContractId - used as paypal PayerID
var payerId = payment.ContractId;
//ValidationCode - used as paypal token
var token = payment.AuthorizationCode;
if (string.IsNullOrEmpty(payerId) || string.IsNullOrEmpty(token))
{
return false;
}
// Create the PayPalAPIInterfaceServiceService service object to make the API call
var service = new PayPalAPIInterfaceServiceService((Dictionary<string, string>)Settings);
var getECWrapper = new GetExpressCheckoutDetailsReq();
getECWrapper.GetExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token);
var getECResponse = service.GetExpressCheckoutDetails(getECWrapper);
var request = new DoExpressCheckoutPaymentRequestType();
var requestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
request.DoExpressCheckoutPaymentRequestDetails = requestDetails;
requestDetails.PaymentDetails = getECResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails;
requestDetails.Token = token;
requestDetails.PayerID = payerId;
requestDetails.PaymentAction = PaymentActionCodeType.SALE;
// Invoke the API
var wrapper = new DoExpressCheckoutPaymentReq();
wrapper.DoExpressCheckoutPaymentRequest = request;
var doECResponse = service.DoExpressCheckoutPayment(wrapper);
if (doECResponse.Ack.Equals(AckCodeType.FAILURE) || (doECResponse.Errors != null && doECResponse.Errors.Count > 0))
{
return false;
}
else
{
switch (doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PaymentStatus)
{
case PaymentStatusCodeType.COMPLETED:
payment.Status = PaymentStatus.Completed.ToString();
break;
case PaymentStatusCodeType.INPROGRESS:
payment.Status = PaymentStatus.Processing.ToString();
break;
case PaymentStatusCodeType.DENIED:
payment.Status = PaymentStatus.Denied.ToString();
break;
case PaymentStatusCodeType.FAILED:
payment.Status = PaymentStatus.Failed.ToString();
break;
default:
payment.Status =
doECResponse.DoExpressCheckoutPaymentResponseDetails.PaymentInfo[0].PaymentStatus
.ToString();
break;
}
}
}
catch (Exception ex)
{
message = ex.Message;
return false;
}
return true;
}
示例7: PostProcessPayment
public override PostProcessPaymentResult PostProcessPayment(PostProcessPaymentEvaluationContext context)
{
var retVal = new PostProcessPaymentResult();
if (context == null && context.Payment == null)
throw new ArgumentNullException("paymentEvaluationContext");
if (context.Order == null)
throw new NullReferenceException("no order with this id");
retVal.OrderId = context.Order.Id;
if (!(context.Store != null && !string.IsNullOrEmpty(context.Store.Url)))
throw new NullReferenceException("no store with this id");
var config = GetConfigMap(context.Store);
var service = new PayPalAPIInterfaceServiceService(config);
var getExpressCheckoutDetailsRequest = GetGetExpressCheckoutDetailsRequest(context.OuterId);
try
{
var response = service.GetExpressCheckoutDetails(getExpressCheckoutDetailsRequest);
CheckResponse(response);
var status = response.GetExpressCheckoutDetailsResponseDetails.CheckoutStatus;
if (!status.Equals("PaymentActionCompleted"))
{
var doExpressCheckoutPaymentRequest = GetDoExpressCheckoutPaymentRequest(response, context.OuterId);
var doResponse = service.DoExpressCheckoutPayment(doExpressCheckoutPaymentRequest);
CheckResponse(doResponse);
response = service.GetExpressCheckoutDetails(getExpressCheckoutDetailsRequest);
status = response.GetExpressCheckoutDetailsResponseDetails.CheckoutStatus;
}
if (status.Equals("PaymentActionCompleted"))
{
retVal.IsSuccess = true;
retVal.NewPaymentStatus = PaymentStatus.Paid;
}
}
catch (System.Exception ex)
{
retVal.Error = ex.Message;
retVal.NewPaymentStatus = PaymentStatus.Pending;
}
return retVal;
}
示例8: DoExpressCheckoutPayment
// # DoExpressCheckoutPayment API Operation
// The DoExpressCheckoutPayment API operation completes an Express Checkout transaction.
// If you set up a billing agreement in your SetExpressCheckout API call,
// the billing agreement is created when you call the DoExpressCheckoutPayment API operation.
public DoExpressCheckoutPaymentResponseType DoExpressCheckoutPayment(string token, string payerId, string payment)
{
// Create the DoExpressCheckoutPaymentResponseType object
DoExpressCheckoutPaymentResponseType responseDoExpressCheckoutPaymentResponseType = new DoExpressCheckoutPaymentResponseType();
try
{
// Create the DoExpressCheckoutPaymentReq object
DoExpressCheckoutPaymentReq doExpressCheckoutPayment = new DoExpressCheckoutPaymentReq();
DoExpressCheckoutPaymentRequestDetailsType doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
// The timestamped token value that was returned in the
// `SetExpressCheckout` response and passed in the
// `GetExpressCheckoutDetails` request.
doExpressCheckoutPaymentRequestDetails.Token = token;
// Unique paypal buyer account identification number as returned in
// `GetExpressCheckoutDetails` Response
doExpressCheckoutPaymentRequestDetails.PayerID = payerId;
// # Payment Information
// list of information about the payment
List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();
// information about the first payment
PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
// Total cost of the transaction to the buyer. If shipping cost and tax
// charges are known, include them in this value. If not, this value
// should be the current sub-total of the order.
//
// If the transaction includes one or more one-time purchases, this field must be equal to
// the sum of the purchases. Set this field to 0 if the transaction does
// not include a one-time purchase such as when you set up a billing
// agreement for a recurring payment that is not immediately charged.
// When the field is set to 0, purchase-specific fields are ignored.
//
// * `Currency Code` - You must set the currencyID attribute to one of the
// 3-character currency codes for any of the supported PayPal
// currencies.
// * `Amount`
BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, payment);
paymentDetails1.OrderTotal = orderTotal1;
paymentDetails1.OrderDescription = System.Web.Configuration.WebConfigurationManager.AppSettings["PaypalDescription"];
// How you want to obtain payment. When implementing parallel payments,
// this field is required and must be set to `Order`. When implementing
// digital goods, this field is required and must be set to `Sale`. If the
// transaction does not include a one-time purchase, this field is
// ignored. It is one of the following values:
//
// * `Sale` - This is a final sale for which you are requesting payment
// (default).
// * `Authorization` - This payment is a basic authorization subject to
// settlement with PayPal Authorization and Capture.
// * `Order` - This payment is an order authorization subject to
// settlement with PayPal Authorization and Capture.
// Note:
// You cannot set this field to Sale in SetExpressCheckout request and
// then change the value to Authorization or Order in the
// DoExpressCheckoutPayment request. If you set the field to
// Authorization or Order in SetExpressCheckout, you may set the field
// to Sale.
paymentDetails1.PaymentAction = PaymentActionCodeType.SALE;
// Unique identifier for the merchant. For parallel payments, this field
// is required and must contain the Payer Id or the email address of the
// merchant.
SellerDetailsType sellerDetails1 = new SellerDetailsType();
sellerDetails1.PayPalAccountID = System.Web.Configuration.WebConfigurationManager.AppSettings["PayPalAccountID"];
paymentDetails1.SellerDetails = sellerDetails1;
// A unique identifier of the specific payment request, which is
// required for parallel payments.
paymentDetails1.PaymentRequestID = "PaymentRequest1";
// A unique identifier of the specific payment request, which is
// required for parallel payments.
paymentDetailsList.Add(paymentDetails1);
doExpressCheckoutPaymentRequestDetails.PaymentDetails = paymentDetailsList;
DoExpressCheckoutPaymentRequestType doExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType(doExpressCheckoutPaymentRequestDetails);
doExpressCheckoutPayment.DoExpressCheckoutPaymentRequest = doExpressCheckoutPaymentRequest;
// Create the service wrapper object to make the API call
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService();
// # API call
// Invoke the DoExpressCheckoutPayment method in service wrapper object
responseDoExpressCheckoutPaymentResponseType = service.DoExpressCheckoutPayment(doExpressCheckoutPayment);
return responseDoExpressCheckoutPaymentResponseType;
}
// # Exception log
catch (System.Exception ex)
//.........這裏部分代碼省略.........
示例9: DoExpressCheckoutPaymentAPIOperation
// # DoExpressCheckoutPayment API Operation
// The DoExpressCheckoutPayment API operation completes an Express Checkout transaction.
// If you set up a billing agreement in your SetExpressCheckout API call,
// the billing agreement is created when you call the DoExpressCheckoutPayment API operation.
public DoExpressCheckoutPaymentResponseType DoExpressCheckoutPaymentAPIOperation()
{
// Create the DoExpressCheckoutPaymentResponseType object
DoExpressCheckoutPaymentResponseType responseDoExpressCheckoutPaymentResponseType = new DoExpressCheckoutPaymentResponseType();
try
{
// Create the DoExpressCheckoutPaymentReq object
DoExpressCheckoutPaymentReq doExpressCheckoutPayment = new DoExpressCheckoutPaymentReq();
DoExpressCheckoutPaymentRequestDetailsType doExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
// The timestamped token value that was returned in the
// `SetExpressCheckout` response and passed in the
// `GetExpressCheckoutDetails` request.
doExpressCheckoutPaymentRequestDetails.Token = "EC-2XW434901C650622T";
// Unique paypal buyer account identification number as returned in
// `GetExpressCheckoutDetails` Response
doExpressCheckoutPaymentRequestDetails.PayerID = "A9BVYX8XCR9ZQ";
// # Payment Information
// list of information about the payment
List<PaymentDetailsType> paymentDetailsList = new List<PaymentDetailsType>();
// information about the first payment
PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
// Total cost of the transaction to the buyer. If shipping cost and tax
// charges are known, include them in this value. If not, this value
// should be the current sub-total of the order.
//
// If the transaction includes one or more one-time purchases, this field must be equal to
// the sum of the purchases. Set this field to 0 if the transaction does
// not include a one-time purchase such as when you set up a billing
// agreement for a recurring payment that is not immediately charged.
// When the field is set to 0, purchase-specific fields are ignored.
//
// * `Currency Code` - You must set the currencyID attribute to one of the
// 3-character currency codes for any of the supported PayPal
// currencies.
// * `Amount`
BasicAmountType orderTotal1 = new BasicAmountType(CurrencyCodeType.USD, "2.00");
paymentDetails1.OrderTotal = orderTotal1;
// How you want to obtain payment. When implementing parallel payments,
// this field is required and must be set to `Order`. When implementing
// digital goods, this field is required and must be set to `Sale`. If the
// transaction does not include a one-time purchase, this field is
// ignored. It is one of the following values:
//
// * `Sale` - This is a final sale for which you are requesting payment
// (default).
// * `Authorization` - This payment is a basic authorization subject to
// settlement with PayPal Authorization and Capture.
// * `Order` - This payment is an order authorization subject to
// settlement with PayPal Authorization and Capture.
// Note:
// You cannot set this field to Sale in SetExpressCheckout request and
// then change the value to Authorization or Order in the
// DoExpressCheckoutPayment request. If you set the field to
// Authorization or Order in SetExpressCheckout, you may set the field
// to Sale.
paymentDetails1.PaymentAction = PaymentActionCodeType.ORDER;
// Unique identifier for the merchant. For parallel payments, this field
// is required and must contain the Payer Id or the email address of the
// merchant.
SellerDetailsType sellerDetails1 = new SellerDetailsType();
sellerDetails1.PayPalAccountID = "[email protected]";
paymentDetails1.SellerDetails = sellerDetails1;
// A unique identifier of the specific payment request, which is
// required for parallel payments.
paymentDetails1.PaymentRequestID = "PaymentRequest1";
// information about the second payment
PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
// Total cost of the transaction to the buyer. If shipping cost and tax
// charges are known, include them in this value. If not, this value
// should be the current sub-total of the order.
//
// If the transaction includes one or more one-time purchases, this field must be equal to
// the sum of the purchases. Set this field to 0 if the transaction does
// not include a one-time purchase such as when you set up a billing
// agreement for a recurring payment that is not immediately charged.
// When the field is set to 0, purchase-specific fields are ignored.
//
// * `Currency Code` - You must set the currencyID attribute to one of the
// 3-character currency codes for any of the supported PayPal
// currencies.
// * `Amount`
BasicAmountType orderTotal2 = new BasicAmountType(CurrencyCodeType.USD, "4.00");
paymentDetails2.OrderTotal = orderTotal2;
// How you want to obtain payment. When implementing parallel payments,
//.........這裏部分代碼省略.........
示例10: PostProcessPayment
public override PostProcessPaymentResult PostProcessPayment(PostProcessPaymentEvaluationContext context)
{
if (context.Order == null)
throw new ArgumentNullException("context.Order is null");
if (context.Payment == null)
throw new ArgumentNullException("context.Payment is null");
if (context.Store == null)
throw new ArgumentNullException("context.Store is null");
if (string.IsNullOrEmpty(context.Store.Url))
throw new NullReferenceException("url of store not set");
var retVal = new PostProcessPaymentResult();
retVal.OrderId = context.Order.Id;
var config = GetConfigMap();
var service = new PayPalAPIInterfaceServiceService(config);
var getExpressCheckoutDetailsRequest = GetGetExpressCheckoutDetailsRequest(context.OuterId);
try
{
var response = service.GetExpressCheckoutDetails(getExpressCheckoutDetailsRequest);
CheckResponse(response);
var status = response.GetExpressCheckoutDetailsResponseDetails.CheckoutStatus;
if (!status.Equals("PaymentActionCompleted"))
{
var doExpressCheckoutPaymentRequest = GetDoExpressCheckoutPaymentRequest(response, context.OuterId);
var doResponse = service.DoExpressCheckoutPayment(doExpressCheckoutPaymentRequest);
CheckResponse(doResponse);
response = service.GetExpressCheckoutDetails(getExpressCheckoutDetailsRequest);
status = response.GetExpressCheckoutDetailsResponseDetails.CheckoutStatus;
}
if (status.Equals("PaymentActionCompleted"))
{
retVal.IsSuccess = true;
retVal.OuterId = response.GetExpressCheckoutDetailsResponseDetails.PaymentDetails[0].TransactionId;
if(PaypalPaymentActionType == PaymentActionCodeType.AUTHORIZATION)
{
retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Authorized;
context.Payment.OuterId = retVal.OuterId;
context.Payment.AuthorizedDate = DateTime.UtcNow;
}
else if (PaypalPaymentActionType == PaymentActionCodeType.SALE)
{
retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Paid;
context.Payment.OuterId = retVal.OuterId;
context.Payment.IsApproved = true;
context.Payment.CapturedDate = DateTime.UtcNow;
}
}
else
{
retVal.ErrorMessage = "Payment process not successfully ends";
}
}
catch (System.Exception ex)
{
retVal.ErrorMessage = ex.Message;
}
return retVal;
}
示例11: DoExpressCheckoutForParallelPayment
/// <summary>
/// Handles DoExpressCheckoutForParallelPayments
/// </summary>
/// <param name="contextHttp"></param>
private void DoExpressCheckoutForParallelPayment(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);
DoExpressCheckoutPaymentRequestType doCheckoutPaymentRequestType = new DoExpressCheckoutPaymentRequestType();
DoExpressCheckoutPaymentRequestDetailsType details = new DoExpressCheckoutPaymentRequestDetailsType();
// A timestamped token by which you identify to PayPal that you are processing
// this payment with Express Checkout. The token expires after three hours.
// If you set the token in the SetExpressCheckout request, the value of the token
// in the response is identical to the value in the request.
// Character length and limitations: 20 single-byte characters
details.Token = parameters["token"];
// Unique PayPal Customer Account identification number.
// Character length and limitations: 13 single-byte alphanumeric characters
details.PayerID = parameters["payerID"];
// (Optional) How you want to obtain payment. If the transaction does not include a one-time purchase, this field is ignored.
// It is one of the following values:
// Sale – This is a final sale for which you are requesting payment (default).
// Authorization – This payment is a basic authorization subject to settlement with PayPal Authorization and Capture.
// Order – This payment is an order authorization subject to settlement with PayPal Authorization and Capture.
// Note:
// You cannot set this field to Sale in SetExpressCheckout request and then change
// this value to Authorization or Order in the DoExpressCheckoutPayment request.
// If you set the field to Authorization or Order in SetExpressCheckout, you may set the field to Sale.
// Character length and limitations: Up to 13 single-byte alphabetic characters
// This field is deprecated. Use PaymentAction in PaymentDetailsType instead.
details.PaymentAction = (PaymentActionCodeType)Enum.Parse(typeof(PaymentActionCodeType), parameters["paymentType"]);
PaymentDetailsType paymentDetails1 = new PaymentDetailsType();
BasicAmountType orderTotal1 = new BasicAmountType();
orderTotal1.value = parameters["orderTotal"];
//PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
orderTotal1.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
// (Required) The total cost of the transaction to the buyer.
// If shipping cost (not applicable to digital goods) and tax charges are known,
// include them in this value. If not, this value should be the current sub-total
// of the order. If the transaction includes one or more one-time purchases, this
// field must be equal to the sum of the purchases. Set this field to 0 if the
// transaction does not include a one-time purchase such as when you set up a
// billing agreement for a recurring payment that is not immediately charged.
// When the field is set to 0, purchase-specific fields are ignored.
// For digital goods, the following must be true:
// total cost > 0
// total cost <= total cost passed in the call to SetExpressCheckout
// Note:
// You must set the currencyID attribute to one of the 3-character currency codes
// for any of the supported PayPal currencies.
// When multiple payments are passed in one transaction, all of the payments must
// have the same currency code.
// Character length and limitations: Value is a positive number which cannot
// exceed $10,000 USD in any currency. It includes no currency symbol.
// It must have 2 decimal places, the decimal separator must be a period (.),
// and the optional thousands separator must be a comma (,).
paymentDetails1.OrderTotal = orderTotal1;
SellerDetailsType sellerDetailsType1 = new SellerDetailsType();
sellerDetailsType1.PayPalAccountID = parameters["receiverEmail_0"];
paymentDetails1.PaymentRequestID = parameters["paymentRequestID_0"];
paymentDetails1.SellerDetails = sellerDetailsType1;
PaymentDetailsType paymentDetails2 = new PaymentDetailsType();
BasicAmountType orderTotal2 = new BasicAmountType();
orderTotal2.value = parameters["orderTotal"];
//PayPal uses 3-character ISO-4217 codes for specifying currencies in fields and variables.
orderTotal2.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), parameters["currencyCode"]);
// (Required) The total cost of the transaction to the buyer.
// If shipping cost (not applicable to digital goods) and tax charges are known,
// include them in this value. If not, this value should be the current sub-total
// of the order. If the transaction includes one or more one-time purchases, this
// field must be equal to the sum of the purchases. Set this field to 0 if the
// transaction does not include a one-time purchase such as when you set up a
// billing agreement for a recurring payment that is not immediately charged.
// When the field is set to 0, purchase-specific fields are ignored.
// For digital goods, the following must be true:
// total cost > 0
// total cost <= total cost passed in the call to SetExpressCheckout
// Note:
// You must set the currencyID attribute to one of the 3-character currency codes
// for any of the supported PayPal currencies.
// When multiple payments are passed in one transaction, all of the payments must
//.........這裏部分代碼省略.........
示例12: ProcessingResult_PayPal
private ActionResult ProcessingResult_PayPal(ProcessingResultModel model)
{
if (model == null)
{
throw new System.ArgumentNullException("model");
}
PaymentResultContext context = new PaymentResultContext();
context.Order = model.order;
if (model.success == true)
{
if (model.token == null)
{
throw new System.ArgumentNullException("token");
}
if (model.payerID == null)
{
throw new System.ArgumentNullException("payerID");
}
GetExpressCheckoutDetailsRequestType request = new GetExpressCheckoutDetailsRequestType();
request.Version = "104.0";
request.Token = model.token;
GetExpressCheckoutDetailsReq wrapper = new GetExpressCheckoutDetailsReq();
wrapper.GetExpressCheckoutDetailsRequest = request;
System.Collections.Generic.Dictionary<string, string> config = PaymentController.PayPal_CreateConfig();
PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(config);
GetExpressCheckoutDetailsResponseType ecResponse = service.GetExpressCheckoutDetails(wrapper);
if (ecResponse == null)
{
throw new System.Exception("checkout details result is null");
}
if (ecResponse.Errors != null && ecResponse.Errors.Count > 0)
{
ecResponse.Errors.ForEach(delegate (ErrorType m)
{
context.Errors.Add(m.LongMessage);
});
}
if (ecResponse.Ack == AckCodeType.SUCCESS || ecResponse.Ack == AckCodeType.SUCCESSWITHWARNING)
{
GetExpressCheckoutDetailsResponseDetailsType details = ecResponse.GetExpressCheckoutDetailsResponseDetails;
if (details == null)
{
throw new System.Exception("details object is null");
}
if (string.IsNullOrEmpty(details.InvoiceID))
{
throw new System.Exception("invoiceID not found");
}
if (details.PaymentDetails == null)
{
throw new System.Exception("payment details is null");
}
System.Collections.Generic.List<PaymentDetailsType> paymentDetails = new System.Collections.Generic.List<PaymentDetailsType>();
foreach (PaymentDetailsType payment in details.PaymentDetails)
{
paymentDetails.Add(new PaymentDetailsType
{
NotifyURL = null,
PaymentAction = payment.PaymentAction,
OrderTotal = payment.OrderTotal
});
}
DoExpressCheckoutPaymentRequestType paymentRequest = new DoExpressCheckoutPaymentRequestType();
paymentRequest.Version = "104.0";
paymentRequest.DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType
{
PaymentDetails = paymentDetails,
Token = model.token,
PayerID = model.payerID
};
DoExpressCheckoutPaymentResponseType doECResponse = service.DoExpressCheckoutPayment(new DoExpressCheckoutPaymentReq
{
DoExpressCheckoutPaymentRequest = paymentRequest
});
if (doECResponse == null)
{
throw new System.Exception("payment result is null");
}
if (doECResponse.Errors != null && doECResponse.Errors.Count > 0)
{
doECResponse.Errors.ForEach(delegate (ErrorType m)
{
context.Errors.Add(m.LongMessage);
});
}
if (doECResponse.Ack == AckCodeType.SUCCESS || doECResponse.Ack == AckCodeType.SUCCESSWITHWARNING)
{
ConfirmInvoiceResult invoiceResult = BookingProvider.ConfirmInvoice(details.InvoiceID.Trim());
Tracing.DataTrace.TraceEvent(TraceEventType.Information, 0, "PAYPAL transaction: invoice: '{0}', invoice confirmation: '{1}'", new object[]
{
details.InvoiceID,
invoiceResult.IsSuccess ? "SUCCESS" : "FAILED"
});
if (!invoiceResult.IsSuccess)
{
context.Errors.Add(string.Format("invoice confirmation error: {0}", invoiceResult.ErrorMessage));
}
else
{
context.Success = true;
//.........這裏部分代碼省略.........