public function getMatchingPaymentProfileId($last4)
    {
        if (!$this->isSuccessful()) {
            return null;
        }

        // Handle quirkiness with XML -> JSON conversion
        if (!array_key_exists(0, $this->data['profile']['paymentProfiles'])) {
            $this->data['profile']['paymentProfiles'] = [$this->data['profile']['paymentProfiles']];
        }

        foreach ($this->data['profile']['paymentProfiles'] as $paymentProfile) {
            // For every payment  profile check if the last4 matches the last4 of the card in request.
            $cardLast4 = substr($paymentProfile['payment']['creditCard']['cardNumber'], -4);
            if ($last4 == $cardLast4) {
                return (string)$paymentProfile['customerPaymentProfileId'];
            }
        }

        return null;
    }