Пример #1
0
        public IPaymentResponse DoExpressCheckoutPayment(NameValueCollection payPalResponse)
        {
            var response = new PayPalPaymentResponse(payPalResponse);

            parsePayPalAck(payPalResponse,
                           success: () =>
            {
                response.TransactionReference = payPalResponse["PAYMENTINFO_0_TRANSACTIONID"];

                var rawPaymentStatus = payPalResponse["PAYMENTINFO_0_PAYMENTSTATUS"];
                PayPalPaymentStatus paymentStatus;
                if (Enum.TryParse(rawPaymentStatus, true, out paymentStatus))
                {
                    response.Status = paymentStatus == PayPalPaymentStatus.Pending
                                              ? PaymentStatus.Pending
                                              : PaymentStatus.Successful;
                }
                else
                {
                    response.Status         = PaymentStatus.Failed;
                    response.FailureMessage = "An error occurred processing your PayPal payment.";
                }
            },
                           fail: message =>
            {
                response.Status          = PaymentStatus.Failed;
                response.IsSystemFailure = true;
                response.FailureMessage  = message;
            });

            return(response);
        }
Пример #2
0
        public IPaymentResponse DoExpressCheckoutPayment(NameValueCollection payPalResponse)
        {
            var response = new PayPalPaymentResponse(payPalResponse);

            parsePayPalAck(payPalResponse,
                success: () =>
                {
                    response.TransactionReference = payPalResponse["PAYMENTINFO_0_TRANSACTIONID"];

                    var rawPaymentStatus = payPalResponse["PAYMENTINFO_0_PAYMENTSTATUS"];
                    PayPalPaymentStatus paymentStatus;
                    if (Enum.TryParse(rawPaymentStatus, true, out paymentStatus))
                    {
                        response.Status = paymentStatus == PayPalPaymentStatus.Pending
                                              ? PaymentStatus.Pending
                                              : PaymentStatus.Successful;
                    }
                    else
                    {
                        response.Status = PaymentStatus.Failed;
                        response.FailureMessage = "An error occurred processing your PayPal payment.";
                    }
                },
                fail: message =>
                {
                    response.Status = PaymentStatus.Failed;
                    response.IsSystemFailure = true;
                    response.FailureMessage = message;
                });

            return response;
        }
Пример #3
0
        public IPaymentResponse MassPayment(NameValueCollection response)
        {
            var result = new PayPalPaymentResponse(response);

            parsePayPalAck(response,
                           success: () =>
            {
                result.Status = PaymentStatus.Successful;
            },
                           fail: message =>
            {
                result.FailureMessage  = message;
                result.Status          = PaymentStatus.Failed;
                result.IsSystemFailure = true;
            });

            return(result);
        }
Пример #4
0
        public IPaymentResponse DoExpressCheckoutPayment(NameValueCollection payPalResponse)
        {
            var response = new PayPalPaymentResponse(payPalResponse);

            parsePayPalAck(payPalResponse,
                           success: () =>
            {
                response.TransactionReference = payPalResponse["PAYMENTINFO_0_TRANSACTIONID"];

                var rawPaymentStatus = payPalResponse["PAYMENTINFO_0_PAYMENTSTATUS"];
                PayPalPaymentStatus paymentStatus;
                if (Enum.TryParse(rawPaymentStatus, true, out paymentStatus))
                {
                    response.Status = paymentStatus == PayPalPaymentStatus.Pending
                                              ? PaymentStatus.Pending
                                              : PaymentStatus.Successful;
                }
                else
                {
                    response.Status         = PaymentStatus.Failed;
                    response.FailureMessage = "An error occurred processing your PayPal payment.";
                }
                response.ErrorCode         = parseOptionalStringValueFromResponse("PAYMENTREQUEST_0_ERRORCODE", payPalResponse);
                response.ErrorShortMsg     = parseOptionalStringValueFromResponse("PAYMENTREQUEST_0_SHORTMESSAGE", payPalResponse);
                response.ErrorLongMsg      = parseOptionalStringValueFromResponse("PAYMENTREQUEST_0_LONGMESSAGE", payPalResponse);
                response.ErrorSeverityCode = parseOptionalStringValueFromResponse("PAYMENTREQUEST_0_SEVERITYCODE", payPalResponse);
            },
                           fail: message =>
            {
                response.Status          = PaymentStatus.Failed;
                response.IsSystemFailure = true;
                response.FailureMessage  = message;
            });

            return(response);
        }