Last active
January 15, 2019 19:54
-
-
Save JuaniVeltri/6b58ad47a71840d6f679e6629e9c03af to your computer and use it in GitHub Desktop.
Creación de pago .NET
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using AdminLTE.Data; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using MercadoPago; | |
using MercadoPago.Resources; | |
using MercadoPago.DataStructures.Payment; | |
using MercadoPago.Common; | |
using Microsoft.AspNetCore.Authorization; | |
namespace AdminLTE.APIs | |
{ | |
[Route("api/[controller]")] | |
[ApiController] | |
[AllowAnonymous] | |
public class MPController : ControllerBase | |
{ | |
private readonly ApplicationDbContext db; | |
public MPController(ApplicationDbContext _context) | |
{ | |
db = _context; | |
} | |
// GET: api/MP | |
[HttpGet("",Name ="TryPayment")] | |
public async Task<IActionResult> TryPayment() | |
{ | |
//For Web-checkout: | |
MercadoPago.SDK.SetAccessToken("TEST-4123207277....-350922726"); | |
Payment payment = new Payment() | |
{ | |
TransactionAmount = float.Parse("100.0"), | |
Token = "2b00e16a09...a348399db4", | |
Description = "Ergonomic Silk Shirt", | |
PaymentMethodId = "visa", | |
Installments = 1, | |
Payer = new Payer() | |
{ | |
Email = "[email protected]" | |
} | |
}; | |
payment.Save(); //En esta linea se crashea | |
var status = payment.Status; | |
return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment