-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from EduardoKroetz/feature/payment
FEATURE: integração do sistema com os serviços do Stripe
- Loading branch information
Showing
109 changed files
with
4,074 additions
and
1,875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Hotel.Domain.DTOs; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Stripe; | ||
using Stripe.Checkout; | ||
|
||
namespace Hotel.Domain.Controllers; | ||
|
||
[ApiController] | ||
[Route("v1/payments")] | ||
public class PaymentController : ControllerBase | ||
{ | ||
[HttpPost("checkout/card/{priceId}")] | ||
public async Task<IActionResult> CreateCheckout([FromRoute] string priceId) | ||
{ | ||
if (string.IsNullOrEmpty(priceId)) | ||
{ | ||
return BadRequest(new Response("ID de preço inválido")); | ||
} | ||
|
||
var options = new SessionCreateOptions | ||
{ | ||
PaymentMethodTypes = new List<string> | ||
{ | ||
"card" | ||
}, | ||
|
||
LineItems = new List<SessionLineItemOptions> | ||
{ | ||
new SessionLineItemOptions | ||
{ | ||
Price = priceId, | ||
Quantity = 1, | ||
} | ||
}, | ||
Mode = "payment", | ||
SuccessUrl = "https://localhost:7100/success.html", | ||
CancelUrl = "https://localhost:7100/cancel.html" | ||
}; | ||
|
||
var service = new SessionService(); | ||
|
||
try | ||
{ | ||
var session = await service.CreateAsync(options); | ||
|
||
return Ok(new Response("Sessão criada com sucesso!", new { sessionId = session.Id })); | ||
} | ||
catch (StripeException) | ||
{ | ||
throw new StripeException("Algum erro ocorreu ao criar a sessão de pagamento"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Hotel.Domain.DTOs.PaymentDTOs; | ||
|
||
public record CardOptions(string TokenId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.