/// <summary> /// Gets execution status of a payment by PayKey /// </summary> /// <param name="payKey"></param> /// <returns></returns> public PaymentExecStatusSEnum GetPaymentExecutionStatus(string payKey) { Check.Require(string.IsNullOrEmpty(payKey) == false, "PayPalService.GetPaymentStatus: PayKey is required."); PaymentDetailsRequest request = new PaymentDetailsRequest(new RequestEnvelope("en_US")); request.payKey = payKey; Dictionary <string, string> configurationMap = FWUtils.ConfigUtils.GetAppSettings().Paypal.GetAcctAndConfig(); AdaptivePaymentsService service = new AdaptivePaymentsService(configurationMap); PaymentDetailsResponse response = service.PaymentDetails(request); string ack = response.responseEnvelope.ack.ToString().Trim().ToUpper(); // if no error happened if (!ack.Equals(AckCode.FAILURE.ToString()) && !ack.Equals(AckCode.FAILUREWITHWARNING.ToString())) { PaymentExecStatusSEnum execStatus = new PaymentExecStatusSEnum(response.status); return(execStatus); } else { throw new UserException(GetPayPalErrorString(response.error)); } }
/** * AUTO_GENERATED */ public PaymentDetailsResponse PaymentDetails(PaymentDetailsRequest paymentDetailsRequest, string apiUserName) { string response = Call("PaymentDetails", paymentDetailsRequest.ToNVPString(""), apiUserName); NVPUtil util = new NVPUtil(); return(PaymentDetailsResponse.CreateInstance(util.ParseNVPString(response), "", -1)); }
/** * */ public PaymentDetailsResponse PaymentDetails(PaymentDetailsRequest PaymentDetailsRequest, string apiUsername) { string resp = call("PaymentDetails", PaymentDetailsRequest.toNVPString(""), apiUsername); NVPUtil util = new NVPUtil(); return(new PaymentDetailsResponse(util.parseNVPString(resp), "")); }
public TransactionPayment Post(PaymentDetailsRequest payment) { var transactionDetails = new TransactionPaymentDetails(payment); return(new TransactionPayment { TransactionId = transactionDetails.GetHashCode(), Payment = transactionDetails, Status = PaymentStatus.Success }); }
/// <summary> /// /// </summary> ///<param name="paymentDetailsRequest"></param> ///<param name="credential">An explicit ICredential object that you want to authenticate this call against</param> public PaymentDetailsResponse PaymentDetails(PaymentDetailsRequest paymentDetailsRequest, ICredential credential) { IAPICallPreHandler apiCallPreHandler = new PlatformAPICallPreHandler(this.config, paymentDetailsRequest.ToNVPString(string.Empty), ServiceName, "PaymentDetails", credential); ((PlatformAPICallPreHandler)apiCallPreHandler).SDKName = SDKName; ((PlatformAPICallPreHandler)apiCallPreHandler).SDKVersion = SDKVersion; ((PlatformAPICallPreHandler)apiCallPreHandler).PortName = "AdaptivePayments"; NVPUtil util = new NVPUtil(); return(PaymentDetailsResponse.CreateInstance(util.ParseNVPString(Call(apiCallPreHandler)), string.Empty, -1)); }
public async Task <HttpResponseMessage> SavePaymentDetails(PaymentDetailsRequest paymentDetailsRequest) { httpResponseMessage = new HttpResponseMessage(); if (paymentDetailsRequest != null && ModelState.IsValid) { var paymentDetailsResponse = await _IAccountService.SavePaymentDetails(paymentDetailsRequest); httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, paymentDetailsResponse); } else { httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, new { Message = CustomErrorMessages.INVALID_INPUTS, Success = false }); } return(httpResponseMessage); }
public IHttpActionResult RentSuccess([FromBody] PaymentDetailsRequest paymentDetailsRequest) { Payment paymentHistory = _paymentService.GetPaymentByPaymentId(paymentDetailsRequest.PaymentId); if (paymentHistory == null || paymentHistory.state != AppConstants.CreatedState) { return(BadRequest()); } PaymentRentInfo paymentDetails = _paymentService.GetPaymentRentInfoByPaymentId(paymentDetailsRequest.PaymentId); if (paymentDetails == null) { return(BadRequest()); } Car car = _carService.GetCarById(paymentDetails.CarId); if (car == null) { return(BadRequest()); } if (_carService.RentCar(car)) { try { car.RentedUntil = paymentDetails.RentedUntil; _userService.AddUserRentalHistory(User.Identity.GetUserId(), car); _paymentService.ExecutePayment(paymentDetailsRequest.PaymentId, paymentDetailsRequest.PayerId); string carObject = JsonConvert.SerializeObject(car, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); _carHub.Clients.All.carUpdated(carObject); return(Ok()); } catch (System.Exception) { return(InternalServerError()); } } return(BadRequest()); }
/// <summary> /// Handle PaymentDetails API call /// </summary> /// <param name="context"></param> private void PaymentDetails(HttpContext context) { NameValueCollection parameters = context.Request.Params; PaymentDetailsRequest req = new PaymentDetailsRequest(new RequestEnvelope("en_US")); // set optional parameters if (parameters["payKey"] != "") req.payKey = parameters["payKey"]; if (parameters["transactionId"] != "") req.transactionId = parameters["transactionId"]; if (parameters["trackingId"] != "") req.trackingId = parameters["trackingId"]; // All set. Fire the request AdaptivePaymentsService service = new AdaptivePaymentsService(); PaymentDetailsResponse resp = null; try { resp = service.PaymentDetails(req); } catch (System.Exception e) { context.Response.Write(e.Message); return; } // Display response values. Dictionary<string, string> keyResponseParams = new Dictionary<string, string>(); string redirectUrl = null; if (!(resp.responseEnvelope.ack == AckCode.FAILURE) && !(resp.responseEnvelope.ack == AckCode.FAILUREWITHWARNING)) { keyResponseParams.Add("Pay key", resp.payKey); keyResponseParams.Add("Payment execution status", resp.status); keyResponseParams.Add("Sender email", resp.senderEmail); } displayResponse(context, "PaymentDetails", keyResponseParams, service.getLastRequest(), service.getLastResponse(), resp.error, redirectUrl); }
public void ShouldReturnSameTransactionIdForSameDetails() { var sut = new PaymentController(); var details1 = new PaymentDetails() { Amount = 1, CardNumber = 1234123412341234, CCV = 123, Timestamp = DateTime.MaxValue }; var transaction1 = new PaymentDetailsRequest() { SupplierId = "123456", Payment = details1 }; var result1 = sut.Post(transaction1); var details2 = new PaymentDetails() { Amount = 1, CardNumber = 1234123412341234, CCV = 123, Timestamp = DateTime.MaxValue }; var transaction2 = new PaymentDetailsRequest() { SupplierId = "123456", Payment = details2 }; var result2 = sut.Post(transaction2); Assert.Equal(result1.TransactionId, result2.TransactionId); }
private static bool PaypalHandleBuyerPaidAndWeNeedToVerify(ITradelrRepository repository) { bool haveChanges = false; var paymentsNeededVerifying = repository.GetPayments(PaymentMethodType.Paypal, PaymentStatus.Charging); foreach (var payment in paymentsNeededVerifying) { var configurationMap = Configuration.GetAcctAndConfig(); var service = new AdaptivePaymentsService(configurationMap); var detailsRequest = new PaymentDetailsRequest { payKey = payment.redirectUrl.ToPayPalPayKey(), requestEnvelope = new RequestEnvelope { errorLanguage = "en_US" }, trackingId = payment.reference }; PaymentDetailsResponse resp = null; bool haveError = false; try { resp = service.PaymentDetails(detailsRequest); } catch (Exception ex) { var affectedInvoice = payment.order; Syslog.Write( string.Format( "Failed to process payment for order {0}, payment amount of {1} deleted", affectedInvoice.id, payment.paidAmount)); Syslog.Write(ex); haveError = true; } if (!haveError && resp.responseEnvelope.ack == AckCode.SUCCESS) { var transaction = new Transaction(payment.order, repository, null); switch (resp.status) { case "COMPLETED": transaction.UpdatePaymentStatus(payment, PaymentStatus.Accepted); transaction.AddPaidAmount(payment.paidAmount); // <------- order status is updated inside here // send download links if digital order if (transaction.HasDigitalOrderItems()) { transaction.SendDownloadLinksEmail(); } haveChanges = true; break; case "ERROR": transaction.UpdatePaymentStatus(payment, PaymentStatus.Declined); haveChanges = true; break; case "EXPIRED": repository.DeletePayment(payment); haveChanges = true; break; } } } return(haveChanges); }
private static bool checkPayPal() { if (!String.IsNullOrEmpty(SessionVariables.UserName)) { if (checkForUpdate()) { PaymentDetailsResponse responsePaymentDetails = new PaymentDetailsResponse(); try { // # PaymentDetailsRequest // The code for the language in which errors are returned RequestEnvelope envelopeRequest = new RequestEnvelope(); envelopeRequest.errorLanguage = "en_US"; // PaymentDetailsRequest which takes, // `Request Envelope` - Information common to each API operation, such // as the language in which an error message is returned. PaymentDetailsRequest requestPaymentDetails = new PaymentDetailsRequest(envelopeRequest); // You must specify either, // // * `Pay Key` - The pay key that identifies the payment for which you want to retrieve details. This is the pay key returned in the PayResponse message. // * `Transaction ID` - The PayPal transaction ID associated with the payment. The IPN message associated with the payment contains the transaction ID. // `payDetailsRequest.transactionId = transactionId` // * `Tracking ID` - The tracking ID that was specified for this payment in the PayRequest message. // `requestPaymentDetails.trackingId = trackingId` requestPaymentDetails.payKey = SessionVariables.paymentKey; // Create the service wrapper object to make the API call AdaptivePaymentsService service = new AdaptivePaymentsService(); // # API call // Invoke the PaymentDetails method in service wrapper object responsePaymentDetails = service.PaymentDetails(requestPaymentDetails); if (responsePaymentDetails != null) { // Response envelope acknowledgement string acknowledgement = "PaymentDetails API Operation - "; acknowledgement += responsePaymentDetails.responseEnvelope.ack.ToString(); Console.WriteLine(acknowledgement + "\n"); // # Success values if (responsePaymentDetails.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS")) { // The status of the payment. Possible values are: // // * CREATED - The payment request was received; funds will be // transferred once the payment is approved // * COMPLETED - The payment was successful // * INCOMPLETE - Some transfers succeeded and some failed for a // parallel payment or, for a delayed chained payment, secondary // receivers have not been paid // * ERROR - The payment failed and all attempted transfers failed // or all completed transfers were successfully reversed // * REVERSALERROR - One or more transfers failed when attempting // to reverse a payment // * PROCESSING - The payment is in progress // * PENDING - The payment is awaiting processing if (responsePaymentDetails.status == "COMPLETED") { updatePayTable(); return(true); } } // # Error Values else { return(false); //List<ErrorData> errorMessages = responsePaymentDetails.error; //foreach (ErrorData error in errorMessages) //{ //} } } } // # Exception log catch (System.Exception ex) { return(false); // Log the exception message } } else { return(false); } } return(false); }
public async Task <SavePaymentReponse> SavePaymentDetails(PaymentDetailsRequest paymentDetailsRequest) { return(await _IAccountRepository.SavePaymentDetails(paymentDetailsRequest)); }
/// <summary> /// /// </summary> ///<param name="paymentDetailsRequest"></param> public PaymentDetailsResponse PaymentDetails(PaymentDetailsRequest paymentDetailsRequest) { return(PaymentDetails(paymentDetailsRequest, (string)null)); }
public PaymentDetailsResponse PaymentDetails(PaymentDetailsRequest PaymentDetailsRequest) { return(PaymentDetails(PaymentDetailsRequest, null)); }