I need to integrate a third party library into Ubercart and am looking for tips on the best way to do this.
Once the payment is received, I need to make a third-party API call that asks for a key. If the request is successful, we include the key with the "file download available" email. If the request is not successful we need to handle the error appropriately (by sending a page/email/sms or something yet to be determined) and allow the transaction to continue as configured.
So, basically, I think I'm talking about creating a module that "requires" the third-party API, and then overrides uc_cart_complete_sale(). Is this the best method to do something like this? Or is there a better location to insert this type of business logic. Ideally, I'll add this to contrib when I'm done so I would like to do it right.
So, something like this (pseudo-code):
if (payment.hasBeenReceived())
$sdk = new SDK();
$result = $sdk->request(payload params);
if($result === false)
handleErrorAppropriately();
else
insertKeysIntoFileDownloadEmail($result['key']);
goOnAboutYour MerryWay();I'm a Drupal/Ubercart n00b so be gentle with me....



Joined: 05/07/2008