Skip to content
Snippets Groups Projects
Commit 7509ced7 authored by anemirovsky's avatar anemirovsky
Browse files

Fix "One of parameters (value: ) is not of the type Integer" error when...

Fix "One of parameters (value: ) is not of the type Integer" error when submitting a recurring contribution using the Stripe payment  processor.

The Stripe payment processor extension was not handling the case where a user
submits a recurring contribution without setting the number of installments.
This commit fixes that and also modifies the code that uses the recurring
contribution's end date to take ongoing recurring contributions into a
account.
parent dcbc94d5
Branches
Tags
No related merge requests found
......@@ -472,13 +472,21 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
$query_params = array(
1 => array($stripe_customer->id, 'String'),
2 => array($invoice_id, 'String'),
3 => array($end_time, 'Integer'),
);
// Insert the new Stripe Subscription info.
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_stripe_subscriptions
(customer_id, invoice_id, end_time, is_live)
VALUES (%1, %2, %3, '$transaction_mode')", $query_params);
// Set end_time to NULL if installments are ongoing indefinitely
if (empty($installments)) {
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_stripe_subscriptions
(customer_id, invoice_id, is_live)
VALUES (%1, %2, '$transaction_mode')", $query_params);
} else {
// Add the end time to the query params.
$query_params[3] = array($end_time, 'Integer');
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_stripe_subscriptions
(customer_id, invoice_id, end_time, is_live)
VALUES (%1, %2, %3, '$transaction_mode')", $query_params);
}
$params['trxn_id'] = $stripe_response->id;
$params['fee_amount'] = $stripe_response->fee / 100;
......
......@@ -139,7 +139,7 @@ class CRM_Stripe_Page_Webhook extends CRM_Core_Page {
%11, %12, '1', %13)",
$query_params);
if ($time_compare > $end_time) {
if (!empty($end_time) && $time_compare > $end_time) {
$end_date = date("Y-m-d H:i:s", $end_time);
// Final payment. Recurring contribution complete.
$stripe_customer->cancelSubscription();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment