Formatting improvements and add code comments on Order API + fix broken URL
Created by: artfulrobot
- Fix broken link to dev/financial#73 (closed)
- Use
//
for single line comments (isn't#
deprecated? or is that just in .ini files?) - Add whitespace and comments around migration from transact code.
- Wrap code example lines so they display properly
Merge request reports
Activity
351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], 351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], 351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], 351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], 351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], Created by: artfulrobot
I've added both in because that's the most efficient way (saves a lookup on instrument). It currently looks up intstrument from the contribution too, if processor not given, but anyway.
I wonder if
payment_processor_id
should be required forPayment.create
- it seems really important and is stored in the financial transaction table.
351 353 } 352 354 $order = civicrm_api3('Order', 'create' $params); 353 355 try { 356 // Use the Payment Processor to attempt to take the actual payment. You may 357 // pass in other params here, too. 354 358 civicrm_api3('PaymentProcessor', 'pay', ['contribution_id' => $order['id']]); 355 civicrm_api3('Payment', 'create', ['contribution_id' => $order['id'], 'amount' => $params['amount']]); 359 360 // Assuming the payment was taken, record it which will mark the Contribution 361 // as Completed and update related entities. 362 civicrm_api3('Payment', 'create', [ 363 'contribution_id' => $order['id'], 364 'total_amount' => $params['amount'], Created by: eileenmcnaughton
@artfulrobot ok I logged that here dev/financial#95
@MikeyMJCO I think this is OK to merge
Please register or sign in to reply