Ejemplo n.º 1
0
        private async Task HandleTextAsync(string replyToken, string userMessage, string userId)
        {
            userMessage = userMessage.ToLower().Replace(" ", "");
            if (userMessage == "チョコレート")
            {
                var reserve = new Reserve()
                {
                    ProductName    = "チョコレート",
                    Amount         = 1,
                    Currency       = Currency.JPY,
                    OrderId        = Guid.NewGuid().ToString(),
                    ConfirmUrl     = $"{appsettings.ServerUri}/api/linebot/confirm",
                    ConfirmUrlType = ConfirmUrlType.SERVER
                };

                var response = await payClient.ReserveAsync(reserve);

                // ユーザーの情報を設定
                reserve.Mid = userId;
                CacheService.Cache.Add(response.Info.TransactionId, reserve);
                var replyMessage = new TemplateMessage(
                    "Button Template",
                    new ButtonsTemplate(
                        text: $"{reserve.ProductName}を購入するには下記のボタンで決済に進んでください",
                        actions: new List <ITemplateAction> {
                    new UriTemplateAction("LINE Pay で決済", response.Info.PaymentUrl.Web)
                }));

                await messagingClient.ReplyMessageAsync(replyToken, new List <ISendMessage> {
                    replyMessage
                });
            }
        }
        public async Task <IActionResult> Reserve()
        {
            var reserveData = GetReserveData();
            var nonce       = Guid.NewGuid().ToString();
            var requestUrl  = "/v3/payments/request";
            var requestJson = JsonConverterFacade.SerializeObject(reserveData, _client.SerializerSettings);
            var signature   = _client.GetSignature((_config.ChannelSecret + requestUrl + requestJson + nonce), _config.ChannelSecret);

            var result = await _client.ReserveAsync(reserveData, nonce, signature);

            return(Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Reserve()
        {
            // 決済予約の作成
            var reserve = new Reserve()
            {
                ProductName = "チョコレート",
                Amount      = 1,
                Currency    = Currency.JPY,
                OrderId     = Guid.NewGuid().ToString(),
                ConfirmUrl  = $"{appsettings.ServerUri}/api/pay/confirm"
            };

            var response = await client.ReserveAsync(reserve);

            CacheService.Cache.Add(response.Info.TransactionId, reserve);

            return(Redirect(response.Info.PaymentUrl.Web));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Reserve(bool capture, PayType payType = PayType.NORMAL)
        {
            var reserve = new Reserve()
            {
                ProductName = "チョコレート",
                Amount      = 1,
                Currency    = Currency.JPY,
                OrderId     = Guid.NewGuid().ToString(),
                ConfirmUrl  = $"{configuration["ServerUri"]}/api/pay/confirm",
                CancelUrl   = $"{configuration["ServerUri"]}/api/pay/cancel",
                Capture     = capture,
                PayType     = payType
            };

            var response = await client.ReserveAsync(reserve);

            CacheService.Cache.Add(response.Info.TransactionId, reserve);

            return(Redirect(response.Info.PaymentUrl.Web));
        }