Created
July 26, 2016 20:34
-
-
Save pcave/2bac9ad9312c9a28513538b7bad15d03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_springboard_quick_donate_optin_create(). | |
*/ | |
function salesforce_quick_donate_springboard_quick_donate_optin_create($account, $donation, $card_id) { | |
// Load the full card on file entity. | |
$card_on_file = commerce_cardonfile_load($card_id); | |
// Create a quick donate subscription object and queue it up. | |
$sobject = new stdClass(); | |
$sobject->type = 'Quick_Donate_Subscription__c'; | |
$sobject->fields = array( | |
'Card_Id__c' => $card_id, | |
'Payment_Method__c' => $card_on_file->payment_method, | |
'Payment_Gateway__c' => $card_on_file->instance_id, | |
'Card_Token__c' => $card_on_file->remote_id, | |
'Credit_Card_Type__c' => $card_on_file->card_type, | |
'Name_on_Card__c' => $card_on_file->card_name, | |
'Card_Last_4__c' => $card_on_file->card_number, | |
'Card_Expiration_Month__c' => $card_on_file->card_exp_month, | |
'Card_Expiration_Year__c' => $card_on_file->card_exp_year, | |
'Opt_In_Date__c' => $card_on_file->created, | |
'Default_Card__c' => $card_on_file->instance_default, | |
'Contact__c' => sprintf('[Contact:user:%d]', $account->uid), | |
'Donation__c' => sprintf('[Opportunity:donation:%d]', $donation->did), | |
'Form_Id__c' => $donation->node->nid, | |
'Form_Name__c' => $donation->node->title, | |
); | |
$item = array( | |
'drupal_id' => $card_id, | |
'module' => 'salesforce_quick_donate', | |
'delta' => 'commerce_cardonfile', | |
'object_type' => 'Quick_Donate_Subscription__c', | |
'operation' => 'CREATE', | |
'sobject' => $sobject, | |
); | |
$queue = salesforce_queue_load(); | |
$result = $queue->createItem($item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment