public TestServerPaymentSettingsResponse Post(TestPayPalProductionSettingsRequest request) { var response = new TestServerPaymentSettingsResponse { IsSuccessful = false, Message = "Paypal Production Credentials are invalid" }; try { if (_paylServiceFactory.GetInstance().TestCredentials(request.ClientCredentials, request.ServerCredentials, false)) { return(new TestServerPaymentSettingsResponse { IsSuccessful = true, Message = "Paypal Production Credentials are valid" }); } } catch (Exception e) { response.Message += "\n" + e.Message; } return(response); }
internal InitializePayPalCheckoutResponse InitializePayPalCheckoutIfNecessary( Guid accountId, bool isPrepaid, Guid orderId, Contract.Requests.CreateOrderRequest request, decimal bookingFees, string companyKey, CreateReportOrder createReportOrder, string absoluteRequestUri) { if (isPrepaid && request.Settings.ChargeTypeId == ChargeTypes.PayPal.Id) { var paypalWebPaymentResponse = _payPalServiceFactory.GetInstance(companyKey).InitializeWebPayment(accountId, orderId, absoluteRequestUri, request.Estimate.Price, bookingFees, request.ClientLanguageCode); if (paypalWebPaymentResponse.IsSuccessful) { return(paypalWebPaymentResponse); } var createOrderException = new HttpError(HttpStatusCode.BadRequest, ErrorCode.CreateOrder_RuleDisable.ToString(), paypalWebPaymentResponse.Message); createReportOrder.Error = createOrderException.ToString(); _commandBus.Send(createReportOrder); throw createOrderException; } return(null); }
/// <summary> /// If we ever need to support fees or CoF network payment with other providers than CMT/RideLinq, /// we'll need to keep track of on which company the pre-auth has been made and handle it properly because, as of today, orderPaymentDetail is unique by order. /// </summary> public PreAuthorizePaymentResponse PreAuthorize(string companyKey, Guid orderId, AccountDetail account, decimal amountToPreAuthorize, bool isReAuth = false, bool isSettlingOverduePayment = false, bool isForPrepaid = false, string cvv = null) { // we pass the orderId just in case it might exist but most of the time it won't since preauth is done before order creation if (IsPayPal(account.Id, orderId, isForPrepaid)) { return(_payPalServiceFactory.GetInstance(companyKey).PreAuthorize(account.Id, orderId, account.Email, amountToPreAuthorize, isReAuth)); } // if we call preauth more than once, the cvv will be null but since preauth already passed once, it's safe to assume it's ok var response = GetInstance(companyKey).PreAuthorize(companyKey, orderId, account, amountToPreAuthorize, isReAuth, isSettlingOverduePayment, false, cvv); // when CMT has preauth enabled, remove this ugly code and delete temp info for everyone // we can't delete here for CMT because we need the cvv info in the CommitPayment method if (GetPaymentSettings(companyKey).PaymentMode != PaymentMethod.Cmt && GetPaymentSettings(companyKey).PaymentMode != PaymentMethod.RideLinqCmt) { // delete the cvv stored in database once preauth is done, doesn't fail if it doesn't exist _orderDao.DeleteTemporaryPaymentInfo(orderId); } return(response); }
public object Get(ExecuteWebPaymentAndProceedWithOrder request) { _logger.LogMessage("ExecuteWebPaymentAndProceedWithOrder request : " + request.ToJson()); var temporaryInfo = _orderDao.GetTemporaryInfo(request.OrderId); var orderInfo = JsonSerializer.DeserializeFromString <TemporaryOrderCreationInfo>(temporaryInfo.SerializedOrderCreationInfo); if (request.Cancel || orderInfo == null) { var clientLanguageCode = orderInfo == null ? SupportedLanguages.en.ToString() : orderInfo.Request.ClientLanguageCode; _commandBus.Send(new CancelOrderBecauseOfError { OrderId = request.OrderId, ErrorDescription = _resources.Get("CannotCreateOrder_PrepaidPayPalPaymentCancelled", clientLanguageCode) }); } else { // Execute PayPal payment var response = _payPalServiceFactory.GetInstance(orderInfo.BestAvailableCompany.CompanyKey).ExecuteWebPayment(request.PayerId, request.PaymentId); if (response.IsSuccessful) { var account = _accountDao.FindById(orderInfo.AccountId); var tipPercentage = account.DefaultTipPercent ?? _serverSettings.ServerData.DefaultTipPercentage; var tipAmount = FareHelper.CalculateTipAmount(orderInfo.Request.Fare.AmountInclTax, tipPercentage); _commandBus.Send(new MarkPrepaidOrderAsSuccessful { OrderId = request.OrderId, TotalAmount = orderInfo.Request.Fare.AmountInclTax + tipAmount, MeterAmount = orderInfo.Request.Fare.AmountExclTax, TaxAmount = orderInfo.Request.Fare.TaxAmount, TipAmount = tipAmount, TransactionId = response.TransactionId, Provider = PaymentProvider.PayPal, Type = PaymentType.PayPal }); } else { _commandBus.Send(new CancelOrderBecauseOfError { OrderId = request.OrderId, ErrorDescription = response.Message }); } } // Build url used to redirect the web client to the booking status view string baseUrl; if (_serverSettings.ServerData.BaseUrl.HasValue()) { baseUrl = _serverSettings.ServerData.BaseUrl; } else { baseUrl = Request.AbsoluteUri .Replace(Request.PathInfo, string.Empty) .Replace(GetAppHost().Config.ServiceStackHandlerFactoryPath, string.Empty) .Replace(Request.QueryString.ToString(), string.Empty) .Replace("?", string.Empty); } var redirectUrl = string.Format("{0}#status/{1}", baseUrl, request.OrderId); return(new HttpResult { StatusCode = HttpStatusCode.Redirect, Headers = { { HttpHeaders.Location, redirectUrl } } }); }
public BasePaymentResponse Post(LinkPayPalAccountRequest request) { var session = this.GetSession(); return(_payPalServiceFactory.GetInstance().LinkAccount(new Guid(session.UserAuthId), request.AuthCode)); }