On this page, you can read how you can place a print order for a file which is not created yet and will be provided later. This applies for cases in which a file is dynamically created (i.e. based on user input). This process works as a combination of the print button and the print API.

1. Place async button

The first step is to place the ”asynchronous” button in your website. You can find a detailed description of this button in the button documentation in the section ”Hosting your own files without uploading”. Here’s an example for that button. Note there’s no data-offering nor data-publicationattribute.

<a title='Peecho' href='http://www.peecho.com/' data-width='216' data-height='279'
 data-pages='100' class='peecho-print-button' data-thumbnail='https://your/thumbnail/location'
 data-noprice='true' data-currency='EUR' data-reference='MERCHANTREFERENCE' data-locale='en_EN'>
Test button
2. Payment notification

When you or a customer clicks on the print button, they will be redirected to the Peecho checkout. In the checkout, they can specify the product details, shipping information and complete payment. When everything is done correctly, the customer will see a thank you page.

Meanwhile, the payment gateway will notify Peecho after payment confirmation, and Peecho will notify the merchant by issuing a GET request to the pingback URL you provide us, which should point to a location you have control over. The URL should have the following format:


%MERCHANTID% – a reference defined at your end which you can use to identify your order. You can specify this merchant id in the button-script when placing the order, in a variable called ‘data-reference’.

%PEECHOID% – unique order reference defined by Peecho.

%SECRET% – hash generated at our end. You can recreate the hash at your end to make sure nobody tampered with the data (optional).

At this stage, the order will be in the state “PENDING_COMPLETION” until you follow step 3.

3. Provide source file

In this last step you should provide a URL of the source file, so we can proceed with processing your order. This can be done at any time after your server receives our GET request (see above step). Take your time to prepare the file and then call this method:

POST /rest/order/set_source_url

Set the source URL of an order – only applicable for asynchronous source generation (if you generate a PDF after the order procedure has been completed).


orderIdYesThe Peecho order reference.
sourceURLYesThe full URL to the source document
merchantApiKeyYesUnique string identifier of the merchant.
secretYesBase64 encoded HMAC SHA1 Hash of externalOrderId + merchantReference + sourceUrl using your merchantSecretKey as HMAC-key
backgroundColorNoBackground color of spine.
textColorNoColor of text on spine.
textSizeNoSize of text on spine.
textCenterNoText in the center part spine.
textTopNoText in the top part spine.
textBottomNoText in the bottom part spine.
textFamilyNoFont of spine text. (Arial, DarkCourier, Georgia, GochiHand, Helvetica, Tahoma, TimesNewRoman, Verdana)
curl -v -d "orderId={yourExternalOrderId}&sourceUrl=https://dl.dropboxusercontent.com/u/5278037/mediamarkt.pdf&merchantApiKey={yourMerchantApiKey}&secret={generatedSecretHash}" "http://www.peecho.com/rest/order/set_source_url"
String secretKey = "merchantSecretKey";
String externalOrderId = "1234";
String merchantReference = "merchantReference";
String sourceUrl = "http://somesourceurl.com/a.pdf";
String data = externalOrderId + merchantReference + sourceUrl;
Mac m = Mac.getInstance("HmacSHA1");
m.init(new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA1"));
byte[] hash = m.doFinal(data.getBytes("UTF-8"));
String secret = new String(Base64.encodeBase64(hash));

 You get as result: MjavkJnEj5SrkHYWtO65KDWEw3M=
 (using org.apache.commons.codec.binary for base64 and javax.crypto for Mac).



This service either returns 'OK' or an error status.
Simple as that!
After completing these simple steps, your order will be processed, printed and shipped. You can read more about async print in this post on our blog. Do you need help with async print? Email us!