summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWesley Jones2015-11-30 06:45:28 (GMT)
committerWesley Jones2015-11-30 06:45:28 (GMT)
commit72fc814ce33297a22edde33c45787904d68c05a4 (patch)
treec7f3b219f5b497ef2e138ae225329ce23adb489a
parented684e3c2a589d0efe3160fb34817f3e576217b6 (diff)
Adding a Rule event to allow rules to run when the recurring profile gets created but the one time payment fails - such as an email to an admin
-rw-r--r--commerce_license_billing_paypal.module5
-rw-r--r--commerce_license_billing_paypal.rules.inc16
2 files changed, 18 insertions, 3 deletions
diff --git a/commerce_license_billing_paypal.module b/commerce_license_billing_paypal.module
index f3c063a..8a58d7c 100644
--- a/commerce_license_billing_paypal.module
+++ b/commerce_license_billing_paypal.module
@@ -159,7 +159,6 @@ function commerce_license_billing_paypal_commerce_payment_method_info() {
* The Express Checkout token if successful or FALSE if not.
*/
function commerce_license_billing_paypal_set_express_checkout($payment_method, $order, $flow) {
-
// Extract the order total value array.
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_total = $order_wrapper->commerce_order_total->value();
@@ -367,7 +366,6 @@ function commerce_license_billing_paypal_redirect_form_validate($order, $payment
// Get product from order to figure out what type of membership we are
// creating.
- // dd($order);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
// Get the first item in the order since this module only supports one item per checkout.
$line_item_wrapper = $order_wrapper->commerce_line_items[0];
@@ -458,10 +456,10 @@ function commerce_license_billing_paypal_redirect_form_validate($order, $payment
'MAXFAILEDPAYMENTS' => 3,
'PAYERID' => $response['PAYERID'],
);
+
$response2 = commerce_paypal_api_request($payment_method, $nvp2, $order);
if ($response2['ACK'] == 'Success') {
-
// Set the Recurring Profile ID.
if (empty($response2['PROFILEID'])) {
watchdog(
@@ -508,6 +506,7 @@ function commerce_license_billing_paypal_redirect_form_validate($order, $payment
// Attempt to process the payment.
if (!commerce_paypal_ec_do_payment($payment_method, $order, $charge)) {
+ rules_invoke_event('commerce_license_billing_paypal_error', $order);
return FALSE;
}
}
diff --git a/commerce_license_billing_paypal.rules.inc b/commerce_license_billing_paypal.rules.inc
index dfe7ee7..0ac82d9 100644
--- a/commerce_license_billing_paypal.rules.inc
+++ b/commerce_license_billing_paypal.rules.inc
@@ -5,6 +5,22 @@
*/
/**
+* Implementation of hook_rules_event_info().
+*/
+function commerce_license_billing_paypal_rules_event_info() {
+ return array(
+ 'commerce_license_billing_paypal_error' => array(
+ 'label' => t('After receiving Paypal error'),
+ 'module' => 'commerce_license_billing_paypal',
+ 'group' => t('Commerce License Billing Paypal'),
+ 'variables' => array(
+ 'order' => array('type' => 'commerce_order', 'label' => t('The order that failed.')),
+ ),
+ ),
+ );
+}
+
+/**
* Implements hook_rules_condition_info().
*/
function commerce_license_billing_paypal_rules_condition_info() {