The API mentioned in my first tutorial got taken down and so I had to do some updates. First, choose another 3rd party API. I currently am trying out HTML 2 PDF Rocket and modified my code a bit:
public async Task<FileStreamResult> PrintAsync(int id)
InvoiceVM invoiceVM = new InvoiceVM();
invoiceVM = invoiceRepository.Get(id);
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject(_hostingEnvironment.WebRootPath + "\\pdf\\")
var view = await engine.CompileRenderAsync("PDF.cshtml", invoiceVM);
string apiKey = "xxxxxxxxxxxxxxxxxxxx";
using (var client = new WebClient())
// Build the conversion options
NameValueCollection options = new NameValueCollection();
MemoryStream ms = new MemoryStream(client.UploadValues("http://api.html2pdfrocket.com/pdf", options));
return new FileStreamResult(ms, "application/pdf");
This is based directly off the HTML 2 Rocket documentation. For the rest of the code see the first tutorial.
I recently had an issue with printing a report to PDF using Microsoft Reporting Service and a RDLC file, etc. Something similar to this. Unfortunately, it worked great in development, but refused to work once deployed into Azure. No matter what I did, I could not duck the GDI errors I kept getting, and apparently this continues through a line of various PDF exporting extensions, all of which rely on GDI for export. Turns out, I’m not alone in facing this problem and so, I decided to find a solution.
My general idea was to use something to render my PDF view, send that view as one long html string to a free PDF microservice and get the PDF in return.…
TLDR: post IS successful. PayTrace, by design, returns a 400 error, which sets off exceptions in httpresponse. Solution: catch the exception and then continue deserializing your response.
I coded a few weeks ago a .NET post to the PayTrace API which helps me demo and test payment by credit card using client side encryption. The process more or less went like this:
- Create demo account as a merchant on Paytrace
- Download PEM key
- On submit of form with credit card information, an imported PayTraceJS library encrypts the card number and csc code
- Use the demo account’s username and password to submit a request for a token
- Submit transaction (which includes encrypted info as well as other required fields) using token and await response
A successful http response returns a status code of 200. I read it via stream, deserialize it using json into my CardResponse object (both successful and failure responses have the same design). Everything went great until I began testing rejected cards.…
This is a very basic tutorial on dealing with Payeezy, who’s documentation I found sometimes difficult. Some of this guidance, I only found in forum threads and so I document…
Get What You Need
- Merchant Demo account
- Developer Sandbox account
- Merchant Token (demo)
- API secret (sandbox)
- API key (sandbox
This year I am re-writing my previous payment solution (from PHP to .NET) and first on the project list is credit cards. We are using PayTrace and their client-side encryption as to not have to worry about PCI Compliance.
I’m to the point where I have a Pre-Payment model with all the fields needed to send via JSON. I also have a method to request a token for sending (uses demo username and pass) and a test PEM file I downloaded from the PayTrace site. I also got the webpage scanning credit cards, and I hit submit and.. I get this:
XML Parsing Error: no element found
This is appearing in the console of Inspector in Firefox. Turns out this a generic error Firefox throws out when it’s expending a file but gets nothing.
My path’s are correct, but the “public_key.pem” file is not attaching to my post. The problem? MIME-type.…
As I work toward syncing our as400 to our payment gateway, I’ve encountered an error both in PayTrace and Payeezy sample codes, generally when making a JSON post with Curl in PHP.
ssl certificate problem: self signed certificate in certificate chain
Almost ALL documentation / research on this suggests you turn off Curl verification (CURLOPT_SSL_VERIFYPEER off) and yes, it works, but it’s just not an option when I’m trying to secure my server for payment transactions.…