Jetpay Developer Guide
...
Collect payment method at chec...
EFT checkout example
2 min
this example walks through a full end to end eft payment flow it demonstrates how to create a contact, create a debit, securely collect and attach a bank account, and then pay the debit use this as a reference implementation to understand how the pieces fit together in a real checkout experience flow diagram sequencediagram participant backend as platform backend participant frontend as platform frontend actor customer participant jetpay as jetpay api backend >>jetpay create contact jetpay >>backend contact id backend >>jetpay create debit jetpay >>backend debit transaction id frontend >>customer collect bank account details customer >>frontend submit bank details frontend >>backend bank account data backend >>jetpay create bank account jetpay >>backend bank account id backend >>jetpay pay debit jetpay >>backend debit status code sample \# \# configuration \# base url="https //extapi demo jetpay baselinepayments com" api token="\<your api token>" \# \# 1 create contact \# curl x put "$base url/contact" \\ h "authorization bearer $api token" \\ h "content type application/json" \\ d '{ "email" "jane\@example com", "name" "jane doe", "tags" \[], "language" "en" }' \# → save the returned contact id (e g , contact 123) \# \# 2 create debit \# curl x put "$base url/debit" \\ h "authorization bearer $api token" \\ h "content type application/json" \\ d '{ "amount" 10000, "statement" "test statement", "note" "test note", "to bank account" "platform bank abc", "contact id" "contact 123", "preauthorize" false }' \# → save the returned debit transaction id (e g , debit 456) \# \# 3 collect bank details and add bank account \# \# important \# you must create and present a secure form in your application \# to collect the customer's bank account details \# jetpay does not host an eft collection form curl x put "$base url/contact/bank account" \\ h "authorization bearer $api token" \\ h "content type application/json" \\ d '{ "institution" "test bank", "title" "personal account", "holder name" "jane doe", "contact id" "contact 123", "account type" "checking", "transit number" "12345", "institution number" "001", "account number" "1234567", "holder address" "123 main st", "holder address postal code" "a1a1a1", "holder address city" "toronto", "holder address country" "ca", "holder email" "jane\@example com" }' \# → save the returned bank account id (e g , bank account 789) \# \# 4 pay debit \# curl x put "$base url/pay debit" \\ h "authorization bearer $api token" \\ h "content type application/json" \\ d '{ "pad signed" true, "signature pad time" 1700000000, "from bank account" "bank account 789", "debit transaction id" "debit 456" }' \# → the api returns the updated debit object \# → implement webhooks to track final status updates import requests import time base url = "https //extapi demo jetpay baselinepayments com" api token = "\<your api token>" headers = { "authorization" f"bearer {api token}", "content type" "application/json" } \# \# 1 create contact \# contact response = requests put( f"{base url}/contact", headers=headers, json={ "email" "jane\@example com", "name" "jane doe", "tags" \[], "language" "en" } ) contact id = contact response json()\["contact id"] \# \# 2 create debit \# debit response = requests put( f"{base url}/debit", headers=headers, json={ "amount" 10000, "statement" "test statement", "note" "test note", "to bank account" "platform bank abc", "contact id" contact id, "preauthorize" false } ) debit id = debit response json()\["debit transaction id"] \# \# 3 add bank account \# \# important \# you must build and present a secure form in your application \# to collect the customer’s bank account details bank response = requests put( f"{base url}/contact/bank account", headers=headers, json={ "institution" "test bank", "title" "personal account", "holder name" "jane doe", "contact id" contact id, "account type" "checking", "transit number" "12345", "institution number" "001", "account number" "1234567", "holder address" "123 main st", "holder address postal code" "a1a1a1", "holder address city" "toronto", "holder address country" "ca", "holder email" "jane\@example com" } ) bank account id = bank response json()\["bank account id"] \# \# 4 pay debit \# pay response = requests put( f"{base url}/pay debit", headers=headers, json={ "pad signed" true, "signature pad time" int(time time()), "from bank account" bank account id, "debit transaction id" debit id } ) print(pay response json())const base url = "https //extapi demo jetpay baselinepayments com"; const api token = "\<your api token>"; const headers = { "authorization" `bearer ${api token}`, "content type" "application/json" }; async function runeftflow() { // // 1 create contact // const contactres = await fetch(`${base url}/contact`, { method "put", headers, body json stringify({ email "jane\@example com", name "jane doe", tags \[], language "en" }) }); const contactdata = await contactres json(); const contactid = contactdata contact id; // // 2 create debit // const debitres = await fetch(`${base url}/debit`, { method "put", headers, body json stringify({ amount 10000, statement "test statement", note "test note", to bank account "platform bank abc", contact id contactid, preauthorize false }) }); const debitdata = await debitres json(); const debitid = debitdata debit transaction id; // // 3 add bank account // // important // you must build and present a secure form in your application // to collect the customer's bank account details const bankres = await fetch(`${base url}/contact/bank account`, { method "put", headers, body json stringify({ institution "test bank", title "personal account", holder name "jane doe", contact id contactid, account type "checking", transit number "12345", institution number "001", account number "1234567", holder address "123 main st", holder address postal code "a1a1a1", holder address city "toronto", holder address country "ca", holder email "jane\@example com" }) }); const bankdata = await bankres json(); const bankaccountid = bankdata bank account id; // // 4 pay debit // const payres = await fetch(`${base url}/pay debit`, { method "put", headers, body json stringify({ pad signed true, signature pad time math floor(date now() / 1000), from bank account bankaccountid, debit transaction id debitid }) }); const paydata = await payres json(); console log(paydata); } runeftflow();