Merge branch 'master' of git://github.com/civicrm/civicrm-core into codingstandards-12
[civicrm-core.git] / tests / phpunit / CiviTest / PaypalPro.php
1 <?php
2 require_once "CRM/Financial/DAO/PaymentProcessor.php";
3
4 /**
5 * Class PaypalPro
6 */
7 class PaypalPro extends PHPUnit_Framework_Testcase {
8 /**
9 * Helper function to create
10 * a payment processor of type Paypal Pro
11 *
12 * @return int
13 * $paymentProcessor id of created payment processor@todo this appears not to be working but because it doesn't extend the test class
14 * callAPISuccess won't work
15 * I have duplicated this on the main test class as a work around
16 */
17 public static function create() {
18
19 $paymentProcessor = new CRM_Financial_DAO_PaymentProcessor();
20 $paymentParams = array(
21 'name' => 'demo',
22 'domain_id' => CRM_Core_Config::domainID(),
23 'payment_processor_type' => 'PayPal',
24 'is_active' => 1,
25 'is_default' => 0,
26 'is_test' => 1,
27 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
28 'password' => '1183377788',
29 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
30 'url_site' => 'https://www.sandbox.paypal.com/',
31 'url_api' => 'https://api-3t.sandbox.paypal.com/',
32 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
33 'class_name' => 'Payment_PayPalImpl',
34 'billing_mode' => 3,
35 'financial_type_id' => 1,
36 );
37 $paymentProcessor->copyValues($paymentParams);
38 $paymentProcessor->save();
39 return $paymentProcessor->id;
40 }
41
42 /**
43 * Helper function to delete a PayPal Pro
44 * payment processor
45 * @param int $id
46 * Id of the PayPal Pro payment processor.
47 * to be deleted
48 * @return bool
49 * true if payment processor deleted, false otherwise
50 */
51 public static function delete($id) {
52 $pp = new CRM_Financial_DAO_PaymentProcessor();
53 $pp->id = $id;
54 if ($pp->find(TRUE)) {
55 $result = $pp->delete();
56 }
57 return $result;
58 }
59 }