コード例 #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
ファイル: PayPalResponseParser.cs プロジェクト: tjaart/Moolah
        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
ファイル: PayPalResponseParser.cs プロジェクト: elacy/Moolah
        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);
        }