Photon Commerce API
  • Getting Started with the Photon Commerce API
    • Register a new account
    • Capture an invoice or receipt in real time
    • Confidence Scores & Coordinates
  • Update Document
    • Update Fields
    • Update Line Items
    • Add Line Item
    • Delete Line Item
  • Retrieve Data
  • Async API
  • Async API Webhook
  • Bank Transaction Categorization
  • Invoice Approvals
  • Status Codes
Powered by GitBook
On this page

Was this helpful?

Async API Webhook

To get the status of the document you submitted

To get updates on the status of the document you submitted, you can create a webhook using any external services that sends a POST request to the endpoint '/webhook' using your credentials and the photon_key of the document.

Fetch document status

POST https://api.photoncommerce.com/webhook

Retrieves the status of a specific document - if it is being processed or has already been processed.

Path Parameters

Name
Type
Description

photon_key

string

The name of the JSON file

Headers

Name
Type
Description

PASSWORD

string

The password for each account

SECRET-KEY

string

The secret key for each account

CLIENT-ID

string

Unique Client ID for each account

AUTHORIZATION

string

Pass your username and unique API key in the form "apikey <your-username>:<your api key>"

{
"data":
    {
    "Total":1871.8,
    "Balance_Due":1871.8,
    "Date":"2021-03-08",
    "Category":"General",
    "Invoice_Number":"1030",
    "Account_Number":"",
    "Bill_To_Name":"Kevin Condon",
    "Bill_To_Address":"San Francisco, CA",
    "Bill_To_Vat_Number":"",
    "Card_Number":"",
    "Cashback":0.0,
    "Created":"2021-06-22 04:10:21",
    "Currency_Code":"USD",
    "Discount":0.0,
    "Due_Date":"2021-03-08",
    "Payment_Terms":"Due upon Receipt",
    "Payment_Display_Name":"",
    "Payment_Type":"",
    "Phone_Number":"3108496500",
    "Reference_Number":"",
    "Service_End_Date":"",
    "Service_Start_Date":"",
    "Shipping":0.0,
    "Ship_To_Name":"",
    "Ship_To_Address":"",
    "Ship_Date":"",
    "Order_Date":"",
    "Pages":"1",
    "Delivery_Date":"",
    "Is_Duplicate":0,
    "Notes":"",
    "Subtotal":0.0,
    "Tax":0.0,
    "Tax_Lines":[],
    "Tip":0.0,
    "Tracking_Number":"",
    "Vat_Number":"",
    "Vendor_Account_Number":"",
    "Vendor_Bank_Name":"",
    "Vendor_Bank_Number":"",
    "Vendor_Bank_Swift":"",
    "PO_Number":"",
    "Vendor_Name":"Eins",
    "Vendor_Address":"13417 Contour Dr Sherman Oaks, CA 91423 US",
    "Vendor_ABN_Number":"",
    "Vendor_Email":"accounting@einsteam.com",
    "Vendor_Fax":"",
    "Vendor_IBAN":"",
    "Vendor_Phone":"3108496500",
    "Vendor_Raw_Name":"Eins",
    "Vendor_Type":"",
    "Vendor_Recipient":"",
    "Vendor_Address_Line":"13417 Contour Dr",
    "Vendor_City":"Sherman Oaks",
    "Vendor_State":"CA",
    "Vendor_Zipcode":"91423",
    "Bill_To_Recipient":"",
    "Bill_To_Address_Line":"",
    "Bill_To_City":"San Francisco",
    "Bill_To_State":"CA",
    "Bill_To_Zipcode":"",
    "Line_Items":[{"Line":1,"SKU":"","Date":"","Order":0,"Reference":"","Description":"Eins Team Hourly Consulting Service\nAttached\nis\nstatement of work\nbreaking down\nbilled hours for Feb\n15-Mar 6.","QTY":26.74,"Unit":"","Tax":0.0,"Tax_Rate":0.0,"Type":"service","Price":70.0,"Discount":0.0,"Amount":1871.8}],
    "Raw_Text":"Eins Team\n13417 Contour Dr\nSherman Oaks, CA 91423 US\n+1 3108496500\nsamstevens@einsteam.com\n\nINVOICE\n\nBILL TO\t\t\t\t\t\t\t\t\t\tINVOICE\t1030\nKevin Condon\t\t\t\t\t\t\t\t\t\tDATE\t03/08/2021\nSagetap\t\t\t\t\t\t\t\t\t\tTERMS\tDue on receipt\nSan Francisco, CA\t\t\t\t\t\t\t\t\tDUE DATE\t03/08/2021\n\nACTIVITY\t\t\t\tDESCRIPTION\t\tQTY\tRATE\t\t\tAMOUNT\nEins Team Hourly Consulting Service\tAttached is\t\t26.74\t70.00\t\t\t1,871.80\nstatement of work\nbreaking down\nbilled hours for Feb\n15-Mar 6.\n\nThank you for your business! All payments are final and non-refundable. If you\tBALANCE DUE\t\t\t\t\t$1,871.80\nhave any questions please contact accounting@einsteam.com\n\n\tPage 1 of 1",
    "All_Email_Addresses":"samstevens@einsteam.com,accounting@einsteam.com",
    "Document_Type":"Invoice",
    "Vendor_Country":"US",
    "photon_key":"data/app/2021-06-21/21-10-18_Eins_Team_Invoice_1030.json"
    },
"message": "success",
"status": "success"
}
import requests
headers = {
    'CLIENT-ID': '<your client id',
    'AUTHORIZATION': 'apikey <your username>:<your api key>',
    'PASSWORD':'<your password>',
    'SECRET-KEY':'<your secret key>'
}

response = requests.post('https://api.photoncommerce.com/webhook?photon_key={photon_key_here}', headers=headers)
curl -X POST -H "CLIENT-ID:<client-id>" -H "AUTHORIZATION:apikey <username>:<api-key>" -H 'PASSWORD:<password>' -H "SECRET-KEY:<secret-key>" "https://api.photoncommerce.com/webhook?photon_key=<photon_key of the file>"
var request = require('request');

var headers = {
    'CLIENT-ID': '<client-id>',
    'AUTHORIZATION': 'apikey <username>:<api-key>',
    'PASSWORD': '<password>',
    'SECRET-KEY': '<secret-key>'
};

var options = {
    url: 'https://api.photoncommerce.com/webhook?photon_key=<photon_key of the file>',
    method: 'POST',
    headers: headers
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

class Main {

	public static void main(String[] args) throws IOException {
		URL url = new URL("https://api.photoncommerce.com/webhook?photon_key=<photon_key of the file>");
		HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
		httpConn.setRequestMethod("POST");

		httpConn.setRequestProperty("CLIENT-ID", "<client-id>");
		httpConn.setRequestProperty("AUTHORIZATION", "apikey <username>:<api-key>");
		httpConn.setRequestProperty("PASSWORD", "<password>");
		httpConn.setRequestProperty("SECRET-KEY", "<secret-key>");

		InputStream responseStream = httpConn.getResponseCode() / 100 == 2
				? httpConn.getInputStream()
				: httpConn.getErrorStream();
		Scanner s = new Scanner(responseStream).useDelimiter("\\A");
		String response = s.hasNext() ? s.next() : "";
		System.out.println(response);
	}
}

In case the document is still being processed, Photon will return the following as the response: {"message": "The document you submitted is being processed.", "status": "success"}

PreviousAsync APINextBank Transaction Categorization

Last updated 3 years ago

Was this helpful?