The Bidco user profile stores all the personal, address and payment details of the user.

There are two types of user profiles:

  • Temporary: Which lets you build a frictionless bidco experience by allowing guest users to make payments without requiring a Bidco account.
  • Permanent: A profile that exists on the Bidco server which allows a user to log into the same profile at a later time or on another device.

The PTKProfileManager is used used to retrieve and modify profiles in the following ways:



Retrieving the Current User's Profile Information

  1. The profile of the currently authenticated user's, which reflects any successful modifications, can be retrieved using the PTKProfileManager:
PTKProfile *profile = [[PTKManagerFactory sharedManager] profileManager].currentProfile;
  1. Get the list of addresses currently added to the profile with:
NSArray *addresses = profile.addresses;
  1. Get the default address with:
PTKAddress address = profile.defaultAddress;
  1. Get the list of payment instruments currently added to the profile with:
NSArray *paymentInstruments = profile.paymentInstruments;
  1. Get the default payment instrument with:
PTKPaymentInstrument *paymentInstrument = profile.defaultPaymentInstrument;
  1. Get the device ID associated with the profile:
NSString *deviceId = profile.deviceId;
  1. Get the profile ID with:
NSString *profileId = profile.profileId;
  1. Check if the user profile is active and can be used:
BOOL activeProfile = profile.isActive;
  1. Get a list of any custom data keys attached to the profile:
NSArray *customDataValues = profile.customDataValues;

Adding an Address

For more information on displaying addresses see Addresses.

  1. Create a new PTKAddressDetails object and set the address information:
PTKAddressDetails *addressDetails = [PTKAddressDetails addressDetailsWithAlias:@"Alias"
                                                                     firstName:@"Joe"
                                                                      lastName:@"Bloggs"
                                                                         state:nil
                                                                       country:[PTKCountry UnitedKingdom]
                                                                      postCode:@"WC1A 2SL"
                                                                          city:@"London"
                                                                         line1:@"10 Bloombury Way"
                                                                         line2:nil
                                                                        county:@"London"];

  1. Validate the address details

Use PTKAddressDetailsValidator to verify that all address details have been entered correctly.

PTKAddressDetailsValidator *addressDetailsValidator = [PTKAddressDetailsValidator new];
NSArray *errors = [addressDetailsValidator validate:addressDetails];
if (errors) {
for (PTKValidationFailure *validationFailure in errors) {
    NSString *property = validationFailure.propertyName;
        PTKValidationError errorCode = validationFailure.errorCode;
        // Display validation to user and obtain updated value
    }
} else {
	// No issues found while validating the address details
}

For more information on validators please see the Validators page.


  1. Add the address to the user profile using the ProfileManager:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager addAddress:addressDetails completion:^(PTKAddress *addedAddress, NSError *error) {
if (addedAddress) {
    // Address was successfully added
}
}];

Updating an Address

  1. Create an PTKAddressDetails object from an existing Address and modify the address information:
PTKAddress *originalAddress = profile.defaultAddress;
PTKAddressDetails *modifiedAddress = [originalAddress editableCopy];
modifiedAddress.alias = @"Work Address";

  1. Validate the address details

    Use the PTKAddressDetailsValidator to validate the address details as described in step 2 of Adding an Address


  1. Use the PTKProfileManager to update the address information:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager updateAddress:originalAddress addressDetails:modifiedAddress completion:^(PTKAddress *updatedAddress, NSError *error) {
if (updatedAddress) {
    // Address was successfully updated
}
}];

Deleting an Address

  1. Use the PTKProfileManager to delete an existing address:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager deleteAddress:address completion:^(PTKProfile *updatedProfile, NSError *error) {
if (updatedProfile) {
    // Address was successfully deleted from profile
}
}];

Adding a Payment Instrument

  1. Create a new PTKPaymentMethodDetails object to store the card information:
PTKPaymentMethodDetails *paymentMethod = [PTKPaymentMethodDetails paymentMethodDetailsWithCardHolderFirstName:@"Joe"
                                                                                           cardHolderLastName:@"Bloggs"
                                                                                                   cardNumber:@"4111111111111111"
                                                                                                   expiryDate:[PTKYearMonth yearMonthWithYear:2019 month:1]
                                                                                    cardHolderIndentityNumber:@"0123456789"
                                                                                                  issueNumber:@12
                                                                                                validFromDate:[PTKYearMonth yearMonthWithYear:2015 month:1]];

  1. Validate the payment method details

Use PTKPaymentMethodDetailsValidator to verify that all payment method details have been entered correctly.

PTKPaymentMethodDetailsValidator *paymentMethodDetailsValidator = [PTKPaymentMethodDetailsValidator new];
NSError *errors = [paymentMethodDetailsValidator validate:paymentMethodDetails];
if (errors) {
    for (PTKValidationFailure *validationFailure in errors) {
        NSString *property = validationFailure.propertyName;
        PTKValidationError errorCode = validationFailure.errorCode;
        // Display validation to user and obtain an updated value
    }
} else {
    // No issues found while validating the payment details
}

For more information on validators please see the Validators page.


  1. Create a new PTKPaymentInstrumentDetails object and set the payment method, billing address and other information:
