3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Core_Payment_PaypalPro
16 class CRM_Core_Payment_PaypalStdTest
extends CiviUnitTestCase
{
19 * @var \CRM_Core_Payment_PayPalImpl
24 * @throws \CiviCRM_API3_Exception
26 public function setUp() {
28 $processorID = $this->processorCreate([
29 'payment_processor_type_id' => 'PayPal_Standard',
32 'url_site' => 'https://www.paypal.com/',
33 'url_recur' => 'https://www.paypal.com/',
34 'class_name' => 'Payment_PayPalImpl',
37 $this->processor
= Civi\Payment\System
::singleton()->getById($processorID);
41 * @throws \CRM_Core_Exception
43 public function tearDown(): void
{
44 $this->quickCleanUpFinancialEntities();
49 * Test doing a one-off payment.
51 * @throws \Civi\Payment\Exception\PaymentProcessorException
53 public function testSinglePayment() {
55 $params['amount'] = 5.24;
56 $params['currency'] = 'USD';
57 $params['invoiceID'] = 'xyz';
58 $params['ip_address'] = '127.0.0.1';
59 $params['qfKey'] = 'w';
60 $params['currencyID'] = 'USD';
62 $this->processor
->doPayment($params);
64 catch (CRM_Core_Exception_PrematureExitException
$e) {
65 $redirectValues = parse_url($e->errorData
['url']);
66 $this->assertEquals('https', $redirectValues['scheme']);
67 $this->assertEquals('www.paypal.com', $redirectValues['host']);
68 $this->assertEquals('/cgi-bin/webscr', $redirectValues['path']);
70 parse_str($redirectValues['query'], $query);
71 $this->assertEquals(5.24, $query['amount']);
72 $this->assertEquals('CiviCRM_SP', $query['bn']);