Every time a new customer (payer) registered on the platform and wants to make a payment for the first time, it is necessary to transfer the customer data to the secuconnect-API. The created Customer-ID can then be reused for each additional payment:

$customer = new \SecucardConnect\Product\Payment\Model\Customer();
$customer->id = 'PCU_WMTTCSTJS2M80MHX875XUHDHNM8UA6';

Create a customer

PHP-SDK

Request
/**
 * @var \SecucardConnect\Product\Payment\CustomersService $service
 */
$service = $secucard->payment->customers;

$customer = new Customer();

$contact = new Contact();
$contact->salutation = 'Mr.';
$contact->title = 'Dr.';
$contact->forename = 'John';
$contact->surname = 'Doe';
$contact->companyname = 'Testfirma';
$contact->dob = '1971-02-03';
$contact->birthplace = 'MyBirthplace';
$contact->nationality = 'DE';
// specifying email for customer is important, so the customer can receive Mandate information
$contact->email = 'example@example.com';
$contact->phone = '0049123456789';

$customer->contact = $contact;

$address = new Address();
$address->street = 'Example Street';
$address->street_number = '6a';
$address->city = 'ExampleCity';
$address->country = 'DE';
$address->postal_code = '01234';

$contact->address = $address;

$customer = $service->save($customer);

The country and nationality is given as ISO 3166-2 code.

Response
Created Customer with id: PCU_M0PSEHCWK2M00Y8KX75XUMGS6W8XAQ
Customer data: SecucardConnect\Product\Payment\Model\Customer Object
(
    [created] => DateTime Object
        (
            [date] => 2016-10-14 11:49:29.000000
            [timezone_type] => 1
            [timezone] => +02:00
        )
    [updated] =>
    [contract] => SecucardConnect\Product\Payment\Model\Contract Object
        (
            [created] =>
            [updated] =>
            [parent] =>
            [merchant] =>
            [allow_cloning] =>
            [sepa_mandate_inform] =>
            [id] => PCR_W6AV7JJUJ2YS6WHFR5GQGS99ABZDAP
            [object] => payment.contracts
        )
    [contact] => SecucardConnect\Product\Common\Model\Contact Object
        (
            [salutation] => Mr.
            [title] => Dr.
            [forename] => John
            [surname] => Doe
            [name] => John Doe
            [companyname] => Testfirma
            [dob] => DateTime Object
                (
                    [date] => 1971-02-03 00:00:00.000000
                    [timezone_type] => 1
                    [timezone] => +01:00
                )
            [birthplace] => MyBirthplace
            [nationality] => DE
            [gender] =>
            [phone] => 0049-123456789
            [mobile] =>
            [email] => example@example.com
            [picture] =>
            [pictureObject] =>
            [url_website] =>
            [address] => SecucardConnect\Product\Common\Model\Address Object
                (
                    [street] => Example Street
                    [street_number] => 6a
                    [city] => ExampleCity
                    [postal_code] => 01234
                    [country] => Deutschland
                    [id] =>
                    [object] =>
                )
        )
    [merchant] =>
    [id] => PCU_M0PSEHCWK2M00Y8KX75XUMGS6W8XAQ
    [object] => payment.customers
)

Search for a customer

It's also possible to check if a customer was already created. For this you can f.e. search for the customer by his email and his name.

.NET-SDK

Request
var service = client.Payment.Customers;

// Create a filter to search for an existing customer
var filter = new Product.Common.Model.QueryParams();
filter.Query = "email=example@example.com AND forename=MOE AND surname=Doe";
filter.Count = 1;

// Run the query
var customers = service.GetList(filter);