Events

If you want to do some manual work, there are some events you can handle.

fundraisingBox:init

Triggered after the form has been sucessfully initialized.
Provides a JSON with Form Configuration and Session / Transaction and some additional info.

🚧

Consider this event for dynamic forms!

Don't forget: the initialization of the form is done asynchronously! You have to wait for this event until you can use the Plugin-functions. See Functions.

{
	"status": "success",
  "config": {...}, // see Form Configuration JSON
  "session": {...}, // see Session JSON
  "info": {
    "credit_card_errors": {
      "empty": "This is a required field.",
      "luhn": "Invalid",
      "bad": "Invalid",
      "expire": "Invalid",
      "system": "System error",
      "syserror": "Credit card payment failed. Please try again or select a different payment method."
    },
    "micropayment_project": "abc123"
  },
  "sandbox": false
}

Example: adding visible items:

<div id="items"></div>
<script>
	myForm.on("fundraisingBox:init", function(event, json) {
  	if(json.status == "success")
    {
			var items = myForm.getItems();
      for(i=0; i<items.length; i++)
      {
        if(items[i].visible)
        {
          $("#items").append("<div><input type='radio' name='payment[fb_item_id]' value='"+items[i].id+"' />"+items[i].title+" "+items[i].amount+"€</div>");
        }
      }
      ...
    }
	});
</script>

fundraisingBox:updateSession

Triggered after updateSession() is successfully done.
Provides a JSON with the Session.

{
	"status": "success",
  "session": {...} // see Session JSON
}

fundraisingBox:payment

Triggered after doPayment() is successfully done.

On success:
Provides a JSON with the Transaction

{
  "status": "success",
  "payment_status": "success", // or "awaiting" if redirect payment (PayPal, Sofortüberweisung, EPS)
  "redirect_url": "http://meineorga.de/spenden/danke.html?betrag=120",
  "transaction": {...} // see Transaction JSON
}

On error
Provides a JSON with errors.

{
  "status": "success",
  "payment_status": "error",
  "errors": { // see Errors JSON
    "current_fields": { ... },
    "globals": [ 
      "Es ist ein Fehler aufgetreten. Bitte laden Sie die Seite neu und versuchen Sie es erneut."
    ]
	}
}

fundraisingBox:creditCardReady

Triggered after the additional credit card javascript is done.
Wait for this event if you want to use the credit card functions.

fundraisingBox:creditCardSuccess

Triggered after the token has been created successfully.
Provides a JSON with token and obfuscated number and secure id.

{ 
  token: "123456f0d83ef93830caaf25f94c19fbd",
  number: "411111******1111",
  secure_id: "***"
}

fundraisingBox:creditCardError

Triggered if it was not possible to create the credit card token.
Provides Errors JSON with credit card errors in "current_fields".

fundraisingBox:walletPayReady

Triggered after it's known which wallet payment methods are available. Occurs only if Apple Pay or Google Pay are activated in your form.
Provides an updated Payment Methods JSON, with a new attribute "can_make_payment" for stripe_apple_pay and stripe_google_pay.
Use this event to show or hide the respective payment methods. See example.

{
  "sepa_direct_debit": {
    "countries": "DE AT CH",
    "amount_min": 0.01,
    "amount_max": 50000,
    "label": "SEPA-Lastschrift",
    "recurring": true
  },
  "stripe_apple_pay": {
  	"countries": "",
    "amount_min": 0.5,
    "amount_max": "",
    "label": "Apple Pay",
    "recurring": false,
    "can_make_payment": true
	},
  "stripe_google_pay": {
    "countries": "",
    "amount_min": 0.5,
    "amount_max": "",
    "label": "Google Pay",
    "recurring": false,
    "can_make_payment": false
  },
  ...
}

fundraisingBox:fieldError

Triggered if client-side field validation fails. Currently (2023/02) happens only for payments with Amazon Pay, if amount and interval are missing.
If you have deactivated autoRenderErrors you should listen to this event and render the errors by yourself.
Provides Errors JSON with new errors in "current_fields".

fundraisingBox:amazonPaySuccess

Triggered after the Amazon Pay popup has been closed and the "order reference id" has been retrieved.
Important: The payment is not yet finished, so if you have deactivated autoSubmit you should listen to this event and you have to submit the form by yourself to finalize the payment.

Provides a simple JSON with the reference id:

{
  amazon_pay_order_reference_id: "dummyreferenceid"
}

fundraisingBox:walletPaymentCancelled

Triggered after cancellation of a wallet payment request such as google pay.