Event Listeners
2 min
After completing transactions in Pay3 SDK UI, the Pay3 SDK publishes events via Firebase real-time database for all native SDKs. The listener can be registered after successfully completing the anonymos login in Firebase which happens during initialisation.
pay3-sdk-transaction-status
This event is fired by Pay3 SDK in following scenario
- On completion of Checkout transaction triggered by TriggerOpenCheckout
Snapshot Payload
- data (Type Object): Following keys are present in this object
- status (Type string): The status can have values SUCCESS or ERROR.
- message (Type string): User-friendly message returned after completion of the transaction.
- orderId (Type string): Pay3 Order ID.
- requestId (Type string): Unique id passed by App.
- error (Type Object, Optional): Following keys will be present if there is an error. Please refer to SDK ErrorsSDK Errors for reference.
- code (Type number): Error code.
- message (Type string): Error message.
public class Pay3Helper : MonoBehaviour {
// Pseudocode to attach a listner to receive transaction status
// events with in the Unity application
private void StartTransactionListener() {
FirebaseDatabase.GetInstance(fbApp)
.GetReference("/app_notifications/"+fbUserId+"/pay3-sdk-transaction-status")
.ValueChanged += (object sender2, ValueChangedEventArgs event) => {
// Extract event data from snapshot object returned by the event listener
};
}
} Pay3Helper.cs
public class Pay3Helper : MonoBehaviour {
// Pseudocode to attach a listner to receive transaction status
// events with in the Unity application
private void StartTransactionListener() {
FirebaseDatabase.GetInstance(fbApp)
.GetReference("/app_notifications/"+fbUserId+"/pay3-sdk-transaction-status")
.ValueChanged += (object sender2, ValueChangedEventArgs event) => {
// Extract event data from snapshot object returned by the event listener
};
}
}