PTKCreditCardIssuer *creditCardIssuer = [PTKCreditCardIssuer cardIssuerWithString:PTKCreditCardIssuerVisaString];
PTKPaymentInstrumentDetails *paymentInstrumentDetails = [PTKPaymentInstrumentDetails paymentInstrumentDetailsWithPaymentType:PTKPaymentTypePaymentCard
                                                                                                            creditCardIssuer:creditCardIssuer
                                                                                                               paymentMethod:paymentMethod
                                                                                                              billingAddress:updatedAddress
                                                                                                                       phone:@"01234567890"
                                                                                                               phoneAreaCode:@"+567"
                                                                                                                       email:@"customer@email.com"];

  1. Add the payment instrument to the user profile using the PTKProfileManager:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager addPaymentInstrument:paymentInstrument completion:^(PTKPaymentInstrument *addedPaymentInstrument, NSError *error) {
    if (addedPaymentInstrument) {
        // Payment instrument was successfully added
    }
}];

  1. If the payment instrument needs to be activated, send an activation code to the user.
// Check whether the payment instrument requires activation
if (paymentInstrument.activationStatus != PTKActivationStatusNotRequired) {
    PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
    [profileManager sendActivationCodeForPaymentInstrument:paymentInstrument completion:^(NSError * error) {
        if (error != nil) {
            // Handle error
        } else {
            // Inform user that activation code has been sent
        }
    }];
}

The activation code is sent to the user's mobile number.


  1. The user inputs the activation code and you activate the payment instrument.
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager activatePaymentInstrument:paymentInstrument withActivationCode:activationCode completion:^(PTKPaymentInstrument *paymentInstrument, NSError *error) {
    if (error != nil) {
        // Handle error
    } else {
        // Activation successful
    }
}];

The new payment instrument is now available in the current profile.


Updating a Payment Instrument

Only the billing address of a payment instrument may be modifed.

  1. Use the PTKProfileManager to update the billing address of a payment instrument:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager updatePaymentInstrument:paymentInstrument billingAddress:newBillingAddress completion:^(PTKPaymentInstrument *updatedPaymentInstrument, NSError *error) {
    if (updatedPaymentInstrument) {
        // Payment instrument was successfully updated
    }
}];

Deleting a Payment Instrument

  1. Use the PTKProfileManager to delete an existing payment instrument:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager deletePaymentInstrument:paymentInstrument completion:^(PTKProfile *updatedProfile, NSError *error) {
    if (updatedProfile) {
        // Payment instrument was successfully deleted from profile
    }
}];

Checking the Profile Against a Merchant's Requirements

  1. Before transacting with a merchant you should check if the profile contains all the information required for the merchant.
BOOL canTransact = [profile hasRequiredInfoForMerchant:merchant];

Storing a passcode

  1. A passcode is set as a security measure to ensure that the user is the only one that can authorize payments or make changes to the profile.
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager setPasscode:passcode password:currentPassword completion:^(NSError *error) {
    if (error == nil) {
        // Passcode was successfully updated.
    }
}];

Updating the Profile

  1. Create a new ProfileDetails object and set the profile information:
PTKProfileDetails *profileDetails = [PTKProfileDetails profileDetailsWithTitle:@"M"
                                                                     firstName:@"Joe"
                                                                      lastName:@"Bloggs"
                                                                        gender:PTKGenderMale
                                                                   dateOfBirth:dateOfBirth
                                                                         email:@"jbloggs@emial.com"
                                                                 phoneAreaCode:@"+567"
                                                                  mobileNumber:@"01233355555"
                                                                defaultAddress:defaultAddress
                                                      defaultPaymentInstrument:defaultPaymentInstrument
                                                              customDataValues:@[customDataValue, customDataValue2]];

  1. Validate the profile details

Use PTKProfileDetailsValidator to verify that all profile details have been entered correctly.

PTKProfileDetailsValidator *profileDetailsValidator = [PTKProfileDetailsValidator new];
NSArray *errors = [profileDetailsValidator validate:profileDetails];
if (errors) {
    for (PTKValidationFailure *validationFailure in errors) {
        NSString *property = validationFailure.propertyName;
        PTKValidationError errorCode = validationFailure.errorCode;
        // Display validation to user and obtain an updated value
    }
} else {
    // No issues found while validating the profile details
}

  1. Use the PTKProfileManager to update the current profile:
PTKProfileManager *profileManager = [[PTKManagerFactory sharedManager] profileManager];
[profileManager updateProfileWithDetails:profileDetails completion:^(PTKProfile *profile, NSError *error) {
    if (!error) {
        // Profile information is updated
    }
}];

  1. The updated profile information will be reflected in the users current profile:
PTKProfile *profile = [[PTKManagerFactory sharedManager] profileManager].currentProfile;

Saving the Profile

Saving a guest profile to the Bidco server allows the user to log into the profile at a later time or on another device.
The saveProfileWithPassword method returns a set of coupons that the user can redeem on future purchases. The coupons are automatically saved to the user's profile but returned here so they can be displayed to the user.


  1. Populate the SignUpDetails with the user credentials

You can use the user ID from your App as the identifier for the Bidco profile:

PTKSignUpDetails *signUpDetails = [PTKSignUpDetails signUpDetailsWithPassword:currentUserPassword
hostAppProxyUserId:hostAppProxyUserId];

If you would rather use the Bidco profileId as the identifier:

PTKSignUpDetails *signUpDetails = [PTKSignUpDetails signUpDetailsWithPassword:currentUserPassword];

  1. Save the temporary profile
PTKProfileManager *pm = [PTKProfileManager sharedManager];
[pm saveProfileWithPassword:signUpDetails
completion:^(NSArray<PTKCoupon> *registrationCoupons, NSError *error) {
	if (registrationCoupons) {
		// Profile is now permanent. 
		// Display returned coupons to user
	}
}];