Assisted wallet registration

DOCS

Last updated: Aug 15th, 7:24am

You can allow your user to streamline their new mobile wallet registration using their PayPal profile, as illustrated by the following app screen sequence.

Assisted,registration,screen,flow

Figure 1: Assisted registration screen flow

As shown in Figure 1, the app provides a PayPal registration operator, which, when selected, triggers the PayPal Braintree SDK client. When the app switch URL is invoked, the Braintree client checks whether the One-Touch client is installed on the device, which determines whether the PayPal login and consent screens are displayed within the app or launched in a browser. In either case, once the user consents to the integration, the focus returns to the mobile wallet app.

Figure 2 shows the data process flow involved in the assisted registration.

Assisted,registration,sequence,diagram

Figure 2: Assisted registration sequence diagram

As indicated in Figure 2, once the wallet registration is complete, the app can invoke an applicable login method stipulated by the Issuer, and also use the BTPaymentAccountNonce returned by the v.zero client to automatically link PayPal to the wallet as a registered tender.

The next sections provide implementation and samples for each of the relevant calls depicted in Figure 2.

Request the clientToken

Use these commands to request the token and handle the success and failure responses for your device's OS.

OSCommand
iOSretrieveClientToken:(PDRetrieveClientTokenRequest *)request
AndroidgetClientToken(ClientTokenParameters clientTokenParameters)

Within each of the parameter objects, the following data must be passed.

PropertyDescription
providerRequired String
The processor for which the token is valid. The value for this integration is PAYPAL.
tokenOptional String
Some providers require an authorization token from the app to obtain a clientToken. This property is not relevant for this use case

Success response

OSCommand
iOSfetchClientTokenCompletionBlock:(PDRetrieveClientTokenResponse *)response
AndroidonClientTokenRetrieveSuccess (ClientToken clientToken)

Within each of the parameter objects, the following data may be returned:

PropertyDescription
clientTokenString
The btClientToken required to initialize the Braintree SDK client.
additionalInformation
(iOS ONLY)
String
A container for custom property values that may be required or relevant for the integration. Not supported at this time.

Configure the success response to initialize the Braintree SDK client.

Failure response

OSCommand
iOSfetchClientTokenFailureBlock:(PDPaydiantError *utilityServiceManagementError);
AndroidonUserRegistrationError (PaydiantException exception)

Within each of the parameter objects, the following data may be returned:

PropertyDescription
DescriptionString
The basic error description returned by the SDK.
statusMessageString
The Mobile Gateway description associated with the returned statusCode.
statusCodeInteger
The numerical code representing the reason for failure from the Mobile Gateway.
rawErrorDescriptionString
An error description reported by the device system.
localizedDescriptionString
A custom message relevant to the error.
errorInformationString
An object containing error information as obtained from an external party, such as the response from a payment provider.

Samples

