Skip to content

Commit b113805

Browse files
Merge pull request #209 from elcapo/billing-fields-per-processor
Make state/province not mandatory for SagePay
2 parents 1ba8970 + bf043cb commit b113805

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

Metadata/omnipay_Sagepay_Server.mgd.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
'street_address' => "billing_street_address-{$billingLocationID}",
6868
'city' => "billing_city-{$billingLocationID}",
6969
'country' => "billing_country_id-{$billingLocationID}",
70-
'state_province' => "billing_state_province_id-{$billingLocationID}",
7170
'postal_code' => "billing_postal_code-{$billingLocationID}",
7271
],
7372
],
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
3+
use Civi\Api4\Contact;
4+
use Civi\Test\HeadlessInterface;
5+
use Civi\Test\HookInterface;
6+
use Civi\Test\TransactionalInterface;
7+
use GuzzleHttp\Psr7\Response;
8+
use PHPUnit\Framework\TestCase;
9+
use Civi\Test\Api3TestTrait;
10+
use Civi\Api4\ContributionRecur;
11+
use Civi\Api4\Contribution;
12+
13+
/**
14+
* Sage pay tests for one-off payment.
15+
*
16+
* @group headless
17+
*/
18+
class BillingFieldsTest extends TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
19+
use Api3TestTrait;
20+
use HttpClientTestTrait;
21+
22+
/**
23+
* ID of payment processor created for test.
24+
*
25+
* @var int
26+
*/
27+
protected $paymentProcessorID;
28+
29+
/**
30+
* @return \Civi\Test\CiviEnvBuilder
31+
* @throws \CRM_Extension_Exception_ParseException
32+
*/
33+
public function setUpHeadless(): \Civi\Test\CiviEnvBuilder {
34+
// Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
35+
// See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md
36+
return \Civi\Test::headless()
37+
->installMe(__DIR__)
38+
->apply();
39+
}
40+
41+
/**
42+
* Setup for test.
43+
*
44+
* @throws \API_Exception
45+
* @throws \CRM_Csore_Exception
46+
*/
47+
public function setUp():void {
48+
parent::setUp();
49+
50+
$paymentProcessorID = (int) $this->callAPISuccess('PaymentProcessor', 'create', [
51+
'payment_processor_type_id' => 'omnipay_SagePay_Server',
52+
'user_name' => 'sagepay_user',
53+
'is_test' => 1,
54+
'sequential' => 1,
55+
])['values'][0]['id'];
56+
57+
$this->processor = $this->callAPISuccess('PaymentProcessor', 'getsingle', [
58+
'id' => $paymentProcessorID,
59+
]);
60+
}
61+
62+
public function testStateProvinceNotMandatoryInSagePay() {
63+
$processor = new CRM_Core_Payment_OmnipayMultiProcessor('live', $this->processor);
64+
$fields = $processor->getBillingAddressFields(5);
65+
$this->assertArrayNotHasKey('state_province', $fields);
66+
}
67+
68+
}

0 commit comments

Comments
 (0)