{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Callbacks","description":"Tyro Health Docs","keywords":"redocly developer portal, api portal starter, api reference docs","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"callbacks","__idx":0},"children":["Callbacks"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Callbacks are functions that you can provide to a method in the SDK which will give you feedback when an event occurs."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["They can be useful when you want to record data & attributes at a particular stage of a transaction."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"sdkrendercreatetransaction","__idx":1},"children":["sdk.renderCreateTransaction"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can provide a set of callback events to the second parameter of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["renderCreateTransaction"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A list of the supported callbacks are as follows:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Callback"]}]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":""},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Description"]}]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onSuccess(transaction)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invoked when the transaction, claim (when applicable) & payment is successful.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," This callback will not be invoked if the user closes the modal before a successful transaction."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onError(error)"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invoked when an error occurs and the transaction cannot be completed. ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," This callback will not be invoked if the user closes the modal and the transaction errors afterwards."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCancel()"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invoked when the transaction has been cancelled. ",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Warning:"]}," This callback will not be invoked if the user closes the modal and the transaction is cancelled afterwards. You can use the [",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invoiceCancelled"]}," webhook"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["onCloseModal({ transaction, error, status })"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Invoked when the modal has been closed by the user and provides data at the current stage of the transaction.",{"$$mdtype":"Tag","name":"br","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example:"]}," it could be possible that the user closes the modal when a claim/payment is pending from the patient."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"example","__idx":2},"children":["Example:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"import medipassSDK from '@medipass/partner-sdk';\n\nmedipassSDK.renderCreateTransaction(\n  {\n    // ... transaction attributes\n  },\n  {\n    onSuccess: function(transaction) {\n      console.log(transaction);\n      // -> { _id: '123', created: '2022-01-22T23:18:30.329', items: [...], claims: [...], ... }\n    },\n    onError: function(error) {\n      console.log(error);\n      // -> { message: 'An error occurred.' }\n    },\n    onCancel: function() {\n      console.log('Transaction cancelled.');\n    },\n    onCloseModal: function({ transaction, error, status }) {\n      if (status === 'success') {\n        console.log(transaction);\n        // -> { _id: '123', created: '2022-01-22T23:18:30.329', items: [...], claims: [...], ... }\n      } else if (status === 'error') {\n        console.log(error);\n        // -> { message: 'An error occurred.' }\n      } else if (status === 'cancelled') {\n        console.log('Transaction cancelled.');\n      }\n    },\n    onTransactionCreated: function(transaction) {\n      console.log('Transaction created', transaction);\n    },\n    onTransactionUpdated: function(transaction) {\n      console.log('Transaction updated', transaction);\n    },\n  }\n);\n","lang":"js"},"children":[]}]},"headings":[{"value":"Callbacks","id":"callbacks","depth":1},{"value":"sdk.renderCreateTransaction","id":"sdkrendercreatetransaction","depth":2},{"value":"Example:","id":"example","depth":2}],"frontmatter":{"title":"Callbacks","seo":{"title":"Callbacks"}},"lastModified":"2022-11-01T21:53:13.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/developer-portal/eftpos-and-healthpoint/callbacks","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}