// # GetExpressCheckout API Operation // The GetExpressCheckoutDetails API operation obtains information about an Express Checkout transaction public GetExpressCheckoutDetailsResponseType GetExpressCheckoutDetailsAPIOperation() { // Create the GetExpressCheckoutDetailsResponseType object GetExpressCheckoutDetailsResponseType responseGetExpressCheckoutDetailsResponseType = new GetExpressCheckoutDetailsResponseType(); try { // Create the GetExpressCheckoutDetailsReq object GetExpressCheckoutDetailsReq getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq(); // A timestamped token, the value of which was returned by `SetExpressCheckout` response GetExpressCheckoutDetailsRequestType getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType("EC-11U13522TP7143059"); getExpressCheckoutDetails.GetExpressCheckoutDetailsRequest = getExpressCheckoutDetailsRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the GetExpressCheckoutDetails method in service wrapper object responseGetExpressCheckoutDetailsResponseType = service.GetExpressCheckoutDetails(getExpressCheckoutDetails); if (responseGetExpressCheckoutDetailsResponseType != null) { // Response envelope acknowledgement string acknowledgement = "GetExpressCheckoutDetails API Operation - "; acknowledgement += responseGetExpressCheckoutDetailsResponseType.Ack.ToString(); logger.Info(acknowledgement + "\n"); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseGetExpressCheckoutDetailsResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Unique PayPal Customer Account identification number. This // value will be null unless you authorize the payment by // redirecting to PayPal after `SetExpressCheckout` call. logger.Info("Payer ID : " + responseGetExpressCheckoutDetailsResponseType.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID + "\n"); Console.WriteLine("Payer ID : " + responseGetExpressCheckoutDetailsResponseType.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID + "\n"); } // # Error Values else { List<ErrorType> errorMessages = responseGetExpressCheckoutDetailsResponseType.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 responseGetExpressCheckoutDetailsResponseType; }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetExpressCheckoutDetailsRequestType request = new GetExpressCheckoutDetailsRequestType(); // (Required) A timestamped token, the value of which was returned by SetExpressCheckout response. // Character length and limitations: 20 single-byte characters request.Token = token.Value; // Invoke the API GetExpressCheckoutDetailsReq wrapper = new GetExpressCheckoutDetailsReq(); wrapper.GetExpressCheckoutDetailsRequest = 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 GetExpressCheckoutDetails method in service wrapper object GetExpressCheckoutDetailsResponseType ecResponse = service.GetExpressCheckoutDetails(wrapper); // Check for API return status setKeyResponseObjects(service, ecResponse); }
protected void Submit_Click(object sender, EventArgs e) { // Create request object GetExpressCheckoutDetailsRequestType request = new GetExpressCheckoutDetailsRequestType(); request.Token = token.Value; // Invoke the API GetExpressCheckoutDetailsReq wrapper = new GetExpressCheckoutDetailsReq(); wrapper.GetExpressCheckoutDetailsRequest = request; PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); GetExpressCheckoutDetailsResponseType ecResponse = service.GetExpressCheckoutDetails(wrapper); // Check for API return status setKeyResponseObjects(service, ecResponse); }
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); }
// # GetExpressCheckout API Operation // The GetExpressCheckoutDetails API operation obtains information about an Express Checkout transaction public GetExpressCheckoutDetailsResponseType GetExpressCheckoutDetailsAPIOperation() { // Create the GetExpressCheckoutDetailsResponseType object GetExpressCheckoutDetailsResponseType responseGetExpressCheckoutDetailsResponseType = new GetExpressCheckoutDetailsResponseType(); try { // Create the GetExpressCheckoutDetailsReq object GetExpressCheckoutDetailsReq getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq(); // A timestamped token, the value of which was returned by `SetExpressCheckout` response GetExpressCheckoutDetailsRequestType getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType("EC-3PG29673CT337061M"); getExpressCheckoutDetails.GetExpressCheckoutDetailsRequest = getExpressCheckoutDetailsRequest; var config = new Dictionary<string, string> { {"mode", "sandbox"}, {"account1.apiUsername", "konstantin_merchant_api1.scandiaconsulting.com"}, {"account1.apiPassword", "1398157263"}, {"account1.apiSignature", "AFcWxV21C7fd0v3bYYYRCpSSRl31AlRjlcug7qV.VXWV14E1KtmQPsPL"} }; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(config); // # API call // Invoke the GetExpressCheckoutDetails method in service wrapper object responseGetExpressCheckoutDetailsResponseType = service.GetExpressCheckoutDetails(getExpressCheckoutDetails); if (responseGetExpressCheckoutDetailsResponseType != null) { // Response envelope acknowledgement string acknowledgement = "GetExpressCheckoutDetails API Operation - "; acknowledgement += responseGetExpressCheckoutDetailsResponseType.Ack.ToString(); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responseGetExpressCheckoutDetailsResponseType.Ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // Unique PayPal Customer Account identification number. This // value will be null unless you authorize the payment by // redirecting to PayPal after `SetExpressCheckout` call. Console.WriteLine("Payer ID : " + responseGetExpressCheckoutDetailsResponseType.GetExpressCheckoutDetailsResponseDetails.PayerInfo .PayerID + "\n"); } // # Error Values else { List<ErrorType> errorMessages = responseGetExpressCheckoutDetailsResponseType.Errors; foreach (ErrorType error in errorMessages) { Console.WriteLine("API Error Message : " + error.LongMessage + "\n"); } } } } // # Exception log catch (System.Exception ex) { // Log the exception message Console.WriteLine("Error Message : " + ex.Message); } return responseGetExpressCheckoutDetailsResponseType; }
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; }
// # GetExpressCheckout API Operation // The GetExpressCheckoutDetails API operation obtains information about an Express Checkout transaction public GetExpressCheckoutDetailsResponseType GetExpressCheckoutDetails(string token) { // Create the GetExpressCheckoutDetailsResponseType object GetExpressCheckoutDetailsResponseType responseGetExpressCheckoutDetailsResponseType = new GetExpressCheckoutDetailsResponseType(); try { // Create the GetExpressCheckoutDetailsReq object GetExpressCheckoutDetailsReq getExpressCheckoutDetails = new GetExpressCheckoutDetailsReq(); // A timestamped token, the value of which was returned by `SetExpressCheckout` response GetExpressCheckoutDetailsRequestType getExpressCheckoutDetailsRequest = new GetExpressCheckoutDetailsRequestType(token); getExpressCheckoutDetails.GetExpressCheckoutDetailsRequest = getExpressCheckoutDetailsRequest; // Create the service wrapper object to make the API call PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(); // # API call // Invoke the GetExpressCheckoutDetails method in service wrapper object responseGetExpressCheckoutDetailsResponseType = service.GetExpressCheckoutDetails(getExpressCheckoutDetails); } // # Exception log catch (System.Exception ex) { // Log the exception message levent.Level = LogLevel.Error; levent.Message = "Logon failed for PaypalExpressCheckout: " + ex.Message; log.Log(levent); } return responseGetExpressCheckoutDetailsResponseType; }
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; BookingProvider.AcceptInvoice(Convert.ToInt32(context.Order)); } } } } else { context.Errors.Add(PaymentStrings.PaymentCancelled); } return base.View("_ProcessingResult", context); }