I installed Payment360 and I am trying to capture a transaction from a trigger. Payment360 offers the following documentation: payment360 documentation
Through trial and error I see that i need my trigger to call a future method which then calls the capture() method from the installed payment360 package. I had to do it this way because callouts from triggers are not allowed.
I have the below code for testing using ID=a0I46000000jg6c, but ultimately i want to use the ID from the record that initiates the trigger.
- How would I do this?
- I don't think my current code is working, but I get no errors.
Apex Class:
global class FutureClass
{
@future
public static void captureFuture()
{
try {
bt_stripe.P360_API_v1.Tra t = bt_stripe.P360_API_v1.transactionFactory('a0I46000000jg6c');
t.capture();
//bt_stripe.P360_API_v1.P360_Exception if something goes wrong with committing records in database
bt_stripe.P360_API_v1.commitWork();
} catch (Exception ex) {
//do error handling here
}
}
}
Trigger:
trigger CaptureTrans on bt_stripe__Transaction__c (after insert, after update) {
for (bt_stripe__Transaction__c pt : Trigger.new) {
if (pt.GameSet__c) {
FutureClass.captureFuture();
}
}
}