1

私のプロジェクトには、以下のコードに示す Paypal REST API が含まれています。

    private static string accessToken
    {
        get
        {
            string tokenAccess = new OAuthTokenCredential(ConfigManager.Instance.GetProperties()["ClientID"], ConfigManager.Instance.GetProperties()["ClientSecret"]).GetAccessToken();
            return tokenAccess;
        }
    }
    public ActionResult Pay(FormCollection form)
    {
        var appid = Guid.Parse(form["ApartId"]);
        var username = form["EmailAddress"];
        var price = form["Price"];
        var amounts = form["Amount"];
        var user = _bb.Users.Single(m => m.UserName == username);
        var genismodel = _bb.Aparts.Include("Reservations").Single(m => m.ApartID == appid);
        var reservasyon = new Reservation
            {
                ReservationStatus = false,
                ReservationNumber = "0123456877",
                DateForBegin = Convert.ToDateTime(form["BeginDate"]),
                DateForEnd = Convert.ToDateTime(form["EndDate"]),
                ReservationDate = DateTime.Now,
                UserID = user.UserID,
                ReservationTotal =Convert.ToDecimal(price),
                ReservationAmount = Convert.ToDecimal(amounts),
                ReservationType = "Paypal",
                ReservationState = ""

            };
        reservasyon.Aparts.Add(genismodel);
        _bb.Reservations.AddObject(reservasyon);
        _bb.SaveChanges();
        var reservid = reservasyon.ReservationID;
        int orderId = reservid;
        string requestUrl = Request.Url.OriginalString;
        string returnUrl = ConfigurationManager.AppSettings["ReturnURL"];
        string cancelUrl = ConfigurationManager.AppSettings["CancelURL"];
        var amount = amounts;
        var description = form["ApartName"];
        Payment pymnt = null;
        pymnt = CreatePayment(username, PaymentMethod.paypal, amount, description, returnUrl, cancelUrl);
        if (pymnt != null)
        {
            var pymntId = pymnt.id;
            var state = pymnt.state;
            var reservasyonum = _bb.Reservations.Single(m => m.ReservationID == reservid);
            reservasyonum.ReservationState = state;
            reservasyonum.ReservationNumber = pymntId;
            _bb.SaveChanges();
            var dredirectUrl = GetApprovalUrl(pymnt);
            return Redirect(dredirectUrl);
            
        }
        return View();
    }

そして問題はここから派生します:

    public Payment CreatePayment(string email, PaymentMethod paymntMethod, string orderAmount, string orderDescription, string returnUrl, string cancelUrl)
    {
        Payment pymnt = null;
        var amountDetails = new AmountDetails {subtotal = orderAmount};
        var amount = new Amount {currency = "USD"};
        var total = Convert.ToDouble(orderAmount);
        amount.total = total.ToString();
        amount.details = amountDetails;
        var redirectUrls = new RedirectUrls {return_url = returnUrl, cancel_url = cancelUrl};
        var transaction = new Transaction {amount = amount, description = orderDescription};
        var transactions = new List<Transaction> {transaction};
        var payer = new Payer {payment_method = paymntMethod.ToString()};
        var pyment = new Payment
            {
                intent = "sale",
                payer = payer,
                transactions = transactions,
                redirect_urls = redirectUrls
            };

        pymnt = pyment.Create(accessToken);
        return pymnt;
    }

payment.Create(accessToken) が呼び出されると、エラーは次のようになります。

コナム: PayPal.PayPalResource.ConfigureAndExecute[T](APIContext apiContext、HttpMethod httpMethod、文字列リソース、Dictionary2 headersMap、文字列 PayLoad)

コナム: PayPal.PayPalResource.ConfigureAndExecute[T](APIContext apiContext、HttpMethod httpMethod、文字列リソース、文字列 PayLoad)

コナム: PayPal.Api.Payments.Payment.Create(APIContext apiContext)

コナム: PayPal.Api.Payments.Payment.Create(String accessToken)

konum: Cozy.Controllers.ReservationController.CreatePayment(String email, PaymentMethod paymntMethod, String orderAmount, String orderDescription, String returnUrl, String cancelUrl) C:\Users\user\Documents\Projects\CozyLast\Cozy\Controllers\ReservationController.cs içinde:サティル 141

konum: Cozy.Controllers.ReservationController.Pay(FormCollection フォーム) C:\Users\user\Documents\Projects\CozyLast\Cozy\Controllers\ReservationController.cs içinde: satır 99

コナム: lambda_method(Closure, ControllerBase , Object[] )

konum: System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase コントローラー、Object[] パラメーター)

konum: System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 パラメーター)

konum: System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext、ActionDescriptor actionDescriptor、IDictionary 2 パラメーター)

konum:System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.b__41() konum:System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.b__7(IAsyncResult _) konum:System.Web.Mvc. Async.AsyncResultWrapper.WrappedAsyncResult 1.End() konum:System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) konum:System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.b__33() konum:System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.b__49()

なにが問題ですか?返信ありがとうございます。

4

0 に答える 0