Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #26: support recurring contributions. #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

twomice
Copy link
Contributor

@twomice twomice commented Sep 29, 2020

Hi @jmcclelland This approach is functional, but I admit I'm not totally satisfied with all the manual HTML manipulation that's going on in the new createRecurringFieldsDiv() javascript function. This approach is meant to provide more control for the inline field layout that's commonly used for recurring-related fields (e.g.I want to contribute this amount every ____ [day(s)] for ___ installments), which breaks many assumptions about field layout for most fields in Remote Forms. I'm hoping this is useful as-is but of course that's up to you; I'm running out of client budget that might allow significant re-working of this approach. Toughts?

@twomice
Copy link
Contributor Author

twomice commented Sep 29, 2020

Screenshot:

recurring

@jmcclelland
Copy link
Collaborator

Thanks! It looks good in principle. Tomorrow I'll test it out.

@jmcclelland
Copy link
Collaborator

I'm going to need a little more time on this. I'm testing with Stripe as the payment processor and running into a few difficulties. The first is an intermittent error when I just expose the recurring contribution option with monthly as the only choice.

I sometimes get this error:

 [debug_info] => INSERT INTO `civicrm_contribution_recur` (`contact_id` , `amount` , `currency` , `installments` , `start_date` , `create_date` , `modified_date` , `trxn_id` , `invoice_id` , `contribution_status_id` , `is_test` , `payment_processor_id` , `financial_type_id` , `payment_instrument_id` ) VALUES ( 37552 ,  25 , 'USD' ,  0 ,  20201002163209 ,  20201002163209 ,  20201002163209 , '1685e2ffb63fad9114f4e5739727cd24' , '1685e2ffb63fad9114f4e5739727cd24' ,  2 ,  1 ,  16 ,  1 ,  1 )  [nativecode=1364 ** Field 'frequency_interval' doesn't have a default value]

In addition, when I add the option to select frequency, I'm consistently getting an error in the javascript console (the code seems to be sending an OPTIONS request to the https://server.org/ address instead of https://server.org/civicrm/remoteform - so Drupal responds with an 403 un authorized error). These errors are accompanied by the following in the ConfigAndLog:

Oct 02 16:29:15  [debug] paymentMethodID not found. $params: Civi\Payment\PropertyBag Object
(
    [props:protected] => Array
        (
            [default] => Array
                (
                    [contribution_page_id] => 17
                    [test_mode] => 1
                    [firstName] => WTF
                    [lastName] => McWTFER
                    [email-primary] => [email protected]
                    [price_316] => 839
                    [price_set_id] => 238
                    [payment_instrument_id] => 1
                    [isRecur] => 1
                    [recurFrequencyInterval] => 1
                    [amount] => 25
                    [payment_processor_id] => 16
                    [paymentIntentID] => pi_1HXvoUAwDzuDdbFCpIrQi5Uc
                    [id] => 17
                    [version] => 3
                    [email-Primary] => [email protected]
                    [invoiceID] => 718eabdd2a73d7f95d6015bbc3c2a861
                    [is_pay_later] => 0
                    [priceSetId] => 238
                    [amount_level] => Supporter of the Internet Security & Surveillance Rapid Response Team
                    [description] => Simple Contribution
                    [currency] => USD
                    [ip_address] => 10.11.13.1
                    [skipLineItem] => 0
                    [line_item] => Array
                        (
                            [238] => Array
                                (
                                    [839] => Array
                                        (
                                            [price_field_id] => 316
                                            [price_field_value_id] => 839
                                            [label] => Supporter of the Internet Security & Surveillance Rapid Response Team
                                            [field_title] => Contribution Amount
                                            [description] => 
                                            [qty] => 1
                                            [unit_price] => 25.000000000
                                            [line_total] => 25
                                            [participant_count] => 0
                                            [max_value] => 
                                            [membership_type_id] => 
                                            [membership_num_terms] => 
                                            [auto_renew] => 
                                            [html_type] => Radio
                                            [financial_type_id] => 1
                                            [tax_amount] => 0
                                            [non_deductible_amount] => 0.00
                                        )

                                )

                        )

                    [contributionTypeID] => 1
                    [financialTypeID] => 1
                    [financial_type_id] => 1
                    [contributionType_name] => Donation
                    [financialType_name] => Donation
                    [contributionPageID] => 17
                    [contactID] => 37551
                    [item_name] => Online Contribution: Simple Contribution
                    [qfKey] => e381c99d71a31b1c04d2d6cc2f73f3b171dd29f05f0f33b50f97d09909771e16_2726
                    [contributionID] => 4239
                    [contributionRecurID] => 25
                    [error_url] => 
                    [paymentMethodID] => 
                )

        )

    [lastWarning] => Unknown property 'qfKey'. We have merged this in for now as a custom property. Please rewrite your code to use PropertyBag->setCustomProperty if it is a genuinely custom property, or a standardised setter like PropertyBag->setContactID for standard properties
)

Stripe is a complicated payment processor, so I suspect the errors are related to that payment processor.

@twomice
Copy link
Contributor Author

twomice commented Oct 2, 2020

Thanks for the feedback @jmcclelland . I didn't test with Stripe, so I'm glad you found that. Need to see if I can find time to put some thought into that.

@shaneonabike
Copy link

It looks like you pushed this to master but actually it's not there? I have an organization I'm working for that would like to support remote contributions with an interval... will this patch work?

cc @jmcclelland

@jmcclelland
Copy link
Collaborator

@shaneonabike - no, I haven't yet incorporated this pull request into master. I haven't worked on it since my last comment unfortunately.

Also, I wanted to flag that this extension will likely be deprecated soon once oembed functionality is added to CiviCRM: https://lab.civicrm.org/dev/core/-/issues/2994

Hopefully soon we will be able to use ombed to directly embed any form into a web site and not have to mess around with javascript.

@shaneonabike
Copy link

Yeah totally fair! I was aware they were working on it but I have a client who wanted to get this going now. Thanks for the quick response have a great day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants