Edge Payment Technologies offers payment solutions for merchants in diverse legal industries. To learn more about Edge's proposition see our [about](https://tryedge.io/about) page. ## Authentication Before starting with the API, you must [create a merchant account](https://dashboard.tryedge.io/register/your-details) and obtain API keys from the [Developer tab](https://dashboard.tryedge.io/developers) in your account dashboard. You will use the “Publishable key” with Edge JavaScript SDK and the “Secret key” with any SDK or HTTP API call. The Edge HTTP API requires in every request a `Authorization` header with a `Bearer` token. ## JSONAPI The Edge API is based upon REST principles, returns JSON responses, and uses standard HTTP response codes. We speficially use the [JSON:API](https://jsonapi.org/) specification. ## Browser SDK If you're wanting to use Edge Payment Technologies in the browser to make a charge you're going to need to include the Edge javascript SDK. The Edge JavaScript SDK is a toolkit for encrypting data in the browser. Using the Edge JavaScript SDK means your customer's data never leaves their browser unencrypted. You can get the URL to the SDK on the [Developers page](https://dashboard.tryedge.io/developers). Then after that you need to initialize the client: ```javascript const publishableToken = "publishableToken"; const formFactor = "inputs"; const paymentButton = document.querySelector("button#pay"); console.log("Initializing Edge JS with Payment ID:", paymentId); console.log("Publishable Key:", publishableToken); const edgeClient = new Edge(publishableToken, {}); ``` Once initialized you'll need to wait for webhook subscriptions in your backend, but you can also define optimistic javascript event callbacks: ```javascript edgeClient.on("payment_method_verifying", (payload) => { console.log("Verifying payment method", payload.detail); // ... }); edgeClient.on("payment_method_ready", (payload) => { console.log("Payment method ready", payload.detail); if (paymentButton) { // ... } }); edgeClient.on("payment_approved", (payload) => { console.log("Payment approved", payload.detail); }); edgeClient.on("subscription_approved", (payload) => { console.log("Subscription approved", payload.detail); // ... }); edgeClient.on("payment_method_verified", async (payload) => { console.log("Payment method verified", payload.detail); // ... }); edgeClient.on("payment_failed", (payload) => { console.log("Payment failed", payload.detail); // ... }); edgeClient.on("payment_timeout", (payload) => { console.log("Payment timeout", payload.detail); // ... }); // Pay button click triggers payment method verification paymentButton.addEventListener("click", function () { // ... edgeClient.verifyPaymentMethod().catch((err) => { console.error("Payment method verification failed", err); // ... }); }); ``` Finally you need to mount the edge client to the form: ```javascript edgeClient.mountPaymentForm("edge-js", paymentId); ``` ## Test Card Numbers (By network) | Card Number | 3DS Result | Network Result | | --- | --- | --- | | 4005519200000004 | Frictionless Success | Visa Success | | 4444333322221111455 | Frictionless Success | Visa (19 Digit Pan) Success | | 5406004444444443 | Frictionless Success | Mastercard Success | | 6011450103333333 | Frictionless Success | Discover Success | | 370000999999990 | Frictionless Success | AmEx Success | | 36006666333344 | Frictionless Success | Dinner's Club Success | | 6771798021000008 | Frictionless Success | Maestro Success | | 4124939999999990 | Frictionless Success | Generic Decline | | 4444333322221111 | Frictionless Success | Insufficient Funds | | 5555341244441115 | Frictionless Success | Lost Card | | 6011601160116611 | Frictionless Success | Stolen Card | | 370000000000002 | Frictionless Success | Incorrect CVC | | 4917300800000000 | Frictionless Success | Always Blocked | | 5407721000353481 | Frictionless Success | Highest risk | | 370000000100018 | Frictionless Rejection | - | | 5100060000000002 | Challenge Prompt | Success | | 4012000077777777 | Not Enrolled | - | | 4166676667666746 | Issuer Rejected, Unattempted | - | #### JSON:API Filtering EPT supports advanced filtering for all JSON:API resources via query parameters. You can filter by attributes, relationships, and relationship attributes using dot notation. Filter by a direct attribute: ``` GET /api/payment_demands?filter[status]=pending ``` Filter by a relationship's ID: ``` GET /api/payment_demands?filter[payer]= ``` Filter by an attribute of a related resource using dot notation: ``` GET /api/payment_demands?filter[payer.email]=john@example.com ``` This works for any resource and any relationship chain, e.g. `consumer_addresses?filter[customer.name]=John+Doe`. **Notes** - Multiple filters can be combined: `filter[status]=pending&filter[payer.email]=john@example.com` - Relationship chains of arbitrary depth are supported: `filter[merchant.account.owner.email]=ceo@acme.com` - All filters are applied as SQL `AND` conditions.