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

Support chaining Payment.create from Order api #15548

Merged
merged 1 commit into from
Oct 22, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Oct 19, 2019

Overview

Now that we have deprecated creating an order without passing the status of 'Pending' I'm having to switch over some tested code. I quickly realised that supporting chaining would be really helpful here.

This PR creates the tests and code to make this work

civicrm_api3('Order', 'create', [
   'contact_id' => 4 
   'total_amount' => 5,
   'financial_type_id' => 2, 
   'contribution_status_id' => 'Pending',
   'api.Payment.create' => ['total_amount' => 5]]
);

Before

Above call fails

After

Above call passes & is tested

Technical Details

@JoeMurray @mattwire @artfulrobot @aydun

Comments

Note the impact of the deprecation is to show notices - this causes tested code to start failing if it hits the deprecation - this is a good thing.

@seamuslee001 I'll fix the extended reports tests once this is merged

@civibot
Copy link

civibot bot commented Oct 19, 2019

(Standard links)

api/v3/Order.php Outdated
@@ -92,8 +92,9 @@ function civicrm_api3_order_create($params) {
$entityIds = [];
$contributionStatus = CRM_Utils_Array::value('contribution_status_id', $params);
if ($contributionStatus !== 'Pending' && 'Pending' !== CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatus)) {
CRM_Core_Error::deprecatedFunctionWarning('Creating a Order with a status other than pending is deprecated. Currently empty defaults to "Completed" so as a transition not passing in "Pending" is deprecated');
CRM_Core_Error::deprecatedFunctionWarning("Creating a Order with a status other than pending is deprecated. Currently empty defaults to 'Completed' so as a transition not passing in 'Pending' is deprecated. You can chained payment creation like - civicrm_api3('Order', 'create', ['blah' => 'blah', 'contribution_status_id' => 'Pending', 'api.Payment.create => ['total_amount' => 5]]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar: "You can chained payment creation like -" Maybe "You can chain payment creation - for example:"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - fixed

@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

test this please

1 similar comment
@eileenmcnaughton
Copy link
Contributor Author

test this please

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 @monishdeb @mattwire is one of you good to merge this - I can fix the Extended Reports tests once merged

@seamuslee001
Copy link
Contributor

This looks fine to me, backed up by a unit test and makes sense

@seamuslee001 seamuslee001 merged commit 6e8b595 into civicrm:master Oct 22, 2019
@seamuslee001 seamuslee001 deleted the order branch October 22, 2019 23:06
@eileenmcnaughton
Copy link
Contributor Author

Thanks @seamuslee001

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

Successfully merging this pull request may close these issues.

3 participants