- 11 Dec 2023
- 2 Minutes to read
- Print
- DarkLight
Blackthorn | Scheduled Jobs
- Updated on 11 Dec 2023
- 2 Minutes to read
- Print
- DarkLight
You can find the scheduled jobs below in Setup. In the Quick Find box, enter and click "Scheduled Jobs". All of the Payments job names start with Blackthorn | Payments.
- Blackthorn | Payments Send Stripe Invoices - It runs at 6 am each day to send the Invoice to the customer when Send Invoice On Date = "TODAY" on the Invoice.
- Blackthorn | Payments Past Due Invoices - It runs at 5 am each day to update the Invoice Payment Status = "Past Due" when the Due Date < Today and Payment Status = "Unpaid".
You can schedule the jobs listed above by clicking the Schedule Billing Jobs button in the Blackthorn | Payment Admin tab.
Process Stripe Billing Webhook Types Asynchronously
A global method that allows customers to process certain Stripe Billing webhook types asynchronously instead of via the Blackthorn batch jobs was added. If the Process Async checkbox = “True”, the existing web processing batch jobs will skip those webhooks.
Blackthorn customers are responsible for adding the logic that 1) sets the records they want as Process Async and 2) calls the async method to process them. The following example code creates a before trigger to check the Process Async box and an after trigger to call the async method.
Before proceeding, two updates must be made to the Site Guest User/public user.
Step 1: To avoid permission errors, give the Blackthorn | Payments (Site Guest User) permission set Read access to the Product (Product2) object.
- Click the Gear icon in the upper right-hand corner.
- Click Setup.
- In the Quick Find box, enter and click “Permission Sets.”
- Create a new permission set.
- Click New.
- In the Label field, enter a descriptive name for the permission set, such as “Read Access to Product2.”
- Click Save.
- Configure object permissions.
- Click “Object Settings” or “Object Permissions” in the Apps section.
- Find and click the Product (Product2) object. If you don’t see it, use the search function to locate it.
- Click Edit next to the Products heading.
- In the Object Permissions section, set Read to “Enabled” (checked). Do not enable Edit, Create, and Delete unless they are needed.
- Click Save.
Step 2: Assign the newly created permission set to the public user.
- Navigate back to the site you created.
- Click Public Access Settings.
- Click the View Users or Assign Users button.
- Click the link for the site guest user.
- In the Permission Set Assignments section, click Edit Assignments.
- Move the newly created permission set from the Available Permission Sets column to the Enabled Permission Sets column.
- Click Save.
trigger customWebhookTrigger on Webhook_Event__c (before insert, after insert) {
if (Trigger.isBefore) {
for (bt_stripe__Webhook_Event__c webhook : Trigger.new) {
if (webhook.bt_stripe__Type__c == 'invoice.created') {
webhook.bt_stripe__Process_Async__c = true;
}
}
}
if (Trigger.isAfter) {
List<Webhook_Event__c> webhooks = [SELECT Id, Name, Type__c, Process_Async__c, Processed__c, Payment_Gateway__c, Data__c FROM Webhook_Event__c WHERE Id IN :trigger.new];
for (Webhook_Event__c webhook : webhooks) {
if (webhook.bt_stripe__Process_Async__c && webhook.bt_stripe__Type__c == 'invoice.created') {
// Call without sharing class here to process the webhook
}
}
}
}
NOTE: Replace 'invoice.created' or add additional webhook types as needed.