Custom Payment Scenarios Using the API Senior Developer at Skvare - - PowerPoint PPT Presentation

custom payment scenarios
SMART_READER_LITE
LIVE PREVIEW

Custom Payment Scenarios Using the API Senior Developer at Skvare - - PowerPoint PPT Presentation

Custom Payment Scenarios Using the API Senior Developer at Skvare A little about Using CiviCRM since 2010 me... Reformed Joomla Evangelist Nitpicker of lesser-used APIs Case Study: Texas Pediatric Society Case Study: TPS Event


slide-1
SLIDE 1

Custom Payment Scenarios

Using the API

slide-2
SLIDE 2

A little about me...

  • Senior Developer at Skvare
  • Using CiviCRM since 2010
  • Reformed Joomla Evangelist
  • Nitpicker of lesser-used APIs
slide-3
SLIDE 3

Case Study:

Texas Pediatric Society

slide-4
SLIDE 4

Case Study: TPS Event Registration

TPS used their event registration to opportunity to make a donation.

  • Pro: Take advantage of one purchase to make an impulse

donation

  • Con: Difficult to segregate donation from event fee for

reporting.

slide-5
SLIDE 5

Case Study: TPS Event Registration

Client requirements

  • Separate event fee from donation amount
  • No redirects or additional pages
slide-6
SLIDE 6

Taking the Items Out

  • 1. Decide on financial types or other characteristics of

your line items to filter on.

Pro Tip: Use the FinancialType API to get the financial_type_id(s) by name.

slide-7
SLIDE 7

Taking the Items Out

  • 2. Create a preProcess hook
  • 3. Grab the _params and _lineItem arrays out the form
  • bject


Both of these arrays will need to be grabbed using getVar().

slide-8
SLIDE 8

Taking the Items Out

  • 4. Loop through the line items for your initial transaction

and zero out the line items you’ll be transferring.

  • 5. Remove the aggregate of those items from the total.
  • 6. Write the updated items back to the form.
slide-9
SLIDE 9

Creating the New Contribution

When the ThankYou form is accessed:

  • 1. Get the _params and _lineItem arrays again
  • 2. Set a default for the total contribution amount
slide-10
SLIDE 10

Creating the New Contribution

When the ThankYou form is accessed:

  • 3. Loop through the line items again and add the line

item amount to the contribution total.

slide-11
SLIDE 11

Create the transact params array

financial_type_id: Looking for label name total_amount: use the variable created earlier contact_id: can be grabbed from the form values is_test: (optional) payment_processor: use the numeric id credit_card_number: $params[0][‘credit_card_number'], cvv2: $params[0][‘cvv2'], month: $params[0]['credit_card_exp_date']['M'], credit_card_type: $params[0]['credit_card_type'], year: $params[0]['credit_card_exp_date']['Y'], invoice_id: md5(uniqid(rand(), TRUE)), skipLineItem: (optional = 1 to use only the total, 0 to keep the line items) source: (optional)

slide-12
SLIDE 12

Creating the New Contribution

  • Get the line items via the API with the specified entity_id

and Financial Type.

  • Loop through the line items and update these items with

the new contribution_id created from the transact() call.

slide-13
SLIDE 13

Send a Receipt for the New Contribution

  • Send the receipt via contribution.sendconfirmation

$confirmation = civicrm_api3('Contribution', 'sendconfirmation', array( 'id' => contribution_id, 'receipt_from_email' => “email@example.com“, 'receipt_from_name' => “From Name", ));

slide-14
SLIDE 14

Applications

  • Transactions outside of CiviCRM
  • Custom transaction workflows for Events, Tax vs. Non-

Taxed Contributions, Memberships

slide-15
SLIDE 15

Additional Payment APIs in 4.7

Payment

  • Adds a payment to an

existing contribution

  • Does not invoke a payment

processor.

Order

  • Can create contributions with

line items of different types

  • Does not invoke a payment

processor.

slide-16
SLIDE 16

Questions?

slide-17
SLIDE 17

Learn More

Questions? Contact Us Peter Petrik - CEO peter@skvare.com Mark Hanna - Architect / Senior Developer mark@skvare.com Jeremy Proffitt - Senior Developer jeremy@skvare.com / @jproffitt https://skvare.com | @skvare