Sample retrieveClientToken for iOS

    1- (IBAction)registerPyPLBTNClicked:(UIButton *)sender {
    2 [CommonUtil showProgressIndicatorOnView:self];
    3 PDIssuerServiceCoordinator *utilityServiceCoordinator = [PDIssuerServiceCoordinator new];
    4 PDRetrieveClientTokenRequest *request = [PDRetrieveClientTokenRequest new];
    5 request.provider = @"PAYPAL";
    6 [utilityServiceCoordinator retrieveClientToken:request completionBlock:^(PDRetrieveClientTokenResponse *response) {
    7 // Configure success block to initialize the BTAPIClient
    8 } failureBlock:^(PDPaydiantError *utilityServiceManagementError)
    9}

    Sample getClientToken for Android

      1public ServiceConnection userServiceConnection = new ServiceConnection() {
      2 @Override
      3 public void onServiceConnected(ComponentName name, IBinder service) {
      4 userManagementService = ((LocalBinder < IUserManagementService > ) service).getService();
      5 if (userManagementService != null) {
      6 userManagementService.setUserManagementServiceListener(userManagementListenerAdapter);
      7 userManagementService.getClientToken("paypal");
      8 }
      9 }
      10 @Override
      11 public void onServiceDisconnected(ComponentName name) {
      12 userManagementService = null;
      13 }
      14};
      15UserManagementListenerAdapter userManagementListenerAdapter = new userManagementListenerAdapter() {
      16 // Configure success callback to initialize the BTAPIClient
      17 @Override
      18 public void onClientTokenRetrieveSuccess(ClientToken clientToken) {
      19 super.onClientTokenRetrieveSuccess(clientToken);
      20 initBraintree(clientToken.getClientToken());
      21 }
      22}

      Initialize Braintree SDK client

      Call the Braintree API client, passing the btClientToken returned in the response of the Request the clientToken call.

      Depending on your device, see:

      OSCommand
      iOS/braintree/docs/guides/client-sdk/setup/ios/v4
      Android/braintree/docs/guides/client-sdk/setup/android/v3/

      Samples

      Sample initialize Braintree client for iOS

        1[utilityServiceCoordinator retrieveClientToken:request completionBlock: ^(PDRetrieveClientTokenResponse * response) {
        2 [CommonUtil hideProgressIndicatorOnView: self];
        3 NSString *btClientToken = response.clientToken;
        4 BTAPIClient *apiClient = [[BTAPIClient alloc] initWithAuthorization: btClientToken];
        5 BTPayPalDriver *btPayPalDriver = [[BTPayPalDriver alloc] initWithAPIClient: apiClient];
        6 btPayPalDriver.appSwitchDelegate = (id) self;
        7 btPayPalDriver.viewControllerPresentingDelegate = (id) self;
        8 BTPayPalRequest *checkout = [[BTPayPalRequest alloc] init];
        9
        10 [btPayPalDriver requestBillingAgreement:checkout completion: ^(BTPayPalAccountNonce * _Nullable tokenizedPayPalCheckout, NSError * _Nullable error) {
        11
        12 if (error) {
        13 NSLog(@"ERROR = %@", error);
        14 [CommonUtil hideProgressIndicatorOnView: self];
        15 [CommonUtil displayMessageWithTitle: @"Error"
        16 andDescription: @"Your PayPal account could not be linked at this time. Please try again."];
        17 }
        18 else if (tokenizedPayPalCheckout) {
        19 self.paymentNonce = tokenizedPayPalCheckout.nonce;
        20 NSLog(@"Got a nonce: %@", self.paymentNonce);
        21 }
        22 }
        23 }

        Sample initialize Braintree client for Android

          1private void initBraintree(String clientToken) {
          2 BraintreeFragment mBraintreeFragment;
          3 try {
          4 mBraintreeFragment = BraintreeFragment.newInstance(mActivity, clientToken);
          5 PayPal.requestBillingAgreement(mBraintreeFragment, new PayPalRequest());
          6 } catch (InvalidArgumentException e) {
          7 e.printStackTrace();
          8 }
          9}

          Invoke the wallet registration

          Map profile values

          1. Map the profile values returned in the BTPayPalAccountNonce from the Braintree client to the attributes of the WLW user profile object. Implement the success and failure responses for your device.

          2. Display the registration form in the app, pre-populating profile fields with the mapped values, and prompt user to enter values for wallet credentials not populated by the PayPal profile.

          3. Invoke the device OS-specific WLW SDK call to create a new wallet registration using the completed user profile data.

            OSCommand
            iOSregisterNewUser:(PDRegisterUserRequest *)request
            AndroidregisterUser(CreateCustomer customer)

            Within each of the parameter objects, the following data must be passed:

            iOS PropertyAndroid PropertyDescription
            userProfilecustomerRequired Object
            An instance of PDUserProfile (iOS) or Customer (Android) populated with the values retrieved from the PayPal profile and the login credential values provided by the user. Attributes include:
            firstName
            lastName
            email
            password
            confirmPassword
            passcode
            confirmPasscode
            mfaAnswers
            phone
            additionalInformation
            Use this array of key/value definitions to pass other relevant data collected in the form, such as address or zip code or gender, according to Issuer registration specifications. Refer to the code sample for OS-specific syntax.
          4. Implement the device-specific WLW SDK callback to handle the success response:

            OSCommand
            iOSregisterUserCompletionBlock:(PDRegisterUserResponse *)response
            AndroidonRegisterUserSuccess (CreatedCustomer createdCustomer)

            Within each of the parameter objects, the following data will be returned:

            PropertyDescription
            nonceString
            A one-time access token that can be passed with the LoginByNonce method of the SDK, if applicable.
            customerUriString
            WLW’s unique identifier generated for the new wallet registration.
            MessageString
            Raw data returned by the mobile gateway.
          5. Implement the device OS-specific WLW SDK callback to handle the failure response.

            OSCommand
            iOSregisterUserFailureBlock:(PDPaydiantError *userEnrollmentError);
            AndroidonUserRegistrationError (PaydiantException exception)

            Within each of the parameter objects, the following data may be returned:

            PropertyDescription
            DescriptionString
            The basic error description returned by the SDK.
            statusMessageString
            The Mobile Gateway description associated with the returned statusCode.
            statusCodeInteger
            The numerical code representing the reason for failure from the Mobile Gateway.
            rawErrorDescriptionString
            An error description reported by the device system.
            localizedDescriptionString
            A custom message relevant to the error.
            errorInformationString
            An object containing error information as obtained from an external party, such as the response from a payment provider.

          Samples

          Sample registerNewUser for iOS

            1PDUserProfile * userProfile = [PDUserProfile new];
            2userProfile.firstName = tokenizedPayPalCheckout.firstName;
            3userProfile.lastName = tokenizedPayPalCheckout.lastName;
            4userProfile.email = tokenizedPayPalCheckout.email;
            5userProfile.password = kPwd;
            6userProfile.confirmPassword = kPwd;
            7userProfile.passcode = kPin;
            8userProfile.confirmPasscode = kPin;
            9
            10if (tokenizedPayPalCheckout.phone != nil)
            11 userProfile.phone = tokenizedPayPalCheckout.phone;
            12else
            13 userProfile.phone = @"1234567890";
            14
            15userProfile.mfaQuestionAnswers = self.mfaQuestionsAndAnswers;
            16
            17userProfile.additionalCustomerInformation = [NSDictionary dictionaryWithObjectsAndKeys: @"key", @"value", nil];
            18
            19PDRegisterUserRequest *request = [PDRegisterUserRequest new];
            20request.userProfile = userProfile;
            21
            22PDUserEnrollmentCoordinator *userEnrollment = [[PDUserEnrollmentCoordinator alloc] init];
            23[userEnrollment registerNewUser: request
            24 completionBlock: ^(PDRegisterUserResponse * response){
            25 [CommonUtil hideProgressIndicatorOnView: self];
            26 [CommonUtil displayMessageWithTitle: @"Success"
            27 andDescription: [NSString stringWithFormat: @"%@, %@", userProfile.email, response.message]];
            28
            29 self.addPayPalAfterLogin = YES;
            30 self.loginBTN.hidden = YES;
            31 self.registerBTN.hidden = YES;
            32 self.registerPyPLBTN.hidden = YES;
            33
            34 [self.authenticationCoordinator loginByUsernamePassword:tokenizedPayPalCheckout.email password: kPwd];
            35}
            36 failureBlock: ^(PDPaydiantError * userEnrollmentError)
            37{
            38 ...
            39}

            Sample registerUser for Android

              1@Override
              2public View onCreateView(LayoutInflater inflater, ViewGroup container,
              3Bundle savedInstanceState) {
              4 View rootView = inflater.inflate(R.layout.fragment_register_by_pay_pal, container, false);
              5 final EditText password = (EditText) rootView.findViewById(R.id.txtPasswordRegistration);
              6 final EditText confirmPassword = (EditText) rootView.findViewById(R.id.txtConfirmPasswordRegistration);
              7 final EditText passcode = (EditText) rootView.findViewById(R.id.txtPassCodeReg);
              8 final EditText confirmPasscode = (EditText) rootView.findViewById(R.id.txtPassCodeConfirm);
              9 Button registerButton = (Button) rootView.findViewById(R.id.register_button);
              10 registerButton.setOnClickListener(new View.OnClickListener() {
              11 @Override
              12 public void onClick(View view) {
              13 if (paypalInfoRetrieved && newUser != null) {
              14 newUser.setPassword(password.getText().toString());
              15 newUser.setConfirmPassword(confirmPassword.getText().toString());
              16 newUser.setPasscode(passcode.getText().toString());
              17 newUser.setConfirmPasscode(confirmPasscode.getText().toString());
              18 userManagementServiuserManagementService.registerUser(CustomerTransformer.dtoToDomain(newUser));
              19 } else {
              20 CommonUtils.getInstance().showAlertDialog(mActivity, "PayPal info not retrieved.");
              21 }
              22 }
              23 });
              24 return rootView;
              25}

              Invoke user authentication

              Once the wallet registration successfully completes, invoke whichever login method is supported by your app’s issuing partner. Some options include:

              • LoginByNonce – Pass the nonce returned with the registration success response (not the payment nonce returned by the Braintree client) to complete authentication in the back end, without requiring the user to enter credentials.
              • LoginByPin – Display the PIN Login screen and prompt the user to enter the passcode to complete authentication.
              • LoginByUsernamePassword (+MFA) – Display the Password Login screen and prompt the user to enter credentials and, if applicable, security question responses, to complete authentication.

              Refer to WLW’s SDK documentation for details about specific login calls for iOS and Android.

              Since the user has already consented to the PayPal payment integration through the Braintree client, you can invoke payment account enrollment to automatically link the user’s PayPal account as a payment tender in the wallet as part of the entire registration process, providing a seamless experience for the user.

              1. Invoke the device OS-specific WLW SDK call to start payment account enrollment.

                OSCommand
                iOSstartPaymentAccountEnrollment:(PDStartPaymentAccountEnrollmentRequest *)request
                AndroidstartPaymentAccountEnrollment(StartPaymentAccountEnrollment startPaymentAccountEnrollment)

                Within each of the parameter objects, the following data must be passed:

                PropertyDescription
                enrollmentTypeRequired String
                A value specifying whether WLW will be the system of record for the payment account. For this use case, value is kPDEnrollmentTypeProvision
                paymentAccountTypeUriRequired String
                WLW’s unique identifier for the type of payment account.
                paymentAccountNetworkTypeUriRequired String
                WLW’s unique identifier for the payment processor.
                additionalDataRequired Array
                A set of property instances that define other data required for the enrollment. For this use case, you must define the following:

                key = PAYMENT_METHOD_NONCE
                value = <BTPayPalAccountNonce> value returned by the Braintree client (not the login nonce returned in the registration response)

                key = NICKNAME
                value = PayPal

                key = VAULT_BY_NONCE
                value = TRUE
              2. Implement the device OS-specific WLW SDK callback to handle the success response.

                OSCommand
                iOSstartPaymentAccountEnrollmentCompletionBlock:(PDStartPaymentAccountEnrollmentResponse *)response
                AndroidonRegisterUserSuccess (CreatedCustomer createdCustomer)

                Within each of the parameter objects, the following data will be returned:

                PropertyDescription
                enrollmentStateString
                A value indicating the status of the enrollment operation. In this case, the only successful value is kPDEnrollmentStateEnd
                PaydiantCorrelationIdString
                WLW’s unique identifier for the enrollment operation, which is expected to be passed in subsequent calls related to this enrollment, such as continue or cancel. This value is not applicable for this use case.
              3. Implement the device OS-specific WLW SDK callback to handle the failure response.

                OSCommand
                iOSstartPaymentAccountEnrollmentFailureBlock:(PDPaydiantError *managePaymentInstrumentError);
                AndroidonUserRegistrationError (PaydiantException exception)

                Within each of the parameter objects, the following data may be returned:

                PropertyDescription
                DescriptionString
                The basic error description returned by the SDK.
                statusMessageString
                The Mobile Gateway description associated with the returned statusCode.
                statusCodeInteger
                The numerical code representing the reason for failure.
                rawErrorDescriptionString
                An error description reported by the device system.
                localizedDescriptionString
                A custom message relevant to the error.
                errorInformationString
                An object containing error information as obtained from an external party, such as the response from a payment provider.

              Samples

              Sample auto-enroll PayPal tender for iOS

                1PDStartPaymentAccountEnrollmentRequest *request = [[PDStartPaymentAccountEnrollmentRequest alloc] init];
                2request.enrollmentType = kPDEnrollmentTypeProvision;
                3request.paymentAccountTypeUri = @"paydiant:payment-account-management.accounttype#PayPal";
                4request.paymentAccountNetworkTypeUri = @"paydiant:payment-account-management.networktype#PayPal";
                5
                6NSMutableArray * additionalInfo = [NSMutableArray new];
                7
                8PDStartPaymentAccountEnrollmentAdditionalData *paymentMethodNonce = [PDStartPaymentAccountEnrollmentAdditionalData new];
                9paymentMethodNonce.additionalDataKey = @"PAYMENT_METHOD_NONCE";
                10paymentMethodNonce.additionalDataValue = self.paymentNonce;
                11[additionalInfo addObject: paymentMethodNonce];
                12
                13PDStartPaymentAccountEnrollmentAdditionalData *vaultByNonce = [PDStartPaymentAccountEnrollmentAdditionalData new];
                14vaultByNonce.additionalDataKey = @"VAULT_BY_NONCE";
                15vaultByNonce.additionalDataValue = @"true";
                16[additionalInfo addObject: vaultByNonce];
                17
                18PDStartPaymentAccountEnrollmentAdditionalData *nickName = [PDStartPaymentAccountEnrollmentAdditionalData new];
                19nickName.additionalDataKey = @"NICK_NAME";
                20nickName.additionalDataValue = @"PayPal";
                21[additionalInfo addObject: nickName];
                22
                23request.additionalData = additionalInfo;
                24
                25NSMutableArray * metaDataArray = [NSMutableArray new];
                26PDMetaData * metaData = [PDMetaData new];
                27metaData.key = @"PAYMENT_METHOD_NONCE";
                28metaData.value = self.paymentNonce;
                29[metaDataArray addObject: metaData];
                30request.metaData = metaDataArray;
                31
                32PDManagePaymentInstrumentsCoordinator * managePayInstr = [PDManagePaymentInstrumentsCoordinator new];
                33[CommonUtil showProgressIndicatorOnView:self];
                34[managePayInstr startPaymentAccountEnrollment:request completionBlock: ^(PDStartPaymentAccountEnrollmentResponse *response) {
                35 [CommonUtil displayMessageWithTitle:@"Success"
                36 andDescription:@"Added PayPal to your wallet"];
                37 [CommonUtil hideProgressIndicatorOnView:self];
                38 self.loginBTN.hidden = YES;
                39 self.registerBTN.hidden = YES;
                40 self.registerPyPLBTN.hidden = YES;
                41 self.UnlinkBarBTN.enabled = YES;
                42 self.logoutBarBTN.enabled = YES;
                43 self.walletBTN.hidden = NO;
                44} failureBlock: ^(PDPaydiantError * managePaymentInstrumentsError) {
                45 [CommonUtil hideProgressIndicatorOnView: self];
                46 [CommonUtil displayError: managePaymentInstrumentsError];
                47}];

                Next