Published
Tuesday, September 21, 2010 - 05:13
Written by

Continuing the series, let's look at packaging payment processors. Before digging in the text below, make sure you're up to date with previous blog posts: on info file format and on packaging custom search.

 

We'll start as previously, by creating a directory named exactly the same as unique key that we're choosing for our extension. Let's use example of Google Checkout payment processor - both the key and the name of directory will be org.civicrm.googlecheckout.

 

Now, we need to create the info.xml file. Since this process has been described in detail before, going straight to final effect:

 

 <?xml version="1.0" encoding="UTF-8" ?>
 <extension key="org.civicrm.googlecheckout" type="payment">
  <callback>Google</callback>
  <name>Google Checkout</name>
  <description>Google Checkout Payment Processor</description>
  <url>http://civicrm.org</url>
  <license>AGPL</license>
  <maintainer>CiviCRM Core Team &lt;noreply@civicrm.org&gt;</maintainer>
  <releaseDate>2010-09-01</releaseDate>
  <version>1.0</version>
  <develStage>stable</develStage>
  <compatibility><ver>3.3</ver></compatibility>
  <comments>For support, please contact project team on the forums. (http://forum.civicrm.org)</comments>
</extension> 

 

Again, following previous instructions, let's put info.xml and GoogleCheckout.php in the directory we just created. Payment processors do not require templates, so we don't need to follow any other steps that we know already, however, we need to do some more stuff in order for our extension to work.

 

First of all, this payment processor requires some external libraries to work - they're . Let's put them in packages directory inside org.civicrm.googlecheckout. So now, we have the following structure:

 

 org.civicrm.googlecheckout/
|-- CRM
|   |-- Contribute
|   |   `-- Payment
|   |       `-- Google.php
|   `-- Event
|       `-- Payment
|           `-- Google.php
|-- Google.php
|-- info.xml
|-- packages
|   `-- Google
|       |-- README
|       |-- demo
|       |   |-- cartdemo.php
|       |   `-- responsehandlerdemo.php
|       |-- googlemessage.log
|       `-- library
|           |-- googlecart.php
|           |-- googleitem.php
|           |-- googlemerchantcalculations.php
|           |-- googleresponse.php
|           |-- googleresult.php
|           |-- googleshipping.php
|           |-- googletaxrule.php
|           |-- googletaxtable.php
|           `-- xml-processing
|               |-- xmlbuilder.php
|               `-- xmlparser.php
`-- processor-type.xml 

 

Hey, there is one more file here that we didn't talk about before! We are going to need some additional information - hence the processor-type.xml file. It's contents reflect the contents of civicrm_payment_processor_type database table. Here's an example for Google Checkout payment processor (line break in urls are here only because of blog layout problems).

 

 <?xml version="1.0" encoding="UTF-8" ?>
 <payment_processor_type>
  <user_name_label>Merchant ID</user_name_label>
  <password_label>Key</password_label>
  <signature_label></signature_label>
  <subject_label></subject_label>
  <class_name>Payment_Google</class_name>
  <url_site_default>https://checkout.google.com/</url_site_default>
  <url_api_default></url_api_default>
  <url_recur_default></url_recur_default>
  <url_button_default>https://checkout.google.com/buttons/checkout.gif
?merchant_id=YOURMERCHANTIDHERE&w=160&h=43&style=white&variant=text&loc=en_US</url_button
  <url_site_test_default>https://sandbox.google.com/checkout/</url_site_test_default>
  <url_api_test_default></url_api_test_default>
  <url_recur_test_default></url_recur_test_default>
  <url_button_test_default>https://sandbox.google.com/checkout/buttons/checkout.gif
?merchant_id=YOURMERCHANTIDHERE&w=160&h=43&style=white&variant=text&loc=en_U
  <billing_mode>notify</billing_mode>
  <is_recur>0</is_recur>
  <payment_type>1</payment_type>
 </payment_processor_type> 
Filed under